问题
I've two overlapping edges and don't know why:
digraph G {
graph [rankdir=LR, overlap=false];
subgraph cluster1 {
d1;
n1;
}
subgraph cluster2 {
n2;
d2;
}
n1 -> n2;
n2 -> n1;
d0 -> d1;
d0 -> d2;
}
Is there any way to display both edges n1 -> n2
and n2 -> n1
separately? Removing the clusters is not an option but would help ...
回答1:
Trial-and-error solution (don't ask me why this works...):
digraph G {
graph [rankdir=LR, overlap=false];
subgraph cluster1 {
d1;
n1;
}
subgraph cluster2 {
n2;
d2;
}
n1 -> n2;
n1 -> n2[constraint=false, dir=back];
n2 -> n1[style=invis];
d0 -> d1;
d0 -> d2;
}
回答2:
A solution making use of the portPos modifier:
digraph G {
graph [rankdir=LR, overlap=false];
subgraph cluster1 {
d1;
n1;
}
subgraph cluster2 {
n2;
d2;
}
n1:sw -> n2:nw;
n2:ne -> n1:se;
d0 -> d1;
d0 -> d2;
}
Another solution is to make use of the dir and color modifiers:
digraph G {
graph [rankdir=LR, overlap=false];
subgraph cluster1 {
d1;
n1;
}
subgraph cluster2 {
n2;
d2;
}
n2 -> n1[dir=both color="red:blue"];
d0 -> d1;
d0 -> d2;
}
You can even use color="black:black"
if you want to maintain the black and white coloring scheme.
来源:https://stackoverflow.com/questions/9845570/overlapping-edges-in-graphviz