Drawing Flow Diagrams with GraphViz
The diagram itself looks like this – it’s a simplified representation of choosing an access modifier in PHP:
It’s generated using the following code:
digraph {
start [label="Start"];
start -> decision;
decision [shape=diamond, label="Accessed externally?"];
decision -> public [label="Yes"];
decision -> notpublic [label="No"];
public [shape=box, label="public"];
notpublic [shape=diamond, label="Deny to children?"];
notpublic -> protected [label="No"]
notpublic -> private [label="Yes"]
protected [shape=box, label="protected"]
private [shape=box, label="private"]
{ rank=same; decision; public }
{ rank=same; notpublic; private }
}
I used a few different shapes to create the elements shown, and this is a directed graph. To show the decisions, I used labels on edges. And to line everything up as shown here, I used the rank=same settings, to put pairs of elements at the same level, even though graphviz would have started at the top and then added downwards arrows for each element.
Thanks. This helped me to start my own flow diagrams with graphviz.
Very nice. Did you ever expand this example to have decisions that have to make arrows go back up to previous steps, as a possible loop? I’m looking to do similar things to what you have here, but I have elements that make you possibly redo steps…