// test.java - mjd@cs.auckland.ac.nz import java.io.*; import graphs.*; public class test { public static void main(String argv[]) { Graph G = new Graph(); G.addVertices(5); G.addArc(0,2); G.addArc(0,3); G.addEdge(1,2); G.addArc(2,3); G.addArc(2,0); G.addArc(2,4); G.addArc(3,2); G.addEdge(4,1); G.addArc(4,2); //n=5 //2 3 //2 4 //0 1 3 4 //2 //1 2 System.out.println(G.toStringAdjLists()); G.removeArc(2,0); G.removeArc(4,1); G.removeArc(2,3); //n=5 //2 3 //2 4 //1 4 //2 //2 System.out.println(G.toStringAdjMatrix()); G.addVertices(2); G.addArc(5,4); G.addArc(5,2); G.addArc(5,6); G.addArc(2,6); G.addArc(0,6); G.addArc(6,0); //n=7 //2 3 6 //2 4 //1 4 6 //2 //2 //2 4 6 //0 System.out.println(G.toStringAdjLists()); G.removeVertex(4); G.removeEdge(5,0); G.addVertices(1); G.addEdge(1,6); //n=7 //2 3 //2 6 //1 5 //2 //2 5 // //1 System.out.println(G.toStringAdjLists()); } 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 Graph(input); System.out.println(G.toStringAdjMatrix()); System.out.println(G.toStringAdjLists()); } while(G.order() > 0); } catch ( Exception e ) { System.err.println("Exception: "+e); } } }