Graphviz Quick Start

If you're about to write a new .gv file, let me give you a leg up.

Creating graphviz documents quickly is a bit of an art. This is the case of most communication after all.

digraph {

// Styling.
rankdir = "LR";
node [fontname = "verdana" fillcolor="grey95" style="filled"];

// Nodes.
Alice [shape="box" label="Alice (user)"];
Bob [shape="box" label="Bob (user)"];

// Edges.
Alice -> Bob [label="whassup" color="red"];
Bob -> Alice [label="watching the game" color="blue"];

}

I like to split my files in sections and add comments. Start with overall styling, then add nodes, then add the edges.

Make sure to add comments if these are part of your development tools, which I highly recommend!

I'll add a few more tips in the future, but the above is a good starting point.

Make sure you play with rankdir - sometimes TB will make things easier to follow.

Happy graphs!

Tags:  design

Home