import rpi.goldsd.graph.*; public class Cities { public static final void main( String[] args ) { // Create a Vertex object for each city ... Vertex chicago = new Vertex( "Chicago" ); Vertex denver = new Vertex( "Denver" ); Vertex honolulu = new Vertex( "Honolulu" ); Vertex juneau = new Vertex( "Juneau" ); Vertex seattle = new Vertex( "Seattle" ); // Create weighted Edge objects between cities ... Edge E1 = new Edge( chicago, denver, 920.0 ); Edge E2 = new Edge( chicago, honolulu, 4244.0 ); Edge E3 = new Edge( denver, honolulu, 3338.0 ); Edge E4 = new Edge( denver, juneau, 1831.0 ); Edge E5 = new Edge( honolulu, juneau, 2815.0 ); Edge E6 = new Edge( seattle, chicago, 1737.0 ); Edge E7 = new Edge( seattle, juneau, 899.0 ); // Construct a named graph ... Graph USMap = new Graph( "US Cities Graph" ); // Add the vertices to the graph ... USMap.add( chicago ); USMap.add( denver ); USMap.add( honolulu ); USMap.add( juneau ); USMap.add( seattle ); // Add the weighted edges to the graph ... USMap.add( E1 ); USMap.add( E2 ); USMap.add( E3 ); USMap.add( E4 ); USMap.add( E5 ); USMap.add( E6 ); USMap.add( E7 ); // Print out a summary of the graph ... Algorithms.toGraphDraw( USMap, "Cities.html" ); // Find the shortest path between Chicago and Juneau ... System.out.println(); Path P = Algorithms.findShortestPath( chicago, juneau ); System.out.print( "Shortest Path from " + chicago ); System.out.println( " to " + juneau + " is: " + P ); System.out.println( "Overall distance is " + P.weight() + " miles." ); System.out.println(); // Construct a BFS Tree rooted at Honolulu ... // Tree T = Algorithms.breadthFirstTraversal( honolulu ); // T.printSummary(); } }