3

Consider the following simple flow diagram. I like using the graph drawing library in TikZ for its simplicity and semantics:

\documentclass{standalone}

\usepackage{tikz}
    \usetikzlibrary{graphdrawing}
    \usegdlibrary{trees}

\begin{document}

    \tikz[>=latex]
        \graph[
            tree layout,
            node pre sep = 0.2em,
            grow=right,
            },
        ]
        {
            A -> B -> C -> D -> E -> (A.south)
        };

\end{document}

This code connects an arrow from E.west to A.south that crosses the other nodes. How can I create a loop that leaves E.south or E.east and then goes downwards to enter A.south or maybe A.west in the end again?

  • 1
    The code does not compile. – mvkorpel Jul 10 '14 at 9:40
4

Three options:

\documentclass[border=6pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing}
\usegdlibrary{trees}

\begin{document}

\begin{tikzpicture}[>=latex]
\graph[
  tree layout,
  node pre sep = 0.2em,
  grow=right,
  ]
  {
    A -> B -> C -> D -> E ->[bend left] A
  };
\end{tikzpicture}\quad
\begin{tikzpicture}[>=latex]
\graph[
  tree layout,
  node pre sep = 0.2em,
  grow=right,
  ]
  {
    A -> B -> C -> D -> E ->[out=-90,in=-90] A
  };
\end{tikzpicture}\quad
\begin{tikzpicture}[>=latex]
\graph[
  tree layout,
  node pre sep = 0.2em,
  grow=right,
  ]
  {[name=str]
    A -> B -> C -> D -> E 
  };
  \draw[-] (str E.east) to[out=0,in=0] ([yshift=-15pt]str C);
  \draw[<-] (str A.west) to[out=180,in=180] ([yshift=-15pt]str C);
\end{tikzpicture}

\end{document}

enter image description here

The first two options use the fact that you can use the ->[...] syntax to modify the path; the third option uses the [name=<string>] prefix for the graph nodes and then two appropriate \draw commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.