title: How to influence layout of graph items?
body: <p>I am trying to visualize a simple Finite State Machine graph using Graphviz. The layout created by Graphviz is not completely to my liking. I was expecting a more compact result with shorter edges.</p>
  
  <p>So far, I have tried using groups and changing the weights of edges, but not much luck. It is not clear to me why Graphviz draws the graph the way it does and how to adjust its algorithm to my liking. Are there any parameters I can set to achieve that? Or should I use another command than <code>dot</code>? I tried <code>neato</code>, but the result looked completely messed up and again, I do not really understand what I am doing...</p>
  
  <p>This is my best result so far:</p>
  
  <p><img src="https://i.stack.imgur.com/uRdOA.png" alt="Finite State Machine, best result so far"></p>
  
  <p>Trying to visualize a better lay-out than this, I think the graph would look nicer if the red boxes were aligned differently, more compact for example like indicated by the arrows in this picture:</p>
  
  <p><img src="https://i.stack.imgur.com/OljCC.png" alt="Finite State Machine, imagined better result"></p>
  
  <p>I used <code>dot</code> to create the graph and he source code is as follows:</p>
  
  <pre><code>  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     -&gt; Announced [ label="announce"   ];
   23   Announced -&gt; Assigned  [ label="assign"     ];
   24   Assigned  -&gt; Working   [ label="start"      ];
   25   Working   -&gt; Ready     [ label="finish"     ];
   26   Ready     -&gt; Empty     [ label="revoke"     ];
   27 
   28   edge  [fontname="Arial" color="#aaaaaa" weight=1]
   29   Announced -&gt; TimedOut  [ label="timeout"    ];
   30   Assigned  -&gt; TimedOut  [ label="timeout"    ];
   31   Working   -&gt; TimedOut  [ label="timeout"    ];
   32   Working   -&gt; Failed    [ label="error"      ];
   33   TimedOut  -&gt; Announced [ label="announce"   ];
   34   TimedOut  -&gt; Empty     [ label="revoke"     ];
   35   Failed    -&gt; Announced [ label="announce"   ];
   36   Failed    -&gt; Empty     [ label="revoke"     ];
   37 
   38   edge  [style=bold, fontname="Arial" weight=1]
   39   Created   -&gt; Empty     [ label="initialize" ];
   40   Empty     -&gt; Destroyed [ label="finalize"   ];
   41   Announced -&gt; Empty     [ label="revoke"     ];
   42   Assigned  -&gt; Empty     [ label="revoke"     ];
   43   Working   -&gt; Empty     [ label="revoke"     ];
   44 }
  </code></pre>
  
  <p>Also, anybody please let me know if I do any strange things in the Graphviz file above -- any feedback is appreciated.</p>
  
  <hr>
  
  <p>Update:</p>
  
  <p>More experimenting and trying some suggestions like ports, given by user marapet, have increased my confusion... For example, in the picture below, why does <code>dot</code> choose to draw these strange detours for <code>Working-&gt;Failed</code> and <code>Failed-&gt;Announced</code>, as opposed to straighter lines?</p>
  
  <p><img src="https://i.stack.imgur.com/VY1gt.png" alt="Graph with strange long edges"></p>