'Prohibit edge node intersections
my question is how to prevent my edge crossing its node, when rendering a DoT file using Graphviz. I have seen various questions on StackOverflow regarding my question, which eventually boiled down to setting overlap=false or setting the anchor (see :n, :s in minimal example below) in combination with rank and splines properly. However, I still get an edge crossing my node. Setting the anchors even makes it worse. I don't get what I am doing wrong. I have read and tried several things from the docs like scalexy, overlap_scaling, etc. and none of them worked or even had an effect. Could someone explain me what I am doing wrong. Is there probably a setting I made, which is not compatible with the overlap=false setting?
You find a minimal example below:
digraph minimal_example {
overlap=false;
overlap_scaling=5;
rankdir=RL;
splines=line;
"a"
"g" [shape=diamond, color=red]
"a" -> "f"; {rank=same; "f"; "a"}
"g":n -> "b":s; {rank=same; "b"; "g"}
"f" -> { "d" "b" }
"b" -> { "c" }
"c" -> { "d" }
"d" -> { "e" }
"e" -> { }
}
Rendering via: `dot -Tsvg -Nshape=rect -o output.svg
Desired outcome: Move node g below node b. The idea was to achieve this main goal by prohibiting these ugly intersection between nodes and edges.
Version: dot - graphviz version 2.43.0 (0)
System: Ubuntu 20.04.4 LTS
Solution 1:[1]
rankdir=RL;makes an interesting graph- overlap (and overlap_scaling) do not apply to dot, only to the other engines (https://graphviz.org/docs/attrs/overlap/)
"e" -> { }does nothing"d" -> { "e" }(and similar) can be rewritten asd -> e(braces do nothing here)- as you noted, ports do not solve this problem
- FYI, your Ubuntu version is pretty old. But that is not causing your problems.
- relationships (
->) in the same rank are normally shown downward, thusg->bis shown downward (and not where you want it) - you might also try the other engines (neato, fdp, circo, twopi - all mad interesting output)
OK, two solutions:
digraph minimal_example {
rankdir=RL;
//splines=line; // defaults to splines=true
node [shape=rect]
// "a" // oddly, removing this declaration mad a difference
"g" [shape=diamond, color=red]
"a" -> "f"; {rank=same; "f"; "a"}
"g" -> "b"; {rank=same; "b"; "g"}
"f" -> { "d" "b" }
"b" -> { "c" }
"c" -> { "d" }
"d" -> { "e" }
}
digraph minimal_example {
rankdir=RL;
splines=line;
node [shape=rect]
"g" [shape=diamond, color=red]
"a" -> "f"; {rank=same; "f"; "a"}
"g" -> "b" {rank=same; "b"; "g"}
"f" -> { "d" "b" }
"b" -> { "c" }
"c" -> { "d" }
"d" -> { "e" }
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sroush |



