Drawing graphs with dot

Table of Contents

1 Basic Graph Drawing

Draws graphs in four phases:

  1. Depends on graph being acyclic \(\rightarrow\) break any cycles by reversing the internal direction of certain cyclic edges.
  2. Assign nodes to discrete ranks or levels. In a top-to-bottom drawing, ranks detemine Y coordinates.
  3. Orders nodes within a rank to avoid crossings.
  4. Set X coordinates of nodes to keep edges short, and route the edge splines.

1.1 Components

Language describes three kinds of objects:

  • graphs
  • nodes
  • edges

1.2 Drawing

Main graph (outermost) can be:

  • directed, digraph
  • undirected, graph

Within the main graph, a subgraph defines the subset of nodes and edges.

digraph G {
    main -> parse -> execute;
    main -> init;
    main -> cleanup;
    execute -> make_string;
    execute -> printf
    init -> make_string;
    main -> printf;
    execute -> compare;


2 Reference