Drawing Reflective Edges in State Machines

I have to draw a small finite state machine that has some reflective transitions (that is, the initial and final state of the transition are equal.

The problem is that rendering in Graphviz has terrible results.

digraph finite_state_machine { edge [fontsize=11]; S0 -> S0 [label = "td=1\n-/e2"]; S0 -> S1 [label = "td=3 \n-/e3" ]; S1 -> S0 [label = "td=3\n-/-\nt=0"]; S0 -> S2 [label = "P:i1/e4"]; S2 -> S0 [label = "td=0\n-/-" ]; S0 -> S0 [label = "i1/e1\ntd+=1"]; } 

A rendering of the state machine

Is there a way to make this a little better?

By the way: I tried head / tailport, but they do not work on my version of Graphviz (1.13 on Mac OS X)

I'm not limited to the point engine, I just want a good looking graph and don't care about the renderer / language.

many thanks

+4
source share
1 answer

So, if a workaround is found, but not really the answer to my problem.
The trick is to have an invisible node that connects to the initial state. the initial state is then not the top of the hierarchy, and it has a little more freedom in the allocation of nodes. In addition, the head / tailport attributes work as they should. The result - if not beautiful as I would like - is good to watch.

 digraph finite_state_machine { edge [fontsize=7]; fontsize = 11; rankdir=LR; {rank = same;null} {rank = same; S0} {rank = same; S1 S2} nodesep = 1; ranksep = 1; null [shape = plaintext label=""]; null -> S0; S0 -> S0 [label = "td=1\n-/e2", tailport = n, headport = n]; S0 -> S1 [label = "td=3 \n-/e3" ]; S1 -> S0 [label = "td=3\n-/-\nt=0"]; S0 -> S2 [label = "P:i1/e4"]; S2 -> S0 [label = "td=0\n-/-" ]; S0 -> S0 [label = "i1/e1\ntd+=1" headport = s tailport = s]; } 

state machine rendering http://img532.imageshack.us/img532/4083/previewd.png

While this works (for this specific example), I would really like some advice on dot / Graphviz or an alternative for rendering state machines in a nice way.

+5
source

Source: https://habr.com/ru/post/1308188/


All Articles