Graphviz / DOT:如何让箭头"重定向"

时间:2017-05-03 10:37:04

标签: graphviz dot

这是我想在DOT图中生成的内容:

graph

我有以下代码:

\digraph
[scale=0.7]{g1}
{
   margin="0 0 0 0";
   rankdir="TB";
"X" [shape=invhouse];
" " [shape=house];
"100" [shape=cylinder];
"X" -> "100"
"X" -> "+";
"100" -> "+"
"+" -> " ";
}

我也有以下代码,它在某种意义上更接近,但在视觉上看起来并不像我想要的那样:

digraph {
        node[ shape = plaintext ];
        a [label="X", shape = invhouse]
        b [label="+", shape = ellipse]
        ab1 [label="dummy", style=invis, shape=point]
        ab2 [label="dummy", style=invis, shape=point]
        c [label="100", shape = cylinder]
        d [label=" ", shape=house]
        subgraph cluster_0 {
        style=invis
                a -> ab1 [arrowhead=none];
                ab1 -> c;
                c -> ab2;
                ab1 -> ab2 [arrowhead=none];
                ab2 -> b;
                b -> d;
        }
}

如何正确更改我的代码?任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

group属性有助于将节点排成一行

digraph {
    node[ shape = plaintext group=abd];
    a [label="X", shape = invhouse]
    b [label="+", shape = ellipse]
    ab1 [label="dummy", style=invis, shape=point]
    ab2 [label="dummy", style=invis, shape=point]
    c [label="100", shape = cylinder, group=c]
    d [label=" ", shape=house]
    subgraph cluster_0 {
    style=invis
            a -> ab1 [arrowhead=none];
            ab1 -> c;
            c -> ab2;
            ab1 -> ab2 [arrowhead=none];
            ab2 -> b;
            b -> d;
    }
}

straightened out