public void testDirectedAdjacencyList() { DirectedGraph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); g.addVertex(1); g.addVertex(2); g.addVertex(3); g.addVertex(4); g.addVertex(5); g.addEdge(1, 2); g.addEdge(1, 3); g.addEdge(3, 1); g.addEdge(3, 4); g.addEdge(4, 5); g.addEdge(5, 1); g.addEdge(5, 2); g.addEdge(5, 3); g.addEdge(5, 4); g.addEdge(5, 5); g.addEdge(5, 5); CSVExporter<Integer, DefaultEdge> exporter = new CSVExporter<>(nameProvider, CSVFormat.ADJACENCY_LIST, ';'); StringWriter w = new StringWriter(); exporter.exportGraph(g, w); assertEquals(DIRECTED_ADJACENCY_LIST, w.toString()); }
/* * Creates a VertexData object for every vertex in the graph and stores * them * in a HashMap. */ private void createVertexData() { vertexToVertexData = new HashMap<V, VertexData<V>>(graph.vertexSet().size()); for (V vertex : graph.vertexSet()) { vertexToVertexData.put(vertex, new VertexData2<V>(vertex, false, false)); } }
/* * The subroutine of DFS. NOTE: the set is used to distinguish between 1st * and 2nd round of DFS. set == null: finished vertices are stored (1st * round). set != null: all vertices found will be saved in the set (2nd * round) */ private void dfsVisit( DirectedGraph<V, E> visitedGraph, VertexData<V> vertexData, Set<V> vertices) { Deque<VertexData<V>> stack = new ArrayDeque<VertexData<V>>(); stack.add(vertexData); while (!stack.isEmpty()) { VertexData<V> data = stack.removeLast(); if (!data.isDiscovered()) { data.setDiscovered(true); if (vertices != null) { vertices.add(data.getVertex()); } stack.add(new VertexData1<V>(data, true, true)); // follow all edges for (E edge : visitedGraph.outgoingEdgesOf(data.getVertex())) { VertexData<V> targetData = vertexToVertexData.get(visitedGraph.getEdgeTarget(edge)); if (!targetData.isDiscovered()) { // the "recursion" stack.add(targetData); } } } else if (data.isFinished()) { if (vertices == null) { orderedVertices.addFirst(data.getFinishedData()); } } } }
public void testZeroNodes() { GraphGenerator<Integer, DefaultEdge, Integer> gen = new GnpRandomBipartiteGraphGenerator<>(0, 0, 0.5); DirectedGraph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); gen.generateGraph(g, new IntegerVertexFactory(), null); assertEquals(0, g.vertexSet().size()); assertEquals(0, g.edgeSet().size()); }
public void testDirectedGraphGnp2() { GraphGenerator<Integer, DefaultEdge, Integer> gen = new GnpRandomBipartiteGraphGenerator<>(4, 4, 1.0, SEED); DirectedGraph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); gen.generateGraph(g, new IntegerVertexFactory(), null); assertEquals(4 + 4, g.vertexSet().size()); assertEquals(32, g.edgeSet().size()); }
private void replaceVertex(JavaClass newClass) { List<JavaClass> incomingEdges = getParents(newClass); graph.removeVertex(newClass); graph.addVertex(newClass); for (JavaClass each : incomingEdges) { graph.addEdge(each, newClass); } }
private void updateParentReferences(JavaClass parentClass) { for (String child : parentClass.getImports()) { JavaClass childClass = findJavaClass(child); if ((childClass != null) && !childClass.equals(parentClass)) { if (graph.containsVertex(childClass)) { graph.addEdge(parentClass, childClass); } } } }
public void testDirectedMatrixNoNodeIdZeroMissingEdges() { DirectedGraph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); g.addVertex(1); g.addVertex(2); g.addVertex(3); g.addVertex(4); g.addVertex(5); g.addEdge(1, 2); g.addEdge(1, 3); g.addEdge(3, 1); g.addEdge(3, 4); g.addEdge(4, 5); g.addEdge(5, 1); g.addEdge(5, 2); g.addEdge(5, 3); g.addEdge(5, 4); g.addEdge(5, 5); CSVExporter<Integer, DefaultEdge> exporter = new CSVExporter<>(nameProvider, CSVFormat.MATRIX, ';'); exporter.setParameter(CSVFormat.Parameter.MATRIX_FORMAT_ZERO_WHEN_NO_EDGE, true); StringWriter w = new StringWriter(); exporter.exportGraph(g, w); assertEquals(DIRECTED_MATRIX_NO_NODEID_ZERO_NO_EDGE, w.toString()); }
public void testAdjacencyDirected() { DirectedGraph<String, DefaultEdge> g = new DirectedMultigraph<String, DefaultEdge>(DefaultEdge.class); g.addVertex(V1); g.addVertex(V2); g.addEdge(V1, V2); g.addVertex(V3); g.addEdge(V3, V1); g.addEdge(V3, V1); Writer w = new StringWriter(); exporter.exportAdjacencyMatrix(w, g); assertEquals(DIRECTED_ADJACENCY, w.toString()); }
public void testDirectedGraphGnp3() { GraphGenerator<Integer, DefaultEdge, Integer> gen = new GnpRandomBipartiteGraphGenerator<>(4, 4, 0.1, SEED); DirectedGraph<Integer, DefaultEdge> g = new DirectedPseudograph<>(DefaultEdge.class); gen.generateGraph(g, new IntegerVertexFactory(), null); int[][] edges = {{5, 1}, {7, 3}, {3, 8}, {8, 4}}; assertEquals(4 + 4, g.vertexSet().size()); for (int[] e : edges) { assertTrue(g.containsEdge(e[0], e[1])); } assertEquals(edges.length, g.edgeSet().size()); }
/** . */ public void testStronglyConnected2() { DirectedGraph<String, DefaultEdge> g = new DefaultDirectedGraph<String, DefaultEdge>(DefaultEdge.class); g.addVertex(V1); g.addVertex(V2); g.addVertex(V3); g.addVertex(V4); g.addEdge(V1, V2); g.addEdge(V2, V1); // strongly connected g.addEdge(V4, V3); // only weakly connected g.addEdge(V3, V2); // only weakly connected StrongConnectivityInspector<String, DefaultEdge> inspector = new StrongConnectivityInspector<String, DefaultEdge>(g); // convert from List to Set because we need to ignore order // during comparison Set<Set<String>> actualSets = new HashSet<Set<String>>(inspector.stronglyConnectedSets()); // construct the expected answer Set<Set<String>> expectedSets = new HashSet<Set<String>>(); Set<String> set = new HashSet<String>(); set.add(V1); set.add(V2); expectedSets.add(set); set = new HashSet<String>(); set.add(V3); expectedSets.add(set); set = new HashSet<String>(); set.add(V4); expectedSets.add(set); assertEquals(expectedSets, actualSets); actualSets.clear(); List<DirectedSubgraph<String, DefaultEdge>> subgraphs = inspector.stronglyConnectedSubgraphs(); for (DirectedSubgraph<String, DefaultEdge> sg : subgraphs) { actualSets.add(sg.vertexSet()); StrongConnectivityInspector<String, DefaultEdge> ci = new StrongConnectivityInspector<String, DefaultEdge>(sg); assertTrue(ci.isStronglyConnected()); } assertEquals(expectedSets, actualSets); }
private JavaClass findClass(String classname) { for (JavaClass jClass : graph.vertexSet()) { if (jClass.getName().equals(classname)) { return jClass; } } return null; }
public Set<String> getIndexedClasses() { Set<String> classes = newHashSet(); Set<JavaClass> vertexSet = graph.vertexSet(); for (JavaClass each : vertexSet) { classes.add(each.getName()); } return classes; }
public DirectedGraph<Node, Edge> convert() { DirectedGraph<Node, Edge> graph = new SimpleDirectedGraph<Node, Edge>(Edge.factory); // Add vertices for (Type t : hierarchy) graph.addVertex(Node.get(t)); // Add edges for (Type t : hierarchy) { for (Type i : hierarchy.getInterfaces(t)) { graph.addVertex(Node.get(i)); graph.addEdge(Node.get(t), Node.get(i)); } Type sc = hierarchy.getSuperclass(t); if (sc == null) { assert t.equals(OBJECT) : t; continue; } graph.addVertex(Node.get(sc)); graph.addEdge(Node.get(t), Node.get(sc)); } // Check for cycles if (new CycleDetector<Node, Edge>(graph).detectCycles()) throw new CyclicHierarchyException(graph.toString()); return graph; }
/** HG: measures time needed to check a pair of huge random graphs */ @Test public void testHugeGraph() { int n = 700; long time = System.currentTimeMillis(); DirectedGraph<Integer, DefaultEdge> g1 = SubgraphIsomorphismTestUtils.randomGraph(n, n * n / 50, 12345), g2 = SubgraphIsomorphismTestUtils.randomSubgraph(g1, n / 2, 54321); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf2 = new VF2SubgraphIsomorphismInspector<>(g1, g2); assertEquals(true, vf2.isomorphismExists()); SubgraphIsomorphismTestUtils.showLog( "|V1| = " + g1.vertexSet().size() + ", |E1| = " + g1.edgeSet().size() + ", |V2| = " + g2.vertexSet().size() + ", |E2| = " + g2.edgeSet().size() + " - " + (System.currentTimeMillis() - time) + "ms"); }
/** Tests edge cases on directed graphs */ @Test public void testEdgeCasesDirectedGraph() { /* ECD-1: graph and subgraph empty */ DirectedGraph<Integer, DefaultEdge> dg0v = new DefaultDirectedGraph<>(DefaultEdge.class), dg0v2 = new DefaultDirectedGraph<>(DefaultEdge.class); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf1 = new VF2SubgraphIsomorphismInspector<>(dg0v, dg0v2); assertEquals("[]", vf1.getMappings().next().toString()); /* ECD-2: graph non-empty, subgraph empty */ DirectedGraph<Integer, DefaultEdge> dg4v3e = new DefaultDirectedGraph<>(DefaultEdge.class); dg4v3e.addVertex(1); dg4v3e.addVertex(2); dg4v3e.addVertex(3); dg4v3e.addVertex(4); dg4v3e.addEdge(1, 2); dg4v3e.addEdge(3, 2); dg4v3e.addEdge(3, 4); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf2 = new VF2SubgraphIsomorphismInspector<>(dg4v3e, dg0v); assertEquals("[1=~~ 2=~~ 3=~~ 4=~~]", vf2.getMappings().next().toString()); /* ECD-3: graph empty, subgraph non-empty */ VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf3 = new VF2SubgraphIsomorphismInspector<>(dg0v, dg4v3e); assertEquals(false, vf3.isomorphismExists()); /* ECD-4: graph non-empty, subgraph single vertex */ DirectedGraph<Integer, DefaultEdge> dg1v = new DefaultDirectedGraph<>(DefaultEdge.class); dg1v.addVertex(5); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf4 = new VF2SubgraphIsomorphismInspector<>(dg4v3e, dg1v); Iterator<GraphMapping<Integer, DefaultEdge>> iter4 = vf4.getMappings(); Set<String> mappings = new HashSet<>( Arrays.asList( "[1=5 2=~~ 3=~~ 4=~~]", "[1=~~ 2=5 3=~~ 4=~~]", "[1=~~ 2=~~ 3=5 4=~~]", "[1=~~ 2=~~ 3=~~ 4=5]")); assertEquals(true, mappings.remove(iter4.next().toString())); assertEquals(true, mappings.remove(iter4.next().toString())); assertEquals(true, mappings.remove(iter4.next().toString())); assertEquals(true, mappings.remove(iter4.next().toString())); assertEquals(false, iter4.hasNext()); /* ECD-5: graph empty, subgraph single vertex */ VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf5 = new VF2SubgraphIsomorphismInspector<>(dg0v, dg1v); assertEquals(false, vf5.isomorphismExists()); /* ECD-6: subgraph with vertices, but no edges */ DirectedGraph<Integer, DefaultEdge> dg3v0e = new DefaultDirectedGraph<>(DefaultEdge.class); dg3v0e.addVertex(5); dg3v0e.addVertex(6); dg3v0e.addVertex(7); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf6 = new VF2SubgraphIsomorphismInspector<>(dg4v3e, dg3v0e); assertEquals(false, vf6.isomorphismExists()); /* ECD-7: graph and subgraph with vertices, but no edges */ DirectedGraph<Integer, DefaultEdge> dg2v0e = new DefaultDirectedGraph<>(DefaultEdge.class); dg2v0e.addVertex(1); dg2v0e.addVertex(2); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf7 = new VF2SubgraphIsomorphismInspector<>(dg3v0e, dg2v0e); Iterator<GraphMapping<Integer, DefaultEdge>> iter7 = vf7.getMappings(); Set<String> mappings7 = new HashSet<>( Arrays.asList( "[5=1 6=2 7=~~]", "[5=1 6=~~ 7=2]", "[5=2 6=1 7=~~]", "[5=~~ 6=1 7=2]", "[5=2 6=~~ 7=1]", "[5=~~ 6=2 7=1]")); assertEquals(true, mappings7.remove(iter7.next().toString())); assertEquals(true, mappings7.remove(iter7.next().toString())); assertEquals(true, mappings7.remove(iter7.next().toString())); assertEquals(true, mappings7.remove(iter7.next().toString())); assertEquals(true, mappings7.remove(iter7.next().toString())); assertEquals(true, mappings7.remove(iter7.next().toString())); assertEquals(false, iter7.hasNext()); /* ECD-8: graph no edges, subgraph contains single edge */ DirectedGraph<Integer, DefaultEdge> dg2v1e = new DefaultDirectedGraph<>(DefaultEdge.class); dg2v1e.addVertex(5); dg2v1e.addVertex(6); dg2v1e.addEdge(5, 6); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf8 = new VF2SubgraphIsomorphismInspector<>(dg3v0e, dg2v1e); assertEquals(false, vf8.isomorphismExists()); /* ECD-9: complete graphs of different size, * graph smaller than subgraph */ DirectedGraph<Integer, DefaultEdge> dg5c = new DefaultDirectedGraph<>(DefaultEdge.class); dg5c.addVertex(0); dg5c.addVertex(1); dg5c.addVertex(2); dg5c.addVertex(3); dg5c.addVertex(4); dg5c.addEdge(0, 1); dg5c.addEdge(0, 2); dg5c.addEdge(0, 3); dg5c.addEdge(0, 4); dg5c.addEdge(1, 2); dg5c.addEdge(1, 3); dg5c.addEdge(1, 4); dg5c.addEdge(2, 3); dg5c.addEdge(2, 4); dg5c.addEdge(3, 4); DirectedGraph<Integer, DefaultEdge> dg4c = new DefaultDirectedGraph<>(DefaultEdge.class); dg4c.addVertex(0); dg4c.addVertex(1); dg4c.addVertex(2); dg4c.addVertex(3); dg4c.addEdge(0, 1); dg4c.addEdge(0, 2); dg4c.addEdge(0, 3); dg4c.addEdge(1, 2); dg4c.addEdge(1, 3); dg4c.addEdge(2, 3); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf9 = new VF2SubgraphIsomorphismInspector<>(dg4c, dg5c); assertEquals(false, vf9.isomorphismExists()); /* ECD-10: complete graphs of different size, * graph bigger than subgraph */ VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf10 = new VF2SubgraphIsomorphismInspector<>(dg5c, dg4c); Iterator<GraphMapping<Integer, DefaultEdge>> iter10 = vf10.getMappings(); Set<String> mappings10 = new HashSet<>( Arrays.asList( "[0=0 1=1 2=2 3=3 4=~~]", "[0=0 1=1 2=2 3=~~ 4=3]", "[0=0 1=1 2=~~ 3=2 4=3]", "[0=0 1=~~ 2=1 3=2 4=3]", "[0=~~ 1=0 2=1 3=2 4=3]")); assertEquals(true, mappings10.remove(iter10.next().toString())); assertEquals(true, mappings10.remove(iter10.next().toString())); assertEquals(true, mappings10.remove(iter10.next().toString())); assertEquals(true, mappings10.remove(iter10.next().toString())); assertEquals(true, mappings10.remove(iter10.next().toString())); assertEquals(false, iter10.hasNext()); /* ECD-11: isomorphic graphs */ VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf11 = new VF2SubgraphIsomorphismInspector<>(dg4v3e, dg4v3e); Iterator<GraphMapping<Integer, DefaultEdge>> iter11 = vf11.getMappings(); assertEquals("[1=1 2=2 3=3 4=4]", iter11.next().toString()); assertEquals(false, iter11.hasNext()); /* ECD-12: not connected graphs of different size */ DirectedGraph<Integer, DefaultEdge> dg6v4enc = new DefaultDirectedGraph<>(DefaultEdge.class); dg6v4enc.addVertex(0); dg6v4enc.addVertex(1); dg6v4enc.addVertex(2); dg6v4enc.addVertex(3); dg6v4enc.addVertex(4); dg6v4enc.addVertex(5); dg6v4enc.addEdge(1, 2); dg6v4enc.addEdge(2, 3); dg6v4enc.addEdge(3, 1); dg6v4enc.addEdge(4, 5); DirectedGraph<Integer, DefaultEdge> dg5v4enc = new DefaultDirectedGraph<>(DefaultEdge.class); dg5v4enc.addVertex(6); dg5v4enc.addVertex(7); dg5v4enc.addVertex(8); dg5v4enc.addVertex(9); dg5v4enc.addVertex(10); dg5v4enc.addEdge(7, 6); dg5v4enc.addEdge(9, 8); dg5v4enc.addEdge(10, 9); dg5v4enc.addEdge(8, 10); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf12 = new VF2SubgraphIsomorphismInspector<>(dg6v4enc, dg5v4enc); Iterator<GraphMapping<Integer, DefaultEdge>> iter12 = vf12.getMappings(); Set<String> mappings12 = new HashSet<>( Arrays.asList( "[0=~~ 1=8 2=10 3=9 4=7 5=6]", "[0=~~ 1=9 2=8 3=10 4=7 5=6]", "[0=~~ 1=10 2=9 3=8 4=7 5=6]")); assertEquals(true, mappings12.remove(iter12.next().toString())); assertEquals(true, mappings12.remove(iter12.next().toString())); assertEquals(true, mappings12.remove(iter12.next().toString())); assertEquals(false, iter12.hasNext()); }
/** * Tests graph types: In case of invalid graph types or invalid combination of graph arguments * UnsupportedOperationException or InvalidArgumentException is expected */ @Test public void testGraphTypes() { DirectedGraph<Integer, DefaultEdge> dg1 = new DefaultDirectedGraph<>(DefaultEdge.class); dg1.addVertex(1); dg1.addVertex(2); dg1.addEdge(1, 2); SimpleGraph<Integer, DefaultEdge> sg1 = new SimpleGraph<>(DefaultEdge.class); sg1.addVertex(1); sg1.addVertex(2); sg1.addEdge(1, 2); Multigraph<Integer, DefaultEdge> mg1 = new Multigraph<>(DefaultEdge.class); mg1.addVertex(1); mg1.addVertex(2); mg1.addEdge(1, 2); Pseudograph<Integer, DefaultEdge> pg1 = new Pseudograph<>(DefaultEdge.class); pg1.addVertex(1); pg1.addVertex(2); pg1.addEdge(1, 2); /* GT-0 test graph=null */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt0 = new VF2SubgraphIsomorphismInspector<>(null, sg1); Assert.fail("Expected UnsupportedOperationException"); } catch (NullPointerException ex) { } /* GT-1: multigraphs */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt1 = new VF2SubgraphIsomorphismInspector<>(mg1, mg1); Assert.fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException ex) { } /* GT-2: pseudographs */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt2 = new VF2SubgraphIsomorphismInspector<>(pg1, pg1); Assert.fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException ex) { } /* GT-3: simple graphs */ VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt3 = new VF2SubgraphIsomorphismInspector<>(sg1, sg1); assertEquals(true, gt3.getMappings().hasNext()); /* GT-4: directed graphs */ VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt4 = new VF2SubgraphIsomorphismInspector<>(dg1, dg1); assertEquals("[1=1 2=2]", gt4.getMappings().next().toString()); /* GT-5: simple graph + multigraph */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt5 = new VF2SubgraphIsomorphismInspector<>(sg1, mg1); Assert.fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException ex) { } /* GT-6: simple graph + pseudograph */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt6 = new VF2SubgraphIsomorphismInspector<>(sg1, pg1); Assert.fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException ex) { } /* GT-7: directed graph + multigraph */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt7 = new VF2SubgraphIsomorphismInspector<>(dg1, mg1); Assert.fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException ex) { } /* GT-8: directed graph + pseudograph */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt8 = new VF2SubgraphIsomorphismInspector<>(dg1, pg1); Assert.fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException ex) { } /* GT-9: pseudograph + multigraph */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt9 = new VF2SubgraphIsomorphismInspector<>(pg1, mg1); Assert.fail("Expected UnsupportedOperationException"); } catch (UnsupportedOperationException ex) { } /* GT-10: simple graph + directed graph */ try { @SuppressWarnings("unused") VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> gt10 = new VF2SubgraphIsomorphismInspector<>(sg1, dg1); Assert.fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException ex) { } }
private void addToGraph(JavaClass newClass) { if (!graph.addVertex(newClass)) { replaceVertex(newClass); } }
@Test public void testExhaustive() { /* DET-1: * * 0 3 * | /| 0 2 * g1 = | 2 | g2 = |/ * |/ | 1 * 1 4 */ SimpleGraph<Integer, DefaultEdge> g1 = new SimpleGraph<>(DefaultEdge.class), g2 = new SimpleGraph<>(DefaultEdge.class); g1.addVertex(0); g1.addVertex(1); g1.addVertex(2); g1.addVertex(3); g1.addVertex(4); g2.addVertex(0); g2.addVertex(1); g2.addVertex(2); g1.addEdge(0, 1); g1.addEdge(1, 2); g1.addEdge(2, 3); g1.addEdge(3, 4); g2.addEdge(0, 1); g2.addEdge(1, 2); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf2 = new VF2SubgraphIsomorphismInspector<>(g1, g2); assertEquals(true, SubgraphIsomorphismTestUtils.containsAllMatchings(vf2, g1, g2)); /* DET-2: * * g3 = ... g4 = ... * */ DirectedGraph<Integer, DefaultEdge> g3 = new DefaultDirectedGraph<>(DefaultEdge.class), g4 = new DefaultDirectedGraph<>(DefaultEdge.class); g3.addVertex(0); g3.addVertex(1); g3.addVertex(2); g3.addVertex(3); g3.addVertex(4); g3.addVertex(5); g4.addVertex(0); g4.addVertex(1); g4.addVertex(2); g4.addVertex(3); g3.addEdge(0, 1); g3.addEdge(0, 5); g3.addEdge(1, 4); g3.addEdge(2, 1); g3.addEdge(2, 4); g3.addEdge(3, 1); g3.addEdge(4, 0); g3.addEdge(5, 2); g3.addEdge(5, 4); g4.addEdge(0, 3); g4.addEdge(1, 2); g4.addEdge(1, 3); g4.addEdge(2, 3); g4.addEdge(2, 0); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf3 = new VF2SubgraphIsomorphismInspector<>(g3, g4); assertEquals(true, SubgraphIsomorphismTestUtils.containsAllMatchings(vf3, g3, g4)); /* DET-3: * * 1----0 0---2 * | | / * g5 = | g6 = | / * | |/ * 2----3 1 */ SimpleGraph<Integer, DefaultEdge> g5 = new SimpleGraph<>(DefaultEdge.class), g6 = new SimpleGraph<>(DefaultEdge.class); g5.addVertex(0); g5.addVertex(1); g5.addVertex(2); g5.addVertex(3); g6.addVertex(0); g6.addVertex(1); g6.addVertex(2); g5.addEdge(0, 1); g5.addEdge(1, 2); g5.addEdge(2, 3); g6.addEdge(0, 1); g6.addEdge(1, 2); g6.addEdge(2, 0); VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf4 = new VF2SubgraphIsomorphismInspector<>(g5, g6); assertEquals(true, SubgraphIsomorphismTestUtils.containsAllMatchings(vf4, g5, g6)); }