0

我非常感谢您对我想要的图表的帮助。我希望从一个起始集群有许多其他集群的标签,而这些集群又应该组织成多行。

到目前为止,我已经编写了以下代码:

digraph g{
rankdir="TB";
compound=true;

subgraph cluster0{
label="Cluster 0";
a0->b0;
b0->c0;
a0->c0;
}

subgraph cluster1{
label="Cluster 1";
a1->b1;
b1->c1;
a1->c1;
}

subgraph cluster2{
label="Cluster 2";
a2->b2;
b2->c2;
a2->c2;
}


subgraph cluster3{
label="Cluster 3";
a3->b3;
b3->c3;
a3->c3;
}

subgraph cluster4{
label="Cluster 4";
a4->b4;
b4->c4;
a4->c4;
}

a0->a1 [ltail=cluster0,lhead=cluster1];
a0->a2 [ltail=cluster0,lhead=cluster2];
a0->a3 [ltail=cluster0,lhead=cluster3];
a0->a4 [ltail=cluster0,lhead=cluster4];

}

尽管此代码生成了我的集群并适当地互连它们,但不幸的是所有集群(即集群 1、2、3 和 4)都在同一行,而我希望集群 1 和 2 在一行中,集群 3 和 4在另一行,正好在包含集群 1 和 2 的行的下方。

尽管集群组织在一起,但通过使用不可见的链接,它们没有正确对齐(在列中),而且内部节点序列似乎很纠结(例如,参见下面稍微复杂的情况,我希望标记为 4 的节点始终在顶部,其余节点 1,2 和 3 应按从左到右的相应顺序放置)

digraph g {
compound=true;
fontname=Helvetica
page="8.5,11";
size="135";
overlap=false;

subgraph cluster0 {
"start-0" [ label = "4" ];
"n1-0" [ label = "1" ];
"start-0" -> "n1-0" ;
"n2-0" [ label = "2" ];
"start-0" -> "n2-0" ;
"n3-0" [ label = "3" ];
"start-0" -> "n3-0" ;
subgraph 00 { rank = same;  "n1-0" "n2-0" "n3-0" }
}
subgraph cluster1 {
"start-1" [ label = "4" ];
"n1-1" [ label = "1" ];
"start-1" -> "n1-1" ;
"n2-1" [ label = "2" ];
"start-1" -> "n2-1" ;
"n3-1" [ label = "3" ];
"start-1" -> "n3-1" ;
subgraph 01 { rank = same;  "n1-1" "n2-1" "n3-1" }
}
"start-0" -> "start-1" [ltail=cluster0,lhead=cluster1];
subgraph cluster2 {
"start-2" [ label = "4" ];
"n1-2" [ label = "1" ];
"start-2" -> "n1-2" ;
"n2-2" [ label = "2" ];
"start-2" -> "n2-2" ;
"n3-2" [ label = "3" ];
"start-2" -> "n3-2" ;
subgraph 02 { rank = same;  "n1-2" "n2-2" "n3-2" }
}
"start-0" -> "start-2" [ltail=cluster0,lhead=cluster2];
subgraph cluster3 {
"start-3" [ label = "4" ];
"n1-3" [ label = "1" ];
"start-3" -> "n1-3" ;
"n2-3" [ label = "2" ];
"start-3" -> "n2-3" ;
"n3-3" [ label = "3" ];
"start-3" -> "n3-3" ;
subgraph 03 { rank = same;  "n1-3" "n2-3" "n3-3" }
}
"start-0" -> "start-3" [ltail=cluster0,lhead=cluster3];
subgraph cluster4 {
"start-4" [ label = "4" ];
"n1-4" [ label = "1" ];
"start-4" -> "n1-4" ;
"n2-4" [ label = "2" ];
"start-4" -> "n2-4" ;
"n3-4" [ label = "3" ];
"start-4" -> "n3-4" ;
subgraph 04 { rank = same;  "n1-4" "n2-4" "n3-4" }
}
"start-0" -> "start-4" [ltail=cluster0,lhead=cluster4];
subgraph cluster5 {
"start-5" [ label = "4" ];
"n1-5" [ label = "1" ];
"start-5" -> "n1-5" ;
"n2-5" [ label = "2" ];
"start-5" -> "n2-5" ;
"n3-5" [ label = "3" ];
"start-5" -> "n3-5" ;
subgraph 05 { rank = same;  "n1-5" "n2-5" "n3-5" }
}
"start-0" -> "start-5" [ltail=cluster0,lhead=cluster5];

subgraph cluster6 {
"start-6" [ label = "4" ];
"n1-6" [ label = "1" ];
"start-6" -> "n1-6" ;
"n2-6" [ label = "2" ];
"start-6" -> "n2-6" ;
"n3-6" [ label = "3" ];
"start-6" -> "n3-6" ;
subgraph 06 { rank = same;  "n1-6" "n2-6" "n3-6" }
}
"start-0" -> "start-6" [ltail=cluster0,lhead=cluster6];
subgraph cluster7 {
"start-7" [ label = "4" ];
"n1-7" [ label = "1" ];
"start-7" -> "n1-7" ;
"n2-7" [ label = "2" ];
"start-7" -> "n2-7" ;
"n3-7" [ label = "3" ];
"start-7" -> "n3-7" ;
subgraph 07 { rank = same;  "n1-7" "n2-7" "n3-7" }
}
"start-0" -> "start-7" [ltail=cluster0,lhead=cluster7];
subgraph cluster8 {
"start-8" [ label = "4" ];
"n1-8" [ label = "1" ];
"start-8" -> "n1-8" ;
"n2-8" [ label = "2" ];
"start-8" -> "n2-8" ;
"n3-8" [ label = "3" ];
"start-8" -> "n3-8" ;
subgraph 08 { rank = same;  "n1-8" "n2-8" "n3-8" }
}
"start-0" -> "start-8" [ltail=cluster0,lhead=cluster8];
subgraph cluster9 {
"start-9" [ label = "4" ];
"n1-9" [ label = "1" ];
"start-9" -> "n1-9" ;
"n2-9" [ label = "2" ];
"start-9" -> "n2-9" ;
"n3-9" [ label = "3" ];
"start-9" -> "n3-9" ;
subgraph 09 { rank = same;  "n1-9" "n2-9" "n3-9" }
}
"start-0" -> "start-9" [ltail=cluster0,lhead=cluster9];
subgraph cluster10 {
"start-10" [ label = "4" ];
"n1-10" [ label = "1" ];
"start-10" -> "n1-10" ;
"n2-10" [ label = "2" ];
"start-10" -> "n2-10" ;
"n3-10" [ label = "3" ];
"start-10" -> "n3-10" ;
subgraph 010 { rank = same;  "n1-10" "n2-10" "n3-10" }
}
"start-0" -> "start-10" [ltail=cluster0,lhead=cluster10];

"n1-0" -> "start-1" [style=invis];
"n1-0" -> "start-2" [style=invis];
"n1-0" -> "start-3" [style=invis];
"n1-0" -> "start-4" [style=invis];
"n1-0" -> "start-5" [style=invis];

"n3-1" -> "start-6" [style=invis];
"n3-2" -> "start-7" [style=invis];
"n3-3" -> "start-8" [style=invis];
"n3-4" -> "start-9" [style=invis];
"n3-5" -> "start-10" [style=invis];

}

有什么方法可以使用点来实现吗?

非常感谢您提前提供的帮助!

4

1 回答 1

0

您可以尝试添加一些不可见的边缘

c0->a1 [style=invis];
c0->a2 [style=invis];
c1->a3 [style=invis];
c2->a4 [style=invis];

并在需要时从那里进一步改进。

这可以确保集群位于不同的等级上。

于 2012-05-23T19:49:32.060 回答