4
votes

I get a strange graphviz layout with edges overlapping.

Node "5" seems to be placed at the wrong place :

Default messy version

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

Fixed version

Why the default layout is so messy ?

Here is my dot source (just uncomment the line to get the 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 the help of @Sisyphus I can get a better result (but nodes "11" ang "g" are switched without reason) :

enter image description here

1
Please note the dot content is generated. So including the fix as an invisible edge "5" -> "h" [style = invis] is not possible - PhE
...well, then instruct the generator to include the invisible attribute... - Robert Siemer
@robert-siemer : I can't since I don't know anything about the content layout - PhE

1 Answers

1
votes

change

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

to

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

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