/** RG-1: Tests if a all matchings are correct (on some random graphs). */
  @Test
  public void testRandomGraphs() {
    Random rnd = new Random();
    rnd.setSeed(54321);

    for (int i = 1; i < 50; i++) {
      int vertexCount = 2 + rnd.nextInt(i),
          edgeCount = vertexCount + rnd.nextInt(vertexCount * (vertexCount - 1)) / 2,
          subVertexCount = 1 + rnd.nextInt(vertexCount);

      DirectedGraph<Integer, DefaultEdge>
          g1 = SubgraphIsomorphismTestUtils.randomGraph(vertexCount, edgeCount, i),
          g2 = SubgraphIsomorphismTestUtils.randomSubgraph(g1, subVertexCount, i);

      VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf2 =
          new VF2SubgraphIsomorphismInspector<>(g1, g2);

      SubgraphIsomorphismTestUtils.showLog(i + ": " + vertexCount + "v, " + edgeCount + "e ");

      for (Iterator<GraphMapping<Integer, DefaultEdge>> mappings = vf2.getMappings();
          mappings.hasNext(); ) {
        assertEquals(true, SubgraphIsomorphismTestUtils.isCorrectMatching(mappings.next(), g1, g2));
        SubgraphIsomorphismTestUtils.showLog(".");
      }
      SubgraphIsomorphismTestUtils.showLog("\n");
    }
  }
  /** RG-2: Tests if all matchings are correct and if every matching is found (on random graphs). */
  @Test
  public void testRandomGraphsExhaustive() {
    Random rnd = new Random();
    rnd.setSeed(12345);

    for (int i = 1; i < 100; i++) {
      int vertexCount = 3 + rnd.nextInt(5),
          edgeCount = rnd.nextInt(vertexCount * (vertexCount - 1)),
          subVertexCount = 2 + rnd.nextInt(vertexCount),
          subEdgeCount = rnd.nextInt(subVertexCount * (subVertexCount - 1));

      DirectedGraph<Integer, DefaultEdge>
          g1 = SubgraphIsomorphismTestUtils.randomGraph(vertexCount, edgeCount, i),
          g2 = SubgraphIsomorphismTestUtils.randomGraph(subVertexCount, subEdgeCount, i);

      VF2SubgraphIsomorphismInspector<Integer, DefaultEdge> vf2 =
          new VF2SubgraphIsomorphismInspector<>(g1, g2);

      SubgraphIsomorphismTestUtils.showLog(i + ": " + vertexCount + "v, " + edgeCount + "e ....\n");

      assertEquals(true, SubgraphIsomorphismTestUtils.containsAllMatchings(vf2, g1, g2));
    }
  }