title: GraphViz node ordering for Ternary Search Trees
body: <p>I am trying to make a Ternary Search Tree in GraphViz, using dot language. Problem is to balance the layout so it looks nice and neat, so that left, mid and right are perfectly aligned.</p>
  
  <p>I've been searching and experimenting with invisible nodes, but without success.
  The middle nodes makes it difficult to make it look good and thus the children nodes are not aligned like the tree should be.</p>
  
  <p>I came across <a href="https://stackoverflow.com/a/10905657">this</a> answer, which looks great.
  However, I am not sure how you can edit his calculations for three children left, mid and right.
  I've been trying now for days, but without any success.</p>
  
  <p>Any Ideas?</p>
  
  <p>I also made a topic on their <a href="http://www.graphviz.org/content/tree-balancing-problem#comment-2671" rel="nofollow noreferrer">forums</a> of one attempt I made.</p>
  
  <p><strong>-SOLVED-</strong></p>
  
  <p>By using weights correctly, I solved this problem.
  See <a href="http://www.graphviz.org/content/tree-balancing-problem#comment-2671" rel="nofollow noreferrer">GraphViz forum</a>.</p>
  
  <pre><code>digraph {
  nodesep=0.35
  ordering=out
  node[style="filled", fillcolor="grey"]
  edge[color="blue", arrowhead="vee"]
  { node[shape=point style=invis] m5 m2 m8 m6 m4 m10 m11 m12 m13 m14 m15}
  s -&gt; m5 [style=invis]
  s -&gt; h  [weight=100]
  s -&gt; m2 [style=invis]
  h -&gt; m8 [style=invis]
  h -&gt; e [weight=100]
  h -&gt; m6 [style=invis]
  e -&gt; m4 [style=invis]
  e -&gt; l [weight=100]
  e -&gt; o
  l -&gt; m10 [style=invis]
  l -&gt; ll [weight=100]
  l -&gt; m11 [style=invis]
  o -&gt; m12 [style=invis]
  o -&gt; g [weight=100]
  o -&gt; m13 [style=invis]
  g -&gt; m14 [style=invis]
  g -&gt; a [weight=100]
  g -&gt; m15 [style=invis]
  }
  </code></pre>