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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With