Dijkstra’s Algorithm and Its Settling Invariant

Use a cut between settled and unsettled vertices to prove when a tentative nonnegative distance becomes final.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Tentative labels are lengths of known walks
  2. Nonnegative edges justify settling the minimum

Tentative labels are lengths of known walks

Start at the source with distance zero, infinity elsewhere. When a vertex is settled, relax each outgoing edge by comparing a known route through that vertex to the target’s current label. Use an indexed priority queue or heap entries with stale-value checks to choose the smallest unsettled finite label.

Nonnegative edges justify settling the minimum

Suppose the chosen vertex has a strictly shorter path. Look at the first unsettled vertex \(y\) on that path. Its preceding edge was relaxed, so its tentative label is at most the prefix cost to \(y\). Because all later edges are nonnegative, that prefix would be below the chosen label, a contradiction. Terminating when a target is settled is therefore correct. With edges \(s\to a\) of weight \(2\), \(s\to b\) of weight \(5\), and \(b\to a\) of weight \(-4\), this argument fails. Bellman–Ford can handle negative edges, and Johnson reweighting gives conditions for recovering nonnegative edge costs.[1][2]

References

  1. Jeff Erickson, Algorithms ↩
  2. MIT OpenCourseWare, Design and Analysis of Algorithms: Lecture Notes ↩