Shortest Path Home
filename:
home
You are excited that you’ve finally learned how to calculate the shortest distances on a map in
your Computer Science II class. Now, you want to see if you can apply that knowledge to help
you save time.
The Problem:
Given a list of intersection points, and the distances between each of those intersection points
(when riding your bike), determine the shortest distance and path from the intersection
designated as your house to another desired intersection. If there are multiple shortest paths, you
must take the one that has the fewest edges. You are guaranteed that none of the input maps will
have multiple shortest paths with the minimum number of edges.
The Input:
There will be maps (test cases) in the input file.
The first input line contains a positive integer
n
,
indicating the number of maps to be processed.
Each map follows. The first line describing a
map contains a single positive integer,
k
, indicating the number of intersection points in the
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '09
 Computer Science, Graph Theory, Shortest path problem

Click to edit the document details