Java Jung subgraph components
-
09-07-2021 - |
Вопрос
I have an unconnected graph with several components. How can I get a Graph instance of each subgraph component? For example consider the following Graph:
What I want is to be able to return these subgraph components. An example subgraph component would be the graph with vertices: {c0, c1, c2, c3}
I would like to come something like this (These classes don't exist):
GraphComponents<String, Integer> comps = new GraphComponents<String, Integer>(graph);
for(int i = 0; i < comps.size(); i++)
{
comps[i].computeSomethingInteresting();
}
- How can I return an instance of a subgraph component?
- Which Graph type should I use (I am currently using a Forest)
Решение
You could use the getTrees()
command which returns the collection of trees in your Forest
More info.
Другие советы
WeakComponentClusterer will do it: http://jung.sourceforge.net/doc/api/edu/uci/ics/jung/algorithms/cluster/WeakComponentClusterer.html
Не связан с StackOverflow