Proofs: Highway hierarchies
These are the human proofs of Highway hierarchies, at full length.
The two-level highway query returns shortest paths full
This proof shows: correctness, termination.
Claim. Let all weights be nonnegative, let , and let radii and highway edges be as in lines L1 and L2. For all , the query returns , and when it is finite, a walk of that weight (a simple path when all weights are positive).
If the query returns 0 and , which is correct. Assume .
Step 1: neighborhoods are closed along shortest paths. If and is a vertex on a shortest - path, then (weights are nonnegative), so . Symmetrically, if and is on a shortest - path, then .
Step 2: each side is Dijkstra on a fixed graph. Let be the graph with all edges out of vertices of plus all highway edges. We claim the forward side runs Dijkstra's algorithm on from . It is a Dijkstra search, so when it scans , its label is at least (every label is the weight of a real path). If , then , so line L4 allows only highway edges at , the edges of . If , a shortest - path lies in by Step 1, all of whose out-edges are allowed; by induction over the scan order, as in the correctness of Dijkstra, when is scanned, so all its edges are allowed, again the edges of . (The induction: the vertices of are scanned in order of their distance, and each is relaxed from its predecessor on a shortest path, which is in and was scanned with its true distance.) So the forward side is Dijkstra on . In the same way, the backward side is Dijkstra from on the reverse of , the graph of all edges into vertices of plus all highway edges.
Step 3: a shortest path splits. Suppose and let be a shortest path. Let be the least index with ; it exists since . By Step 1, are all in , so the edges of after end in and lie in . Consider an edge with . If , the edge is in . Otherwise by Step 1 (applied to the prefix of up to , a shortest path), and since ; as is on the shortest - path , it is a highway edge by line L2, so it is in . Hence the prefix of up to is in , and the suffix from is in , so .
Step 4: the query. Every value given to is a label of one side plus a label of the other at the same vertex, the weight of an - walk in , so always. If there is no such walk, no meeting vertex is recorded, and the query returns . Otherwise let from Step 3. Suppose the query stops with . Then both least keys were at least and , so both Dijkstra searches had scanned with labels and (Step 2). At the later of the two scans, line L5 set , and never increases, a contradiction. So . Following the predecessors of the remembered vertex on both sides gives an - walk of weight at most the value of when it was set (labels only fall), hence exactly . (The two chains are each simple, coming from Dijkstra trees; if they share a vertex other than the meeting vertex, the result is a walk of that weight, which with positive weights cannot happen.)
Termination. Each side scans each vertex at most once and pushes one heap entry per relaxation, so the loop ends.