title: Vertically aligning a node joining subgraphs in Graphviz
body: <p>I give the following input to Dot:</p>
  
  <pre><code>digraph G {
    subgraph cluster1 {
      fontsize = 20;
      label = "Group 1";
      A -&gt; B -&gt; C -&gt; D;
      style = "dashed";
    }
  
    subgraph {
      O [shape=box];
    }
  
    subgraph cluster2 {
      fontsize = 20;
      label = "Group 2";
      Z -&gt; Y -&gt; X -&gt; W [dir=back];
      style = "dashed";
    }
  
    D -&gt; O [constraint=false];
    W -&gt; O [constraint=false, dir=back];
  }
  </code></pre>
  
  <p>And it produces:</p>
  
  <p><img src="https://i.stack.imgur.com/R4Vaj.png" alt="picture with node O aligned with A and Z"></p>
  
  <p>How can I align node <code>O</code> so that it has the same rank as <code>D</code> and <code>W</code>? That is, a graph that looks like:</p>
  
  <pre><code>A   Z
  |   |
  B   Y
  |   |
  C   X
  |   |
  D-O-W
  </code></pre>
  
  <p>Adding</p>
  
  <pre><code> { rank=same; D; O; W; }
  </code></pre>
  
  <p>yields the error</p>
  
  <pre><code>Warning: D was already in a rankset, ignored in cluster G
  Warning: W was already in a rankset, ignored in cluster G
  </code></pre>
  
  <p>I'm thinking I can hack it by adding invisible nodes and edges to the subgraph of <code>O</code>, but I was wondering if I was missing some Dot magic.</p>