Lab 11 - Dijkstra's Road Trip
Due: Monday, December 13, 2004 at 9:00 AM
Short Answers
Complete the following problems from the book and include your answers in the file README.lab11 that you will submit with the lab.
14.1, 14.2, 14.6, 14.8, 14.16
Lab Program
We looked at Dijkstra's Algoritm in class, and today we will try it out on some "real" problems. Recall that Dijkstra's Algorithm computes shortest path in a graph from a single-source to each reachable destination.
In the class shared directory under labs/dijkstra you will find a Java file, Dijkstra.java. This program implements Dijkstra's Algorithm. It reads data from a file whose name is provided as a command line argument. The file contains lines of the form
from_location to_location route_name distance
each of which describes a route from from_location to to_location via route_name over a distance distance.
The program reads in the data, creating a graph. It prompts the user for a start location and a destination location, then computes a solution and reports back the shortest path.
I also have included two data files: sc-map contains data about the Unified Science Center (minus Physics, for some reason), and interstate-highways contains data about roads in the United States.
What to Do
You may wish to break some of the provided code out into other methods or even other classes at this point. Since it is certainly possible to introduce bugs, you should test your program on several routes to make sure you get the same answers as the original program.
Modify your program to include a new command remove <place1> <place2> that removes the direct route between <place1> and <place2>. Keep in mind that this program uses a directed graph and that you want to avoid using the path in both directions after issuing this command.
Use this new feature to compute a new path that does not use I-70 between Indianapolis and St. Louis. What is the length of the new shortest path?
Map generated by http://www.randmcnally.com
Map generated by http://www.randmcnally.com
You understand that if you want this road to be built, you need to convince congressmen from states other than just Texas and Colorado to approve the funding. Use your program to find two paths which start and end in other states which would be shortened significantly by the construction of Interstate 32. The ends of your two paths should be in four different states. Include the paths both with and without Interstate 32.
What to Turn In
Turn in a file lab11.tar which contains README.lab11 in which you answer the questions above, and your version of Dijkstra.java that includes your enhancements.