title: Can I minimize arc length in dot graph?
body: <p>I have a rather constrained dot graph that is not coming out how I want.</p>
  
  <p>The graphs are intended to represent a dynamic Bayesian network and has an arbitrary number of time slices. I need all nodes in one time slice to be ordered vertically in the same subgraph and each subgraph to be aligned horizontally and preferably equidistant.</p>
  
  <p>Below is the messy DBN generated by the code at the bottom of this question - it's a relatively simple example but should illustrate the problem. I'd prefer to have the arcs from the 't-1' to 't' subgraph and the 't' to 't+1' subgraph look identical, and avoid looping arcs like 'c(t-1)' to 'e(t)' and also have the subgraphs equidistant.</p>
  
  <p>Adjusting the weight of 'c(t-1)' to 'e(t)' does nothing and the code to generate this dot file should be general.</p>
  
  <p>I'm not attached to dot if there's a better program for this type of problem.</p>
  
  <p><img src="https://i.stack.imgur.com/us2eu.jpg" alt="enter image description here"></p>
  
  <p>The code to generate the graph is:</p>
  
  <pre><code>digraph G {
  
      1 [ label = "a(t-1)" ];
      2 [ label = "b(t-1)" ];
      3 [ label = "c(t-1)" ];
      4 [ label = "d(t-1)" ];
      5 [ label = "e(t-1)" ];
      6 [ label = "a(t)" ];
      7 [ label = "b(t)" ];
      8 [ label = "c(t)" ];
      9 [ label = "d(t)" ];
      10 [ label = "e(t)" ];
      11 [ label = "a(t+1)" ];
      12 [ label = "b(t+1)" ];
      13 [ label = "c(t+1)" ];
      14 [ label = "d(t+1)" ];
      15 [ label = "e(t+1)" ];
      rankdir=TB
  
      edge[style=invis];
  
      {
          rank=same;
          K_1 [style=invis] ;
          K_2 [style=invis] ;
          K_3 [style=invis] ;
          K_1 -&gt; K_2 ;
          K_2 -&gt; K_3 ;
      }
  
  
      subgraph cluster1 {
      style=dotted ;
          1 -&gt; 2;
          2 -&gt; 3;
          3 -&gt; 4;
          4 -&gt; 5;
          label="t-1" ;
      }
  
      subgraph cluster2 {
      style=dotted ;
          6 -&gt; 7;
          7 -&gt; 8;
          8 -&gt; 9;
          9 -&gt; 10;
          label="t" ;
      }
  
      subgraph cluster3 {
      style=dotted ;
          11 -&gt; 12;
          12 -&gt; 13;
          13 -&gt; 14;
          14 -&gt; 15;
          label="t+1" ;
      }
  
      K_3 -&gt; 11[style=invis] ;
      K_2 -&gt; 6[style=invis] ;
      K_1 -&gt; 1[style=invis] ;
  
      edge[constraint=false,style=solid] ;
      3 -&gt; 10 ;
  
      8 -&gt; 15 ;
  
  }
  </code></pre>