/* Programmer: Sriram Pemmaraju. Nov 24th, 2007 */ import java.io.*; public class WeightedGraphTester{ //Main method public static void main(String[] args) { myWeightedGraph g = new myWeightedGraph(); System.out.println("Makes an edge-weighted graph..."); g.addVertex("A"); g.addVertex("B"); g.addVertex("C"); g.addVertex("D"); g.addVertex("E"); g.addEdge("A", "C", 3); g.addEdge("A", "B", 5); g.addEdge("C", "D", 4); g.addEdge("B", "D", 1); g.addEdge("D", "E", 2); g.addEdge("B", "E", 7); System.out.println("that has " + g.numberOfVertices() + " vertices and " + g.numberOfEdges() + " edges."); Double d = g.getWeight("A", "E"); if(d == null) System.out.println("There is no edge between A and E"); else System.out.println("The edge between A and E has weight " + d.doubleValue()); d = g.getWeight("A", "C"); if(d == null) System.out.println("There is no edge between A and C"); else System.out.println("The edge between A and C has weight " + d.doubleValue()); System.out.println("The MST of this graph is..."); myWeightedGraph h = g.MSTGraph(); h.printEdges(); System.out.println("The cost of this MST is " + g.costMST()); System.out.println("The brute-force TSP of this graph is..."); g.printTSP(); System.out.println("The cost of this TSP is " + g.costTSP()); System.out.println("---------------------------------------------------------------------------------------"); } }