边缘相互交叉

Edge crossing each other

有没有办法消除边的交叉?

我试了很多方法,都没用。

digraph graphname {
    graph [splines=ortho,];
    node [shape=box,];

    l;

    l_a [shape=diamond,label="",height=0.20,width=0.20];
    l_a_s [shape=point];
    l_a_i [shape=point];
    l_a_ii [shape=point];
    l_a -> l_a_s;
    {rank=same; a -> l_a -> l}
    {rank=same; l_a_i -> l_a_s -> l_a_ii}
    l_a_i -> i;
    l_a_ii -> ii;

    l_c [shape=diamond,label="",height=0.20,width=0.20];
    l_c_s [shape=point];
    l_c_t [shape=point];
    l_c_n [shape=point];
    l_c -> l_c_s;
    {rank=same; l -> l_c -> c} 
    {rank=same; l_c_t -> l_c_s -> l_c_n}
    l_c_t -> t;
    l_c_n -> n;
}

更多细节:

添加这条不可见的边可以解决您的问题:

    l_a_i -> l_c_s [constraint=false style=invis]

我无法从数学上证明为什么这有效,但在这种情况下,通常有助于玩弄定义 nodes/edges 的顺序,或者尝试添加不可见的广告以将布局推向您需要的方向

您需要做的就是稍微重新组织您的 node/edge 定义,不需要额外的边。

例如:

digraph graphname {
    graph [splines=ortho,];
    node [shape=box,];

    a;
    l_a [shape=diamond,label="",height=0.20,width=0.20];
    l;
    l_c [shape=diamond,label="",height=0.20,width=0.20];
    c;
    {rank=same; a -> l_a -> l -> l_c -> c}

    l_a_s [shape=point];
    l_c_s [shape=point];
    l_a -> l_a_s;
    l_c -> l_c_s;

    l_a_i [shape=point];
    l_a_ii [shape=point];
    l_c_t [shape=point];
    l_c_n [shape=point];

    {rank=same;
    l_a_i -> l_a_s -> l_a_ii;
    l_c_t -> l_c_s -> l_c_n;}

    l_a_i -> i;
    l_a_ii -> ii;

    l_c_t -> t;
    l_c_n -> n;
}