// test.java - mjd@cs.auckland.ac.nz import java.io.*; import graphADT.*; public class test { public static void main(String argv[]) { Graph G1 = new GraphAdjLists(); G1.addVertices(5); G1.addArc(0,2); G1.addArc(0,3); G1.addEdge(1,2); G1.addArc(2,3); G1.addArc(2,0); G1.addArc(2,4); G1.addArc(3,2); G1.addEdge(4,1); G1.addArc(4,2); //n=5 //2 3 //2 4 //0 1 3 4 //2 //1 2 System.out.println(G1); Graph G2 = new GraphAdjMatrix(G1); G2.removeArc(2,0); G2.removeArc(4,1); G2.removeArc(2,3); //n=5 //2 3 //2 4 //1 4 //2 //2 System.out.println(G2); Graph G3 = new GraphAdjLists(G2); G3.addVertices(2); G3.addArc(5,4); G3.addArc(5,2); G3.addArc(5,6); G3.addArc(2,6); G3.addArc(0,6); G3.addArc(6,0); //n=7 //2 3 6 //2 4 //1 4 6 //2 //2 //2 4 6 //0 System.out.println(G3); Graph G4 = new GraphAdjLists(G3); G4.removeVertex(4); G4.removeEdge(5,0); G4.addVertices(1); G4.addEdge(1,6); //n=7 //2 3 //2 6 //1 5 //2 //2 5 // //1 System.out.println(G4); } public static void mainOld(String argv[]) { try { // BufferedReader input = new BufferedReader(new FileReader(argv[0])); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); Graph G; do { G = new GraphAdjMatrix(input); //System.out.println(G.toStringAdjMatrix()); //System.out.println(G.toStringAdjLists()); } while(G.order() > 0); } catch ( Exception e ) { System.err.println("Exception: "+e); } } }