Strange chart edges overlapping

I get a weird graphviz layout with overlapping edges.

Node "5" is placed in the wrong place:

Default messy version

If I force the correct position with the edge between node "5" and node "h", everything will be well placed:

Fixed version

Why is the default layout so dirty?

Here is my point source (just uncomment the line to get a fixed version):

digraph dummy {

    subgraph line1 { rank = same
        "1", "a", "b", "c", "d", "e", "f", "17"
    }

    subgraph line2 { rank = same
        "9", "g", "11"
    }

    subgraph line3 { rank = same
        "3", "h", "i", "14"
    }

    "c" -> "d"
    "a" -> "b"
    "b" -> "c"
    "e" -> "f"
    "i" -> "14"
    "14" -> "f"
    "a" -> "3"
    "3" -> "h"
    "d" -> "9"
    "9" -> "g"
    "h" -> "i"
    "g" -> "i"
    "d" -> "e"
    "g" -> "11"
    "11" -> "e"
    "b" -> "5"
    #"5" -> "h" # Uncomment to "fix"
    "c" -> "7"
    "f" -> "17"
    "1" -> "a"
    "h" -> "13"
    "i" -> "15"
    "i" -> "15bis"
    "i" -> "16"
}

With @Sisyphus I can get a better result (but the nodes "11" ang "g" switch for no reason):

enter image description here

+4
source share
1 answer

change

subgraph line2 { rank = same
    "9", "g", "11"
}

to

{ rank = same
    rankdir=LR
    5->7->9->g->11[color=white]
}

This place is node "5" on the right, but "9" and "g" are wrong.

+1
source

Source: https://habr.com/ru/post/1548400/


All Articles