Search code examples
graphvizdot

Graphviz (dot) control edge routing


In this graph the bottom edge is not drawn symmetrical to the top edge:

digraph G {
    A:ne -> A:nw;
    A:sw -> A:se;
}

enter image description here

I want it to look more like a "fat snowman" with the edge A:sw -> A:se; looping below the node. Is there a way?


Solution

  • Short answer no - or not easily.
    Loops seem to be placed from the rankdir direction. If rankdir is TB (down), loops seem to be placed "up".
    It you're willing to work at it, you can run your graph twice, once with rankdir=TB, once with rankdir=BT - both times with -Tdot. Then you'd have to replace the offending edge with the equivalent edge from the other graph. [I hope this makes some sense]
    Here is a tweaked version of your graph run with different values of rankdir:

    digraph G {
        A:ne -> A:nw;
        A:sw -> A:se;
        dummy [style=invis]
        dummy -> A [style=invis]
    }
    

    enter image description here enter image description here