假设,我想在图形中的几个节点之间创建一个子集群(以某种方式表示这些节点因某种原因而聚集在一起):
digraph G {
A [group=g1]
{rank = same; B[group=g2]; C[group=g3]}
D [group=g1]
{rank = same; E[group=g2]; F[group=g3]}
A -> B [label="2", weight=2]
A -> C [label="0", style=dashed, weight=2]
B -> C [label="0", style=dashed, weight=2]
B -> D [label="2", style=dashed, weight=2]
C -> D [label="0", weight=2]
D -> E [label="1", style=dashed, weight=2]
D -> F [label="0", weight=2]
E -> F [label="0", weight=2]
F -> A
edge[style=invis];
A -> D
B -> E
C -> F
subgraph cluster_0 {
label = "I want this in its own sub-square"
B->E
B->Asti
style=filled;
color=lightgrey;
node [style=filled,color=white];
edge[style=invis];
}
}
如你所见,我只是部分成功。也就是说,asti
位于其自己的灰色群集中,但节点B
和E
不是。
有人可以指出如何将所有三个节点E
,B
和asti
放入该灰色群集中?
由于
答案 0 :(得分:1)
使用newrank=true
来避免"取消装箱"簇
digraph G {
newrank=true;
A [group=g1]
{rank = same; B[group=g2]; C[group=g3]}
D [group=g1]
{rank = same; E[group=g2]; F[group=g3]}
A -> B [label="2", weight=2]
A -> C [label="0", style=dashed, weight=2]
B -> C [label="0", style=dashed, weight=2]
B -> D [label="2", style=dashed, weight=2]
C -> D [label="0", weight=2]
D -> E [label="1", style=dashed, weight=2]
D -> F [label="0", weight=2]
E -> F [label="0", weight=2]
F -> A
edge[style=invis];
A -> D
B -> E
C -> F
subgraph cluster_0 {
label = "I want this in its own sub-square"
B->E
B->Asti
style=filled;
color=lightgrey;
node [style=filled,color=white];
edge[style=invis];
}
}