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 {
  "org-mode"
  "org-exp-blocks"
  "dot"
  "ditaa"
  "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 http://orgmode.org/worg/org-contrib/org-exp-blocks.php  More examples can be found at  http://www.graphviz.org/Gallery.php.

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 http://www.graphviz.org/mywiki/FaqBalanceTree

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:http://stackoverflow.com/questions/3128854/graphviz-how-to-assign-the-same-style-to-a-group-of-edges
http://stackoverflow.com/questions/3128854/graphviz-how-to-as

Additional Resources for Graphviz
    *      http://www.mactech.com/articles/mactech/Vol.25/25.01/IntroductiontoGraphviz/index.html
    *      http://edutechwiki.unige.ch/en/Graphviz
    *      http://www.ffnn.nl/pages/articles/media/uml-diagrams-using-graphviz-dot.php
    *      Data Visualisation
    *      Python's Pydot
    *      Haskell's Data.GraphViz
    *      http://developer.mindtouch.com/AppCatalog/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



Comments