Java 使用jgrapht创建带有簇的图
有没有办法使用jgrapht创建带有集群的图形? 带有两个簇“进程1”和“进程2”的示例图: 预期的点文件内容:Java 使用jgrapht创建带有簇的图,java,jgrapht,Java,Jgrapht,有没有办法使用jgrapht创建带有集群的图形? 带有两个簇“进程1”和“进程2”的示例图: 预期的点文件内容: digraph G { subgraph cluster_0 { style=filled; color=lightgrey; node [style=filled,color=white]; a0 -> a1 -> a2 -> a3; label = "process #1"; } subgraph cluster_1 { node [style=filled
digraph G {
subgraph cluster_0 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
a0 -> a1 -> a2 -> a3;
label = "process #1";
}
subgraph cluster_1 {
node [style=filled];
b0 -> b1 -> b2 -> b3;
label = "process #2";
color=blue
}
start -> a0;
start -> b0;
a1 -> b3;
b2 -> a3;
a3 -> a0;
a3 -> end;
b3 -> end;
start [shape=Mdiamond];
end [shape=Msquare];
}
你的图形设计有点奇怪。当我直观地查看您的图时,我看到一个基本图和两个群集的节点组。当我查看您的点文件时,我看到两个子图,以及一个“外部”图,它表示子图中的特定节点。请注意,子图不是簇 你的问题似乎有两个部分:(1)你能用jgrapht创建一个带有簇的图吗?(2)你能在你的例子中创建点文件吗。答案是:(1)是,(2)不是,至少不是现成的,因为
dotporter
不支持“子图”
有几种不同的方法可以创建集群图
列表
,以存储集群。您可以使用AsSubgraph
类来可视化特定集群所诱导的子图BlockCutpointGraph
实现中做了类似的事情AsSubgraph
类MaskSubgraph
类dotporter
类导出在步骤(2)和(3)中创建的图形子图形
键插入其他图形有向图
替换为子图
,并将此图插入基本图中,以获得:
digraph G {
subgraph cluster_0 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
a0 -> a1 -> a2 -> a3;
label = "process #1";
}
start -> a0;
start -> b0;
a1 -> b3;
b2 -> a3;
a3 -> a0;
a3 -> end;
b3 -> end;
start [shape=Mdiamond];
end [shape=Msquare];
}
显然,您必须对其余的集群重复此操作。能否为AsSubgraph类提供语法和示例代码。我尝试了以下代码:
DirectedGraph g=new DefaultDirectedGraph(DefaultEdge.Class);AsSubgraph subgraph=new AsSubgraph(g);
,但我遇到了如下错误:线程“main”java.lang.NoSuchMethodError中的“异常”:org.jgrapht.Graph.getType()Lorg/jgrapht/GraphType;位于org.jgrapht.GraphTests.requirectedRunDirected(GraphTests.java:645)“看看这个类。它包含各种示例。如果没有进一步的细节或完整的错误消息,很难提出任何建议。然而,这似乎与最初关于集群的问题无关。”。。
digraph cluster_0 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
a0 -> a1 -> a2 -> a3;
label = "process #1";
}
digraph G {
subgraph cluster_0 {
style=filled;
color=lightgrey;
node [style=filled,color=white];
a0 -> a1 -> a2 -> a3;
label = "process #1";
}
start -> a0;
start -> b0;
a1 -> b3;
b2 -> a3;
a3 -> a0;
a3 -> end;
b3 -> end;
start [shape=Mdiamond];
end [shape=Msquare];
}