Modelling state machines
Monday, 14. April 2008, 19:11:05
I was trying out some various ways of creating a simple state machine illustration in SVG this weekend. Basically I'm looking for a fairly highlevel description language that allows me to make changes easily while still providing automated layout and a good aestetic result that can be exported to SVG.
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:
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?
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?
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.
By anonymous user, # 15. April 2008, 08:30:02
By dantesoft, # 15. April 2008, 19:20:18
By MacDev_ed, # 16. April 2008, 10:04:17
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.
By anonymous user, # 16. April 2008, 14:02:49
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)
By MacDev_ed, # 30. April 2008, 10:24:45