Pergunta

I'm using JGraphT and I have two DirectedGraph : g1 and g2.

How can I merge g1 and g2 to a third graph g3? I need g3 be a normal graph and has the ability to add new edges and vertices.

Foi útil?

Solução

Finally I found it !

There is a method in Graphs class that adds the second entry graph to the first entry graph:

Graphs.addGraph(g1, g2);

Adds all the vertices and all the edges of the specified source graph to the specified destination graph. First all vertices of the source graph are added to the destination graph. Then every edge of the source graph is added to the destination graph. This method returns true if the destination graph has been modified as a result of this operation, otherwise it returns false.

We can read more here.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top