Graphviz Introduction

Graphviz is a program to generate diagrams of graph structures. It has its own "dot" language and the general intent is that you programmatically generating the inputs for graphviz.

In the words of the description from the homepage:

"Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. Automatic graph drawing has many important applications in software engineering, database and web design, networking, and in visual interfaces for many other domains. …

In practice, graphs are usually generated from an external data sources, but they can also be created and edited manually, either as raw text files or within a graphical editor. (Graphviz was not intended to be a Visio replacement, so it is probably frustrating to try to use it that way.) "

Graphviz looks at nodes and edges (the connections between the nodes), applies various attributes, then generates a graphic in one of many formats. You can apply attributes globally or individually to nodes and edges. The programming focus is on how to generate the edge relationships and then what attributes to apply to each node or edge.

A sample input to graphviz, looking like this:

digraph data_relationships {
  "HTML" [shape=Mrecord, label="{HTML|publish on the web\l}"]
  "LaTeX" [shape=Mrecord, label="{LaTeX|publish in PDF\l}"]
  "org-mode" -> "org-exp-blocks"
  "dot" -> "org-mode"
  "ditaa" -> "org-mode"
  "org-exp-blocks" -> "HTML"
  "org-exp-blocks" -> LaTeX

generates a graphic like this:

This particular example was borrowed from  More examples can be found at

Graphviz Tidbits

Printing a graph on multiple pages

This is available only with Postscript output. Set the page attribute for the graph to page="8.5,11" and it will generate a postscript array of pages of the given size.

Balancing tree output

When a tree node has an even number of children, it isn't necessarily centered above the two middle ones. If you know the order of the children, a simple hack is to introduce new, invisible middle nodes to re-balance the layout. The connecting edges should also be invisible. For example, see

Subgraphs and clusters

This is a missing piece from cl-dot.

Clusters are subgraphs, but not all subgraphs are clusters. For example, you can create subgraphs to assign the same style to edges
which are not in a contigous group of nodes.  See the example given here:

Additional Resources for Graphviz
    *      Data Visualisation
    *      Python's Pydot
    *      Haskell's Data.GraphViz

Lisp Alternative Libraries

If you program in lisp and want to automatically generate some diagrams from a database to visualize relationships, you can write your own  program to generate dot language strings and dump them in a file for dot to read or you can look at the potential lisp libraries for assistance. There seemed to be two potential other alternatives: cl-dot and s-dot. (There is also cl-graphviz, but I had a hard time getting to the project location)

Common data and functions for Lisp examples