package org.psjava.ds.graph;

public class TestGraphFactory {

	public static MutableDirectedWeightedGraph<Integer, Integer> create(int[][] edata) {
		MutableDirectedWeightedGraph<Integer, Integer> g = new MutableDirectedWeightedGraph<Integer, Integer>();
		for (int[] e : edata) {
			g.insertVertex(e[0]);
			g.insertVertex(e[1]);
			g.addEdge(e[0], e[1], e[2]);
		}
		return g;
	}

	public static Graph<String, DirectedEdge<String>> createDirected(String[][] edata) {
		MutableDirectedGraph<String> g = MutableDirectedGraph.create();
		for (String[] e : edata) {
			g.insertVertex(e[0]);
			g.insertVertex(e[1]);
			g.addEdge(e[0], e[1]);
		}
		return g;
	}

	public static Graph<String, CapacityEdge<String, Integer>> createCapacityGraph(Object[][] edata) {
		MutableCapacityGraph<String, Integer> g = MutableCapacityGraph.create();
		for (Object[] e : edata) {
			g.insertVertex((String) e[0]);
			g.insertVertex((String) e[1]);
			g.addEdge((String) e[0], (String) e[1], (Integer) e[2]);
		}
		return g;
	}

}

@@ -670,32 +670,327 @@
 eturn g;%0D%0A%09%7D%0D%0A%0D%0A
+%09public static Graph%3CString, UndirectedEdge%3CString%3E%3E createUndirected(String%5B%5D%5B%5D edata) %7B%0D%0A%09%09MutableUndirectedGraph%3CString%3E g = MutableUndirectedGraph.create();%0D%0A%09%09for (String%5B%5D e : edata) %7B%0D%0A%09%09%09g.insertVertex(e%5B0%5D);%0D%0A%09%09%09g.insertVertex(e%5B1%5D);%0D%0A%09%09%09g.addEdge(e%5B0%5D, e%5B1%5D);%0D%0A%09%09%7D%0D%0A%09%09return g;%0D%0A%09%7D%0D%0A%0D%0A
 %09public static G
@@ -1335,11 +1335,797 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09public static MutableDirectedWeightedGraph%3CString, Integer%3E createDirectedWeighted(Object%5B%5D%5B%5D data) %7B%0D%0A%09%09MutableDirectedWeightedGraph%3CString, Integer%3E g = MutableDirectedWeightedGraph.create();%0D%0A%09%09for (Object%5B%5D e1 : data) %7B%0D%0A%09%09%09g.insertVertex((String) e1%5B0%5D);%0D%0A%09%09%09g.insertVertex((String) e1%5B1%5D);%0D%0A%09%09%09g.addEdge((String) e1%5B0%5D, (String) e1%5B1%5D, (int) (Integer) e1%5B2%5D);%0D%0A%09%09%7D%0D%0A%09%09return g;%0D%0A%09%7D%0D%0A%0D%0A%09public static MutableUndirectedWeightedGraph%3CString, Integer%3E createUndirectedWeighted(Object%5B%5D%5B%5D data) %7B%0D%0A%09%09MutableUndirectedWeightedGraph%3CString, Integer%3E g = MutableUndirectedWeightedGraph.create();%0D%0A%09%09for (Object%5B%5D e1 : data) %7B%0D%0A%09%09%09g.insertVertex((String) e1%5B0%5D);%0D%0A%09%09%09g.insertVertex((String) e1%5B1%5D);%0D%0A%09%09%09g.addEdge((String) e1%5B0%5D, (String) e1%5B1%5D, (Integer) e1%5B2%5D);%0D%0A%09%09%7D%0D%0A%09%09return g;%0D%0A%09%7D%0D%0A%0D%0A
 %7D%0D%0A

add test util