@@ -0,0 +1,1018 @@
+package org.psjava.ds.graph;%0D%0A%0D%0Aimport org.psjava.ds.Collection;%0D%0Aimport org.psjava.ds.set.InsertAllToSet;%0D%0Aimport org.psjava.ds.set.MutableSet;%0D%0Aimport org.psjava.goods.GoodMutableSetFactory;%0D%0Aimport org.psjava.javautil.MergedIterable;%0D%0Aimport org.psjava.javautil.VarargsIterable;%0D%0A%0D%0Apublic class MergedGraph %7B%0D%0A%0D%0A%09public static %3CW%3E DirectedWeightedGraph%3CW%3E create(final DirectedWeightedGraph%3CW%3E g1, final DirectedWeightedGraph%3CW%3E g2) %7B%0D%0A%09%09final MutableSet%3CObject%3E mergedv = GoodMutableSetFactory.getInstance().create();%0D%0A%09%09InsertAllToSet.insertAll(mergedv, g1.getVertices());%0D%0A%09%09InsertAllToSet.insertAll(mergedv, g2.getVertices());%0D%0A%09%0D%0A%09%09return new DirectedWeightedGraph%3CW%3E() %7B%0D%0A%09%09%09@Override%0D%0A%09%09%09public Collection%3CObject%3E getVertices() %7B%0D%0A%09%09%09%09return mergedv;%0D%0A%09%09%09%7D%0D%0A%09%0D%0A%09%09%09@SuppressWarnings(%22unchecked%22)%0D%0A%09%09%09@Override%0D%0A%09%09%09public Iterable%3CDirectedWeightedEdge%3CW%3E%3E getEdges() %7B%0D%0A%09%09%09%09return MergedIterable.wrap(VarargsIterable.create(g1.getEdges(), g2.getEdges()));%0D%0A%09%09%09%7D%0D%0A%09%09%7D;%0D%0A%09%7D%0D%0A%0D%0A%09private MergedGraph() %7B%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

add a util class - merged graph