I would like these two nodes to appear on the same level:
digraph G {
subgraph cluster1 {
label="Local Datacenter";
router1;
host1;
}
subgraph cluster2 {
label="Remote Datacenter";
router2;
host2;
}
router1 -> router2;
router2 -> host2;
router1 -> host1;
}
I have tried using rank=same
and rank=min
, but they aren't giving me what I need.
Interestingly, if I set rankdir=LR
and comment out the two router-to-host edges, it gives me exactly the look I want - but I would like to leave the edges intact.
You may use the newrank
graph attribute (added in GraphViz 2.30) to activate the new ranking algorithm which allows defining rank=same
for nodes which belong to clusters.
Add the following line at the top:
newrank=true;
Add the following line after the cluster definitions:
{ rank=same; router1; router2; }
Here's the resulting graph: