public static void main(String[] args) { System.out.print("Making a new map..."); MapGraph theMap = new MapGraph(); System.out.print("DONE. \nLoading the map..."); GraphLoader.loadRoadMap("data/testdata/simpletest.map", theMap); System.out.println("DONE."); GeographicPoint start = new GeographicPoint(1, 1); GeographicPoint goal = new GeographicPoint(8, -1); System.out.println("Dikstra's: "); theMap.dijkstra(start, goal); System.out.println("A star: "); theMap.aStarSearch(start, goal); // // Method for testing. // MapGraph theMap = new MapGraph(); // System.out.print("DONE. \nLoading the map..."); // GraphLoader.loadRoadMap("data/maps/utc.map", theMap); // System.out.println("DONE."); // // GeographicPoint start = new GeographicPoint(32.8648772, -117.2254046); // GeographicPoint end = new GeographicPoint(32.8660691, -117.217393); // // // List<GeographicPoint> route = theMap.dijkstra(start,end); // List<GeographicPoint> route2 = theMap.aStarSearch(start,end); }
public static void main(String[] args) { /* Use this code in Week 2 System.out.print("Making a new map..."); MapGraph theMap = new MapGraph(); System.out.print("DONE. \nLoading the map..."); GraphLoader.loadRoadMap("data/testdata/simpletest.map", theMap); System.out.println("DONE."); */ // You can use this method for testing. System.out.print("Making a new map..."); MapGraph theMap = new MapGraph(); System.out.print("DONE. \nLoading the map..."); GraphLoader.loadRoadMap("data/graders/mod3/map2.txt", theMap); System.out.println("DONE."); System.out.println("Num nodes: " + theMap.getNumVertices()); System.out.println("Num edges: " + theMap.getNumEdges()); List<GeographicPoint> route = theMap.dijkstra(new GeographicPoint(1.0, 1.0), new GeographicPoint(8.0, -1.0)); System.out.println(route); List<GeographicPoint> route2 = theMap.aStarSearch(new GeographicPoint(1.0, 1.0), new GeographicPoint(8.0, -1.0)); System.out.println(route2); // System.out.println(Double.POSITIVE_INFINITY + Double.POSITIVE_INFINITY); /* Use this code in Week 3 End of Week Quiz MapGraph theMap = new MapGraph(); System.out.print("DONE. \nLoading the map..."); GraphLoader.loadRoadMap("data/maps/utc.map", theMap); System.out.println("DONE."); GeographicPoint start = new GeographicPoint(32.8648772, -117.2254046); GeographicPoint end = new GeographicPoint(32.8660691, -117.217393); List<GeographicPoint> route = theMap.dijkstra(start,end); List<GeographicPoint> route2 = theMap.aStarSearch(start,end); */ }
// main method for testing public static void main(String[] args) { /* System.out.print("Making a new map..."); MapGraph theMap = new MapGraph(); System.out.print("DONE. \nLoading the map..."); GraphLoader.loadRoadMap("data/simpletest.map", theMap); System.out.println("DONE."); System.out.println("Num nodes: " + theMap.getNumVertices()); System.out.println("Num edges: " + theMap.getNumEdges()); List<GeographicPoint> route = theMap.bfs(new GeographicPoint(1.0,1.0), new GeographicPoint(8.0,-1.0)); System.out.println(route); */ MapGraph theMap = new MapGraph(); System.out.print("DONE. \nLoading the map..."); GraphLoader.loadRoadMap("data/maps/utc.map", theMap); System.out.println("DONE."); GeographicPoint start = new GeographicPoint(32.8648772, -117.2254046); GeographicPoint end = new GeographicPoint(32.8660691, -117.217393); // List<GeographicPoint> route = theMap.dijkstra(start,end); List<GeographicPoint> route = theMap.dijkstra(start, end); List<GeographicPoint> route2 = theMap.aStarSearch(start, end); System.out.println(route); System.out.println(route2); /* Use this code in Week 3 End of Week Quiz MapGraph theMap = new MapGraph(); System.out.print("DONE. \nLoading the map..."); GraphLoader.loadRoadMap("data/maps/utc.map", theMap); System.out.println("DONE."); GeographicPoint start = new GeographicPoint(32.868629, -117.215393); GeographicPoint end = new GeographicPoint(32.868629, -117.215393); List<GeographicPoint> route = theMap.dijkstra(start,end); List<GeographicPoint> route2 = theMap.aStarSearch(start,end); */ }
/** * Compare the user's result with the right answer. * * @param i The graph number * @param result The user's graph * @param corr The correct answer * @param start The point to start from * @param end The point to end at */ public void judge( int i, MapGraph result, CorrectAnswer corr, GeographicPoint start, GeographicPoint end) { // Correct if paths are same length and have the same elements feedback += appendFeedback( i, "Running Dijkstra's algorithm from (" + start.getX() + ", " + start.getY() + ") to (" + end.getX() + ", " + end.getY() + ")"); List<GeographicPoint> path = result.dijkstra(start, end); if (path == null) { if (corr.path == null) { feedback += "PASSED."; correct++; } else { feedback += "FAILED. Your implementation returned null; expected \n" + printPath(corr.path) + "."; } } else if (path.size() != corr.path.size() || !corr.path.containsAll(path)) { feedback += "FAILED. Expected: \n" + printPath(corr.path) + "Got: \n" + printPath(path); if (path.size() != corr.path.size()) { feedback += "Your result has size " + path.size() + "; expected " + corr.path.size() + "."; } else { feedback += "Correct size, but incorrect path."; } } else { feedback += "PASSED."; correct++; } }