Graph a Structure with Graphviz

Graphviz will draw a graph composed of nodes and arrows from a declarative text description. Here we describe how to get something up fast and then annotate that with useful debugging results.

Things to Try

Make a file, try1.dot, that contains this dot program. Open it with Graphviz. download

digraph { 1 -> 2 -> 3 -> 4; 1 -> 3; 2 -> 4; }

Try using the Graphviz Plugin. About Graphviz Plugin

digraph { 1 -> 2 -> 3 -> 4 1 -> 3 2 -> 4 rankdir=LR }

Try making a cycle by adding an edge bottom to top.

4 -> 1;

Uploaded image

How it Works

Nodes

A node can be a number or a name or an arbitrary string inside of quotes.

Edges

An edge between nodes is shown with -> which can be daisy-chained in some cases.

Graph vs. Digraph

Use digraph to surround a directed graph.

Use graph to surround an undirected graph.

Use strict to collapse duplicate edges. This can be handy when generating dot files with a program.

strict graph { 1 -- 2 -- 3; 2 -- 3; 1 -- 2; }

strict graph { 1 -- 2 -- 3 2 -- 3 1 -- 2 rankdir=LR }

Triggers

When you sketch a diagram on paper, write the dot filename on the sketch were you will keep the dot version.

When you are considering changing flows in a system, first draw and print the existing flows then sketch changes on the paper. Repeat as needed.