Friday 2 November 2007

GraphViz fun


I'm writing a tiny toy project involving automata, which was a good excuse to learn the dot language finally. I used GraphViz couple of times before and was very fond of it. After trying out several approaches I decided to put down all things I needed in order to get my automata graphs render as needed. These were:


  1. Print the epsilon character.
  2. Switch the orientation to horizontal (it's vertical by default).
  3. Render a double circle node.
  4. Render several graphs in a single plot.
  5. Have invisible nodes.
  6. Have invisible edges.


Having all this before my eyes, it became obvious that the only way to learn how to do it is by example, which is exactly what entered in google. I found this amazing flickr set with examples addressing almost all my problems. So here are the answers:


Print the epsilon character.
You can use html entities in your labels
Switch the orientation to horizontal.
Pass the directive rankdir=LR
Render a double circle node.
node [shape=doublecircle]
Render several graphs in a single plot.
This one was actually not a problem at all - if your nodes don't connect, you get an unconnected graph
Have invisible nodes.
node [shape=plaintext label=""]
Have invisible edges.
edge [style=invis]


So, the presentation's ready. Time to start writing the algorithm :)

1 comment:

Oren said...

Thanks a bunch!