Proofs: Gabow's scaling algorithm
These are the human proofs of Gabow's scaling algorithm, at full length.
Gabow's scaling algorithm is correct full
This proof shows: correctness, termination.
Claim. Let every weight be an integer in , and let be the number of bits of ( if ). For , let and let be the distance from to under ( if does not reach ). After line L1, , and after the iteration of line L2, . Since , GABOW-SCALING returns for every . It ends after iterations.
Reachability does not depend on the weights, so for one exactly when it holds for all ; call the other vertices reachable. All weights are nonnegative integers, so there is no negative cycle, every for reachable is a nonnegative integer, and it is the weight of a simple path (deleting a cycle from a walk does not increase its weight).
Step 1: the rounding bounds. Write with . Then and with . So .
Step 2: scale 0. on every edge (every weight is below ), so for every reachable , and line L1 sets exactly this.
Step 3: the reduced lengths are nonnegative. Assume at the start of iteration . For an edge with reachable, is reachable too, and . With Step 1, . Edges out of unreachable vertices are never scanned in line L5, because such a vertex never gets a finite label.
Step 4: reduced distances. For a path from to a reachable , the potentials telescope: . So , where is the distance under .
Step 5: reduced distances are below . Let be a simple shortest path to under ; it has at most edges. By Step 1, . So , and by Step 4, .
Step 6: the sweep is exact. Line L5 is Dijkstra's algorithm with nonnegative integer lengths (Step 3), with the priority queue replaced by buckets swept in increasing order, except that a tentative label of or more is not recorded. We show that every reachable is scanned from bucket with label , by induction on and, for equal values, on the number of edges of a shortest -path with fewest edges. For , and starts in bucket 0. For , let be the vertex before on a shortest -path to with fewest edges. Then , and if equal, the path to has fewer edges. By induction, is scanned from bucket while the sweep is at level , and it offers the label , which is recorded unless the label is already at most that. Labels are always lengths of paths, so they are never below . So, from that moment on, the label of is and is in bucket , which the sweep reaches no earlier than now (the sweep is at level ). When the sweep reaches that bucket, is scanned with label , unless it was scanned earlier, which would require an earlier label equal to the level then, that is, a label below , impossible. A scanned vertex is not scanned again. So line L5 gives for every reachable , and the parent of is a vertex with .
Step 7: the update. Line L6 sets by Step 4, for every reachable , and leaves for the others. This completes the induction.
Parents. In the last sweep, the parent of satisfies , so by Step 4, ; such edges, one into each reachable , form a shortest-path tree (each parent was scanned before its child, so there is no cycle). When , all weights are 0 and the tree of line L1 is a shortest-path tree.
Termination. Line L1 is a finite search, the loop has iterations, and each sweep visits buckets, each holding finitely many entries.