// test.java - mjd@cs.auckland.ac.nz import java.io.*; import graphADT.*; class myW extends wGraph.Weight { myW(int x) { super(new Integer(x)); } } public class testwgraph { public static void main(String argv[]) { wGraph G1 = new wGraphLists(); 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); wGraph G2 = new wGraphMatrix(G1); G2.removeArc(2,0); G2.removeArc(4,1); G2.removeArc(2,3); G2.addVertices(1); G2.addArc(5,3); G2.addEdge(5,2); G2.removeVertex(5); //n=5 //2 3 //2 4 //1 4 //2 //2 System.out.println(G2); wGraph G3 = new wGraphLists(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); wGraph G4 = new wGraphLists(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); wGraph GM = new wGraphMatrix(); GM.addVertices(5); GM.addArc(0,2); GM.addArc(1,2,new myW(6)); GM.addArc(3,2,new myW(7)); GM.addArc(4,2,new myW(9)); GM.addEdge(0,3); GM.setArcWeight(0,3,new myW(8)); System.out.println(GM); System.out.println(new GraphAdjMatrix(GM)); wGraph GL = new wGraphLists(GM); GL.removeVertex(2); GL.addArc(3,0,new myW(10)); GL.setArcWeight(0,2,new myW(11)); GL.addArc(3,2,new myW(12)); GL.addEdge(1,0); GL.setArcWeight(1,0,new myW(13)); System.out.println(GL); System.out.println(new GraphAdjLists(GL)); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); GL = new wGraphLists(new BufferedReader(input)); System.out.println(GL); } }