I have a digraph which I've set to "rankdir=LR;" so that "rank=same" will be top-to-bottom.
I decided to add a few clusters to this graph, but as a result "rank=same" has now become bottom-to-top.
A minimal example shows the problem:
digraph graph {
graph [
rankdir=LR;
nodesep = "0.5 equally",
newrank = true;
];
/* Guide Nodes */
rank1 [style=dotted];
rank2 [style=dotted];
rank1 -> rank2 [style=dotted];
/* Node Clusters */
subgraph cluster1 {
A;
B;
C;
}
/* Node Hierarchy */
A -> Z;
B -> Z;
C -> Z;
/* Node Rank */
{ rank=same;
rank1 -> A -> B -> C [style=dotted];
}
} /* Closes the digraph */
The result that I want is to have from top to bottom: rank1, A, B, C.
The result that I get is from top to bottom: C, B, A, rank1 --- as seen in the picture below.
How can I get the correct order back?
- Option 1: Just don't use clusters.
- Option 2: Rewrite the "rank=same" line to fit the bottom-to-top direction.
Given the size of my graph, option 2 is simply too much work for too little gain. Is there another option?
EDIT: The answer that marapet gave, does most of what I wanted. However, that solution doesn't work with the following minimal problem:
digraph g {
graph [
rankdir=LR;
nodesep = "0.5 equally",
newrank = true;
];
/* Node Clusters */
subgraph cluster1 {
subgraph cluster2 {
A;
B;
C;
}
P;
subgraph cluster4 {
D;
E;
F;
}
Z;
}
/* Guide Nodes */
rank1 [style=dotted];
rank2 [style=dotted];
/* Guide Nodes Hierarchy */
rank1 -> rank2 [style=dotted];
/* Node Hierarchy */
A -> Z;
B -> Z;
C -> Z;
P -> Z;
D -> Z;
E -> Z;
F -> Z;
/* Rank Constraints */
rank1 -> A -> B -> C -> P -> D -> E -> F [style=dotted, constraint=false];
} /* Closes the digraph */
This results in the following picture:
I can only conclude that the issue I'm having is the result of mixing clusters and non-clusters in the same-rank-edges.

