/** . */
  public void testIsGraphConnected() {
    Pseudograph<String, DefaultEdge> g = create();
    ConnectivityInspector<String, DefaultEdge> inspector =
        new ConnectivityInspector<String, DefaultEdge>(g);

    assertEquals(false, inspector.isGraphConnected());

    g.removeVertex(V4);
    inspector = new ConnectivityInspector<String, DefaultEdge>(g);
    assertEquals(true, inspector.isGraphConnected());

    g.removeVertex(V1);
    assertEquals(1, g.edgeSet().size());

    g.removeEdge(e2);
    g.addEdge(V2, V2);
    assertEquals(1, g.edgeSet().size());

    inspector = new ConnectivityInspector<String, DefaultEdge>(g);
    assertEquals(false, inspector.isGraphConnected());
  }
  /**
   * 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) {
    }
  }
  /**
   * .
   *
   * @return a graph
   */
  public Pseudograph<String, DefaultEdge> create() {
    Pseudograph<String, DefaultEdge> g = new Pseudograph<String, DefaultEdge>(DefaultEdge.class);

    assertEquals(0, g.vertexSet().size());
    g.addVertex(V1);
    assertEquals(1, g.vertexSet().size());
    g.addVertex(V2);
    assertEquals(2, g.vertexSet().size());
    g.addVertex(V3);
    assertEquals(3, g.vertexSet().size());
    g.addVertex(V4);
    assertEquals(4, g.vertexSet().size());

    assertEquals(0, g.edgeSet().size());

    e1 = g.addEdge(V1, V2);
    assertEquals(1, g.edgeSet().size());

    e2 = g.addEdge(V2, V3);
    assertEquals(2, g.edgeSet().size());

    e3 = g.addEdge(V3, V1);
    assertEquals(3, g.edgeSet().size());

    e3_b = g.addEdge(V3, V1);
    assertEquals(4, g.edgeSet().size());
    assertNotNull(e3_b);

    u = g.addEdge(V1, V1);
    assertEquals(5, g.edgeSet().size());
    u = g.addEdge(V1, V1);
    assertEquals(6, g.edgeSet().size());

    return g;
  }