点子图的边缘位置和方向

时间:2016-11-16 20:14:49

标签: graphviz dot

我希望边缘从一个子图指向另一个子图,而不是从一个节点指向子图。

此外,我可以控制边缘的长度吗?

digraph G {
compound=true;

node[shape=box];

subgraph cluster0 {
  color=blue;
  label="Top";
  a;
}

subgraph cluster1 {
  color=magenta;
  label="Middle";
  b;
}

subgraph cluster2 {
  color=green;
  label="Bottom";
  c;
}

a -> b[dir=back,ltail=cluster2,lhead=cluster1]
b -> c[dir=back,ltail=cluster1,lhead=cluster0]

}

enter image description here

1 个答案:

答案 0 :(得分:1)

您必须确保ltaillhead的位置正确无误:

digraph G 
{
    compound=true;
    node[ shape=box ];
    edge[ minlen = 2 ];

    subgraph cluster0 
    {
        color = blue;
        label = "Top";
        a;
    }

    subgraph cluster1 
    {
        color = magenta;
        label = "Middle";
        b;
    }

    subgraph cluster2 
    {
        color = green;
        label = "Bottom";
        c;
    }

    // here:
    a -> b[ dir = back, lhead = cluster1, ltail = cluster0 ]
    b -> c[ dir = back, lhead = cluster2, ltail = cluster1 ]

}

产量

enter image description here