/** Code to test the correctness of the SimpleGraph methods. */
  public static void main(String[] args) {
    // create graph a----b-----c,
    //                X     Y
    // X and Y are objects stored at edges. .

    // All Objects stored will be strings.

    SimpleGraph G = new SimpleGraph();
    Vertex v, w, a, b, c;
    Edge e, x, y;
    v = G.insertVertex(null, "a");
    a = v;
    w = G.insertVertex(null, "b");
    b = w;
    e = G.insertEdge(a, b, null, "X");
    x = e;
    v = G.insertVertex(null, "c");
    c = v;
    e = G.insertEdge(b, c, null, "Y");
    y = e;

    Iterator i;

    System.out.println("Iterating through vertices...");
    for (i = G.vertices(); i.hasNext(); ) {
      v = (Vertex) i.next();
      System.out.println("found vertex " + v.getName());
    }

    System.out.println("Iterating through adjacency lists...");
    for (i = G.vertices(); i.hasNext(); ) {
      v = (Vertex) i.next();
      System.out.println("Vertex " + v.getName());
      Iterator j;

      for (j = G.incidentEdges(v); j.hasNext(); ) {
        e = (Edge) j.next();
        System.out.println("  found edge " + e.getName());
      }
    }

    System.out.println("Testing opposite...");
    System.out.println("aXbYc is ");
    System.out.println(a);
    System.out.println(x);
    System.out.println(b);
    System.out.println(y);
    System.out.println(c);

    System.out.println("opposite(a,x) is " + G.opposite(a, x));
    System.out.println("opposite(a,y) is " + G.opposite(a, y));
    System.out.println("opposite(b,x) is " + G.opposite(b, x));
    System.out.println("opposite(b,y) is " + G.opposite(b, y));
    System.out.println("opposite(c,x) is " + G.opposite(c, x));
    System.out.println("opposite(c,y) is " + G.opposite(c, y));
  }