I have the following graph:
digraph G {
u1, u2, u3, u5 [ shape = oval, style=filled, fillcolor="palegreen"];
u3 -> v3 -> v5_0 -> v5_1 -> v1;
u5 -> v8 -> v5_1;
v1 -> v5_2 -> v2;
u1 -> v2;
v2 -> u2;
}
Now, I want u2 and u3 to be the same node, in the sense that I want the last vertex on the bottom to have an edge go up to u3 at the top of the rendered graph. But if I render:
digraph G {
u1, u2, u3, u5 [ shape = oval, style=filled, fillcolor="palegreen"];
u3 -> v3 -> v5_0 -> v5_1 -> v1;
u5 -> v8 -> v5_1;
v1 -> v5_2 -> v2;
u1 -> v2;
v2 -> u3;
}
The u3 node ends up in the middle of the graph. How do I force u3 to be at the top? I tried using rank=min on it, but that didn't help.


2 possible solutions:
use constraint=false on the "offending" edge (https://graphviz.org/docs/attrs/constraint/)
u2 -> u3 [constraint=false]

this produces a correct, but very ugly, edge:
use dir=back to reverse the "offending" edge

u3 -> u2 [dir=back]Giving: