Вопрос

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:enter image description here

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();
}
  1. How can I return an instance of a subgraph component?
  2. 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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top