Graphviz

Graphviz is a great tool for visualizing graphs, especially trees and dags (but not doges). We'll be using Graphviz in class for examples, so here's a quick primer:

At a high level, a Graphviz input file contains descriptions of nodes and edges. Nodes have this basic syntax:

ID[label="LABEL"];

which tells Graphviz to draw the node ID with label LABEL. Edges have this basic syntax:

ID1 -> ID2;

which tells Graphviz to draw an edge from the node with id ID1 to the node with id ID2. The description of your graph's edges and nodes should appear between curly braces after the digraph keyword:

digraph {
  EDGES
  NODES
}

Note that you can freely mix node and edge descriptions.

For a simple example, we can graph the student life:

digraph {
  1 -> 2;
  2 -> 3;
  3 -> 1;
  1[label="Eat."];
  2[label="Study."];
  3[label="Sleep."];
}

which we can save in a file life.dot and render with the dot command:

$ dot -Tpng life.dot > life.png

yielding this nice image:

For more on getting the most out of dot, check the dot user guide.