GraphFactory { public static <L> DirectedGraph<Vertex<L>, Edge<L>> copyDirectedGraph(DirectedGraph<Vertex<L>, Edge<L>> graph) { DirectedGraph<Vertex<L>, Edge<L>> newGraph = new DirectedSparseMultigraph<Vertex<L>, Edge<L>>(); Map<Vertex<L>, Vertex<L>> nodes = new HashMap<Vertex<L>, Vertex<L>>(); for (Vertex<L> vertex : graph.getVertices()) { nodes.put(vertex, new Vertex<L>(vertex)); newGraph.addVertex(nodes.get(vertex)); } for (Edge<L> edge : graph.getEdges()) { newGraph.addEdge(new Edge<L>(edge), nodes.get(graph.getSource(edge)), nodes.get(graph.getDest(edge)), EdgeType.DIRECTED); } return newGraph; }  static DirectedGraph<Vertex<String>, Edge<String>> createDirectedGraph(List<Statement> sesameGraph); static DirectedGraph<Vertex<String>, Edge<String>> createDirectedGraph(
			List<Statement> sesameGraph, 
			List<String> vWhiteList,
			List<String> eWhiteList); static DirectedGraph<Vertex<L>, Edge<L>> copyDirectedGraph(DirectedGraph<Vertex<L>, Edge<L>> graph); static DirectedMultigraphWithRoot<Vertex<L>, Edge<L>> copyDirectedGraph2GraphWithRoot(DirectedGraph<Vertex<L>, Edge<L>> graph); static DirectedMultigraphWithRoot<Vertex<L>, Edge<L>> copyDirectedGraph2GraphWithRoot(DirectedGraph<Vertex<L>, Edge<L>> graph, L rootLabel);  }
@Test public void test2() { List<DirectedGraph<Vertex<String>, Edge<String>>> graphs = new ArrayList<DirectedGraph<Vertex<String>, Edge<String>>>(); DirectedGraph<Vertex<String>, Edge<String>> graphA, graphB, graphC; graphA = new DirectedSparseMultigraph<Vertex<String>, Edge<String>>(); graphB = new DirectedSparseMultigraph<Vertex<String>, Edge<String>>(); graphC = new DirectedSparseMultigraph<Vertex<String>, Edge<String>>(); Vertex<String> v1, v2, v3, v4; v1 = new Vertex<String>("a"); v2 = new Vertex<String>("b"); v3 = new Vertex<String>("c"); v4 = new Vertex<String>("d"); Edge<String> e1, e2, e3, e4; e1 = new Edge<String>("A"); e2 = new Edge<String>("B"); e3 = new Edge<String>("C"); e4 = new Edge<String>("D"); graphA.addVertex(v1); graphA.addVertex(v2); graphA.addVertex(v3); graphA.addEdge(e1, v1, v2, EdgeType.DIRECTED); graphA.addEdge(e2, v2, v3, EdgeType.DIRECTED); graphA.addEdge(e3, v3, v1, EdgeType.DIRECTED); v1 = new Vertex<String>("a"); v2 = new Vertex<String>("b"); v3 = new Vertex<String>("c"); v4 = new Vertex<String>("a"); e1 = new Edge<String>("A"); e2 = new Edge<String>("B"); e3 = new Edge<String>("C"); e4 = new Edge<String>("A"); graphB.addVertex(v1); graphB.addVertex(v2); graphB.addVertex(v3); graphB.addVertex(v4); graphB.addEdge(e1, v1, v2, EdgeType.DIRECTED); graphB.addEdge(e2, v2, v3, EdgeType.DIRECTED); graphB.addEdge(e3, v3, v1, EdgeType.DIRECTED); graphB.addEdge(e4, v1, v4, EdgeType.DIRECTED); v1 = new Vertex<String>("b"); v2 = new Vertex<String>("b"); v3 = new Vertex<String>("c"); v4 = new Vertex<String>("b"); e1 = new Edge<String>("E"); e2 = new Edge<String>("E"); e3 = new Edge<String>("C"); e4 = new Edge<String>("A"); graphC.addVertex(v1); graphC.addVertex(v2); graphC.addVertex(v3); graphC.addVertex(v4); graphC.addEdge(e1, v1, v2, EdgeType.DIRECTED); graphC.addEdge(e2, v2, v3, EdgeType.DIRECTED); graphC.addEdge(e3, v3, v1, EdgeType.DIRECTED); graphC.addEdge(e4, v1, v4, EdgeType.DIRECTED); graphs.add(graphA); graphs.add(graphB); graphs.add(graphC); System.out.println(graphA); System.out.println(GraphFactory.copyDirectedGraph(graphA)); System.out.println(graphB); System.out.println(GraphFactory.copyDirectedGraph(graphB)); System.out.println(graphC); System.out.println(GraphFactory.copyDirectedGraph(graphC)); }