Next: Initialisation
Up: Shortest Paths in Weighted
Previous: Paths and lengths
  Index
Dijkstra's algorithm
We wish to find the shortest path from some node
to every other
node in the graph which is reachable from
. Let
be the set of
all nodes in the graph. Our aim is to determine (i) the subset
consisting of all nodes
which are reachable
from
and (ii) the function
, defined on
, such that, if
,
is the minimum of the lengths of paths from
to
, otherwise conventionally we set
. Initially we know only
that
and
.
The algorithm is iterative. At each stage we maintain two subsets of
nodes,
and
, satisfying
as pictured in Figure 13.2.
Figure 13.2:
Dijkstra's algorithm.
|
|
consists of those nodes which belong to
or are adjacent
to some node in
.
and
grow as the algorithm
proceeds. The algorithm terminates when
.
We assume that a function
is defined for all
satisfying:
- A1:
- if
, then
;
- A2:
- if
, then there is an
-path from
to
and
is the minimum length of all such paths
where an
-path is defined to be one which only visits nodes in
before finally jumping to
. Note that
will change as
grows. A1 asserts that
gives the correct final
answer on
. The values of
that may change are the
provisional ones defined on
.
Subsections
Next: Initialisation
Up: Shortest Paths in Weighted
Previous: Paths and lengths
  Index
Peter Williams
2005-06-07