CMPS 144L Spring 2019
Lab #7 (Week of Oct 7)
Shortest Paths in a Directed Graph

You are given the following files:

You should be familiar with the queue-related Java source code files, but you should spend some time examining each of the others so that you come to understand each one's purpose.

Your task is to complete the PathFinder class, two of whose methods are unfinished: path() and findShortestPath(). You can use the length() method for ideas on how to complete the former. As for the latter, you should use as a model the algorithm for the Uniform-Cost Single Source Shortest Paths Problem, as covered in lecture.

However, keep in mind that your findShortestPath() method is solving a slightly different problem: It is attempting to find a shortest path connecting a start vertex to just one target vertex (as opposed to all vertices being, in effect, targets). Hence, the method should be written so that, once it "discovers" the target vertex, it quickly finishes, there being no need to discover any others.

For the purpose of iterating through all the outgoing edges of the vertex being "explored", you are encouraged to make use of either the neighborIterator() or neighbors() method in Digraph rather than the hasEdge() method.


Submit your PathFinder.java file to the Lab #7 folder.