点子图边缘位置和方向

Dot subgraph edge position and direction

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

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

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]

}

您必须确保您的 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 ]

}

产量