Combine Charts in JGraphT

I use JGraphT, and I have two DirectedGraph : g1 and g2 .

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

+4
source share
1 answer

I finally found it!

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

 Graphs.addGraph(g1, g2); 

Adds all vertices and all edges of the specified source graph to the specified destination graph. First, all the vertices of the source schedule are added to the destination schedule. Then each edge of the source graph is added to the destination graph. This method returns true if the destination graph was changed as a result of this, otherwise it returns false.

We can read here .

+6
source

Source: https://habr.com/ru/post/1444106/


All Articles