next up previous contents
Next: Dijkstra's algorithm. Up: Graphs Previous: Exercises.   Contents

Shortest path between two vertices.

Suppose we are given a weighted digraph with vertices labelled by non-negative numbers. We want to answer the following question: Given two vertices, what is the shortest route from one to the other?

Here by ``shortest'' we mean a path which, when we add up the weights along its edges, gives the smallest weight for the path overall. This number is called the length of the path. Thus, a shortest path is one with minimal length. Note that there need not be a unique shortest path, since several paths might have the same length. In a disconnected graph there will not be a path between vertices in different components, but we can take care of this by using $ \infty$ once again to stand for ``no path at all''.

Notice that weights don't need to be distances; they can, for example, be time (in which case we could speak of ``quickest paths'') or money (in which case we could speak of ``cheapest paths''), among other possibilities. By considering ``abstract'' graphs in which the numerical weights are left uninterpreted, we can take care of all such situations and others. But notice that we do need to restrict to non-negative numbers, because if there are negative numbers and cycles, we can have paths with smaller and smaller lengths, but no path with minimal length.

Applications of shortest-path algorithms include train-ticket reservations, driving directions, internet packet routing (if you send an email message from your computer to someone else, it has to go through various computer routers, until it reaches it final destination).



Subsections
next up previous contents
Next: Dijkstra's algorithm. Up: Graphs Previous: Exercises.   Contents
Martin Escardo 2005-01-11