[Tex/LaTex] TikZ/pgf: How to draw edges that start and end at the same node when using the `graphdrawing` library

tikz-pgf

I have borrowed this example from http://www.texample.net/.

enter image description here

The graph exhibits a characteristic that I do not know how to reproduce using the graphdrawing library: its nodes have edges that start and end at the same node. How would this be done when using the graphdrawing library?

Here's what I have tried so far. I attempted to force the edge length to be a certain amount, so that the algorithm would have to draw a edge with that length, but then also loop it back. It seems that this command does not force the edge to be a certain length, and thus produces a nonsense result.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usegdlibrary{force, layered, trees}

\begin{document}


    \tikz [rounded corners]
        \graph [spring layout]
        {
            a ->
            {
                b ->[length=3] b
            }
        };

\end{document}

Best Answer

After seeing an example here, which showed how [bend right] could be used with edges in graphdrawing, I tried [loop right] similar to what the example I first presented does. Lo and behold, it works.

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{arrows}
\usetikzlibrary{graphs}
\usegdlibrary{force, layered, trees}

\begin{document}


    \tikz [rounded corners]
        \graph [spring layout]
        {
            a ->
            {
                b ->[loop right] b
            }
        };

\end{document}

enter image description here

Related Question