0

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;
}

enter image description here

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;
}

enter image description here

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.

einpoklum
  • 118,144
  • 57
  • 340
  • 684

1 Answers1

0

2 possible solutions:

  1. 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:
    enter image description here

  2. use dir=back to reverse the "offending" edge
    u3 -> u2 [dir=back] Giving:
    enter image description here

sroush
  • 5,375
  • 2
  • 5
  • 11