如何防止graphviz在标签上绘制边缘?

时间:2016-08-25 12:16:43

标签: graphviz graph-drawing

如果我在这个有向图上运行graphviz:

digraph G {
    subgraph cluster_0 {
        style=filled;
        color=lightgrey;
        node [style=filled,color=white];
        a0; a1;  a2;  a3;
        label = "sources";
    }

    subgraph cluster_1 {
        style=filled;
        color=lightgrey;
        node [style=filled,color=white];
        b0; b1; b2; b3;
        label = "intermediaries";
    }
        a0 -> b0; a1 -> b0;
        a0 -> b1; a1 -> b1;
        a2 -> b2; b0 -> b2;
        b1 -> b2; a3 -> b3;
        b0 -> b3; b1 -> b3;
}

我得到了

enter image description here

有许多边与“中间人”标签相交。如何使graphviz使边缘避免标签与避免图形节点的方式类似?

1 个答案:

答案 0 :(得分:2)

作为解决方法:

digraph G {
    subgraph cluster_0 {
        style=filled;
        color=lightgrey;
        node [style=filled,color=white];
        a0; a1;  a2;  a3;
        label = "sources";
    }

    subgraph cluster_1 {
        style=filled;
        color=lightgrey;
        node [style=filled,color=white];
        nodelabel [label="intermediaries"; style=filled; color=lightgrey]
        nodelabel -> b1 [style=invis];
        nodelabel -> b0 [style=invis];
        b0; b1; b2; b3;
    }
        a0 -> b0; a1 -> b0;
        a0 -> b1; a1 -> b1;
        a2 -> b2; b0 -> b2;
        b1 -> b2; a3 -> b3;
        b0 -> b3; b1 -> b3;
}

产生

output