[index] [home]

Tweet

Dot/Graphviz useful things



(Taken from dot User's Manual - this text is not complete, by far.)

Defaults are given in parentheses, if applicable.

General syntax

Study this, young padawan, for 2 minutes, and learn:

First, look at the pretty picture:

This graph was produced by running

dot -Tpng Dot_and_Graphviz.dot -o Dot_and_Graphviz.png

...where contents of dot_graphviz.dot are as follows:

1  :    digraph G {
2  :      main [ shape = box ]   /* this is a comment... */   // ...and so is this.
3  :      main -> parse
4  :      parse [ shape = parallelogram ];   // semicolons are mostly optional
5  :      parse -> execute [ weight = 8 ]
6  :      init -> execute
7  :      main -> init [ style = dotted ]
8  :      execute -> { make_string; printf }
9  :      edge [ color = red ]
10 :      main -> printf [ label = "100 times" ]
11 :      make_string [ label = "a nice\nmulti-line\lstring\rhere" ]
12 :      node [ shape = box, style = filled, color = green, peripheries = 2 ]
13 :      execute -> compare
14 :      execute [ shape = diamond ]
15 :      node [ shape = triangle ]
16 :      execute
17 :    }

Perhaps-not-immediately-obvious things to note:

Some other things to remember:

Spoiler for attributes in following sections:

Fonts

Don't bother - just use Helvetica to make it look a bit less ancient:

dot -Gfontname=$(DOT_FONT) -Nfontname=$(DOT_FONT) -Efontname=$(DOT_FONT) \
    -Tpng -o dot.png dot.dot

(-G, -N and -E for graph, node and edge)

Useful graph attribs

Useful node-attribs

Useful edge-attribs


Delivered to you by Vim, GNU Make, MultiMarkdown, bozohttpd, NetBSD, and 1 human.