Modelling state machines
Monday, 14. April 2008, 19:11:05
The following example (from Wikipedia) shows a simplified example of what I'd like to get as the end result.
It seemed like Graphviz was a sure fit to those criteria. This is what the above graph would look like if written in the DOT language that graphviz groks:
digraph simple_state_machine {
node [shape = doublecircle]; S1;
node [shape = circle] S2;
node [shape = point] S0;
S0 -> S1;
S1 -> S2 [ label = "0" ];
S1 -> S1 [ label = "1" ];
S2 -> S1 [ label = "0" ];
S2 -> S2 [ label = "1" ];
} As you see this is fairly easy to write, and super easy to change. Exactly what I wanted in other words. Here's the output file:Now the end result isn't as nice as the first example, which was "hand-drawn" in Inkscape judging by the comments in the file. Which brings me to my question: is there a program that can process the DOT input to produce something more similar to the first picture?









Anonymous # 15. April 2008, 08:30
This might be too complicated for your needs, so it depends on how much graphs you need to generate...
Use Dot2TeX to convert your graphs to LaTeX (which has much greater presentation capabilities)
Compile it using latex
convert the resulting image from postscript/dvi to svg.
Dan Alexandru # 15. April 2008, 19:20
Erik Dahlström # 16. April 2008, 10:04
Anonymous # 16. April 2008, 14:02
try other modes - maybe twopi - it looks more symmetric or play with wheights of edges. graphviz is more general tool than drawing nifty looking diagrams - it will handle big complicated layouts that are impossible to draw pretty.
Erik Dahlström # 30. April 2008, 10:24
There are a number of things I'd like to do with the svg output:
1. use a <style> element to get less duplication (makes files smaller)
2. arrows should use svg markers, instead of being just a dumb path duplicated everywhere
3. get rid of the DTD cruft
4. make sure "px" is specified on font-size in style attributes (if used at all)