I would like to draw an algorithm diagram with Tikz
. In this diagram, I would like to show which subroutine call which other one. And also that the diagram could be read from the upper left to the down right.
I've looked on the web for a good way to draw this kind of algorithm diagram (as I want) and found this :
I glanced at the pgf documentation and performed a few tests :
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{graphs}
\begin{document}
\begin{tikzpicture}[every node/.style = draw]
\graph [grow right sep, left anchor=south, right anchor=west,
grow down=7mm,grow right=7mm]{
root -> {
child 1,
child 2 -> {
grand child 1,
grand child 2
},
child 3 -> {
grand child 3
}
}
};
\end{tikzpicture}
\end{document}
Honestly, I'm not familiar at all with this library and graph options. But I'm sure that they have to be modified to create a diagram as the example I've given (see the link above).
Does anyone have an idea how to do this ?
Could you please give some advice about the graph options I need to fix ?
Best Answer
Basic framework: http://www.texample.net/tikz/examples/filesystem-tree/
Have a look to 21. Making trees grow in PGF Manual.
The solution is my first try with it, so its not perfect.
You can create
nodes
andchilds
. The distance between the levels can defined withlevel distance=<length>
. Connection between node and child it set withedge from parent path={[->] ([xshift=.5em]\tikzparentnode.south west) |- (\tikzchildnode.west)}]
. (Thexshift
is optional). You can also adddashed
.The child position is set with
grow via three points={...}
have a look to chapter 72.1 Growth Functions in PGF Manual. For space/ blank childs you can addchild [missing] {}
.Optional you can set the nodes also to
dashed
and notsolid
or something else.MWE: