简体   繁体   English

graphviz中的重叠边

[英]Overlapping edges in graphviz

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?有没有办法分别显示两个边n1 -> n2n2 -> n1 Removing the clusters is not an option but would help ...删除集群不是一种选择,但会有所帮助......

A solution making use of the portPos modifier:使用portPos修饰符的解决方案:

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:另一种解决方案是使用 dir 和color修饰符:

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.如果您想保持黑白配色方案,您甚至可以使用color="black:black"

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;
}

图形输出

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM