Assignment 2
Assignment 2
One task that GPSs perform a lot is nding the shortest path between two points. The problem with this is that lots of people are using the same GPS, meaning that many people nd the same route, causing a lot of trafc on this route. You would like to nd the shortest path between two points that does not use any edges from the actual shortest path, because you would like to avoid the trafc but still use a short path. The easiest way to accomplish this is to nd the shortest path rst, and then remove all the edges that are on the shortest path. Then, in the new graph that has had some of its edges removed, perform the shortest path algorithm again, yielding the shortest path that does not use any edges from the original shortest path.
Input
You will be given input in the same form as Lab 17, except that the rst line will have three parameters - the number of vertices in the graph, the vertex we want to nd the shortest path from, and the vertex we want to nd the shortest path to. 11,0,7 0,1,20 0,5,10 1,2,5 1,5,11 1,6,5 6,2,5 2,7,10 2,3,50 3,8,9 4,5,12 5,6,30 6,7,4 7,8,4 5,9,16
Output
You must output a list of vertices dening the path from the source vertex to the target vertex. In the input given above, we are trying to nd the almost shortest path from vertex 0 to vertex 7. The algorithm should rst nd the path 0,5,10,6,7 as this is the shortest path in that graph (try to conrm this by hand). Then, it should remove all the edges on this path and rerun the shortest path algorithm, so that it ends up with the following output: 0 1 2 7