I am trying to visualize a simple finite state graph using Graphviz. The layout created by Graphviz is not really to my liking. I expected a more compact result with shorter edges.
So far I have been trying to use groups and changing the weight of the ribs, but not very good luck. I donβt understand why Graphviz draws a graph the way it does, and how to customize its algorithm to your liking. Are there any options that I can set for this? Or should I use a command other than dot
? I tried neato
, but the result looked completely spoiled and again, I do not quite understand what I am doing ...
This is my best result:
Trying to imagine a better scheme than this, I think that the graph will look better if the red fields are aligned differently, more compact, for example, as shown by the arrows in this figure:
I used dot
to create a graph, and its source code is as follows:
1 digraph JobStateDiagram 2 { 3 rankdir=LR; 4 size="8,5"; 5 6 node [style="rounded,filled,bold", shape=box, fixedsize=true, width=1.3, fontname="Arial"]; 7 Created [fillcolor=black, shape=circle, label="", width=0.25]; 8 Destroyed [fillcolor=black, shape=doublecircle, label="", width=0.3]; 9 Empty [fillcolor="#a0ffa0"]; 10 Announced [fillcolor="#a0ffa0"]; 11 Assigned [fillcolor="#a0ffa0"]; 12 Working [fillcolor="#a0ffa0"]; 13 Ready [fillcolor="#a0ffa0"]; 14 TimedOut [fillcolor="#ffa0a0"]; 15 Failed [fillcolor="#ffa0a0"]; 16 17 { 18 rank=source; Created Destroyed; 19 } 20 21 edge [style=bold, fontname="Arial" weight=2] 22 Empty -> Announced [ label="announce" ]; 23 Announced -> Assigned [ label="assign" ]; 24 Assigned -> Working [ label="start" ]; 25 Working -> Ready [ label="finish" ]; 26 Ready -> Empty [ label="revoke" ]; 27 28 edge [fontname="Arial" color="#aaaaaa" weight=1] 29 Announced -> TimedOut [ label="timeout" ]; 30 Assigned -> TimedOut [ label="timeout" ]; 31 Working -> TimedOut [ label="timeout" ]; 32 Working -> Failed [ label="error" ]; 33 TimedOut -> Announced [ label="announce" ]; 34 TimedOut -> Empty [ label="revoke" ]; 35 Failed -> Announced [ label="announce" ]; 36 Failed -> Empty [ label="revoke" ]; 37 38 edge [style=bold, fontname="Arial" weight=1] 39 Created -> Empty [ label="initialize" ]; 40 Empty -> Destroyed [ label="finalize" ]; 41 Announced -> Empty [ label="revoke" ]; 42 Assigned -> Empty [ label="revoke" ]; 43 Working -> Empty [ label="revoke" ]; 44 }
Also, someone, please let me know if I do any weird things in the Graphviz file above - any feedback would be appreciated.
Update:
More experimentation and attempting some suggestions, such as ports specified by marapet, increased my confusion ... For example, in the image below, why dot
chooses to draw these strange detours for Working->Failed
and Failed->Announced
, as opposed to more direct ones lines?