English 中文(简体)
图图Viz - 创建多行集群集
原标题:GraphViz - Create Cluster of Clusters in multiple lines

我非常希望你们能帮助我绘制一个我想要的图表。我希望从最初的一组到许多其他组都有标签,而其他组又应该按多行排列。

直到这一刻,我写了以下代码:

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];

}

我能用点来达到这个目的吗?

非常感谢你们提前帮忙!

问题回答

您可以尝试添加一些 < 坚固 > 不可见边缘 < /坚固 > :

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

如有必要,从那里进一步加以改进。

这样可以确保分组处于不同级别。





相关问题
Java: JGraphT: Iterate through nodes

I m trying to iterate through all nodes, so I can print them out for graphviz. What is the best way to do that using the JGraphT library? public static void main(String[] args) { UndirectedGraph&...

Java: Adding nodes to graph bug

Preface: I know that there are high quality graph APIs available. I m interested in writing my own for self-improvement. This is my function to add nodes: public void addNode(Vertex v, ...

Radial plotting algorithm

I have to write an algorithm in AS3.0 that plots the location of points radially. I d like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry ...

Microsoft .Net Chart Control not showing markers

I m using the Microsoft Chart Controls for Microsoft .NET Framework 3.5 and am having a spot of trouble getting Data Markers to show on the image. I m generating the chart at run-time, so can t just ...

3D graphs using pChart

Is there a way to draw a 3D Bar Graph using the pChart library in PHP? I m able to draw a 3D Pie graph but not a line graph. My code looks as follows //The 3D bar graph # // Dataset ...

Finding cycle of 3 nodes ( or triangles) in a graph

I am working with complex networks. I want to find group of nodes which forms a cycle of 3 nodes (or triangles) in a given graph. As my graph contains about million edges, using a simple iterative ...

How to create line chart in iPhone application? [closed]

I am creating a budget application in iPhone, to budget for personal incomes and expenses. Client s need is I want to see line graph (like stock market line report). Red line for (monthly / weekly /...

热门标签