An Introduction to GraphViz

By Mihalis Tsoukalos on Wed, 2004-09-08 23:00.

How to use command-line tools and basic GraphViz utilities to produce graphs both simple and complex.

GraphViz is a collection of tools for manipulating graph structures and generating graph layouts. Graphs can be either directed or undirected. GraphViz offers both graphical and command-line tools. A Perl interface also is available, but it is not covered here for reasons of generality. Graphical tools are not going to be discussed in this article either. Instead, this article focuses on using GraphViz from the command line.

Example GraphViz code:
    digraph G {
      size ="4,4";
      main [shape=box]; /* this is a comment */
      main -> parse [weight=8];
      parse -> execute;
      main -> init [style=dotted];
      main -> cleanup;
      execute -> { make_string; printf}
      init -> make_string;
      edge [color=red]; // so is this
      main -> printf [style=bold,label="100 times"];
      make_string [label="make a\nstring"];
      node [shape=box,style=filled,color=".7 .3 1.0"];
      execute -> compare;

Shown here:


pydot --d2m, Fri, 11 Mar 2005 11:25:55 -0800 reply
( ) is a very good and complete python interface to the GraphViz library. It is easy to be used through external methods or inside fs-based products.

graphviz in zwiki --simon, Wed, 14 Sep 2005 12:03:59 -0700 reply
Here are graphviz commands embedded in a zwiki page:

Has someone generated graphviz output from zwiki pages ?

maybe this --simon, Wed, 14 Sep 2005 12:06:13 -0700 reply
I think does it, though perhaps not with graphviz, requires a java plugin

How to configure GraphViz support? --rmaurizzi, Thu, 26 Mar 2009 18:26:51 -0700 reply
(yes I've seen the other comment are from 2005... a voice from the grave :D ) I've setup a ZWiki 0.60.0, with integrated MathAction. It works: latex gets rendered and axiom does it work. But I can't understand how I include support for GraphViz... is there something missing in MathAction? Or the support is purely from Latex so I have to do something to my Latex installation, like maybe copy graphviz.tex somewhere?

How to configure GraphViz support? --simon, Fri, 27 Mar 2009 20:37:33 -0700 reply
Good to hear mathaction setup worked for you.. you're the third I've heard of, after Bill Page and myself. I never got as far as setting up graphviz integration but maybe tells you more ?

I think my problem is in the Latex system setup... --r.maurizzi, Sat, 28 Mar 2009 05:50:40 -0700 reply
It's the same even with the samples on that page. I'd say that the problem is either in my latex installation that doesn't integrate \digraph (and \psfrag too...) or in the latex template that doesn't include the support. I'll try to do some more test, but I'm no latex expert.

BTW, I'm trying to take a look at the code in MathAction plugin, and I've found a couple of hardcoded paths that can cause problems:  err, stdout, stderr = runCommand('/usr/local/teTeX/bin/i686-pc-linux-gnu/dvips -o %s %s'%(psfileName, dvifileName))  cmdLine = '/usr/bin/maxima -p /zope1/Products/ZWiki/plugins/mathaction/mathaction-maxima-5.9.3.lisp < %s' %(maximaFileName)

Solved! --r.maurizzi, Sat, 28 Mar 2009 07:09:03 -0700 reply
So... it appears you have to modify the Latex template used by MathAction to "input" graphviz.tex ( ) and to "usepackage" its dependency graphicx. I modified the default template in as follows:

  # This is only used if your wiki does not have a node LatexTemplate.
  defaultLatexTemplate = r"""
  """  % (charsizept)

It should be possibile to have a LatexTemplate? Zope document in the wiki from what I read around, but I didn't experiment with this for the moment.

The "trick" was knowing that Latex doesn't have a default path: if you use "input" it expects to find the file in the current directory, in this case the LatexWiki directory in the $INSTANCEHOME/var/LatexWiki (the one you must map with LocalFS).

I'll have to find a better place to put it and having it parsed by Latex, because the that directory gets cleaned of all *.tex file after every page rendered... ^^;

I think my problem is in the Latex system setup... --Simon Michael, Sat, 28 Mar 2009 09:51:27 -0700 reply
Thanks. Note the mathaction plugin has been dropped in Zwiki 2.

Solved! --Simon Michael, Sat, 28 Mar 2009 09:51:48 -0700 reply