/** 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"); }
/* * 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)); } }
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 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()); }
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()); }