Shortest paths on adjacency lists #
An instance (Cslib.Algorithms.Dijkstra.ListInstance) is a directed graph on Fin n given by its
adjacency lists of (target, weight) pairs, with natural-number weights, and a source vertex. The
lists may repeat a pair of endpoints (parallel edges) and may contain self-loops. The instance
determines a weight-matrix instance of Cslib.Algorithms.Dijkstra.Instance that keeps, for each
pair of endpoints, the lightest of its edges (Cslib.Algorithms.Dijkstra.ListInstance.toInstance);
the distance is the distance of that instance Dijkstra
Cormen et al., Section 24.3.
Scanning the edges out of a vertex u in list order, and lowering the tentative distance of each
target v to that of u plus the weight, has the effect of relaxing u in the weight-matrix
instance (Cslib.Algorithms.Dijkstra.ListInstance.relaxEdges_eq_relax): the scan of all parallel
edges to v has the effect of the lightest one. Nothing here refers to a machine: the interface
client (CslibFrontier.Algorithms.Lean.Dijkstra.Client) uses this directly, and the word-RAM
statements (CslibFrontier.Algorithms.WordRAM.Dijkstra.HeapStatement) add the input words.
Main definitions #
Cslib.Algorithms.Dijkstra.ListInstance: a directed graph by adjacency lists, with a source.Cslib.Algorithms.Dijkstra.ListInstance.toInstance: its weight-matrix instance.Cslib.Algorithms.Dijkstra.ListInstance.dist: the shortest-path distance.Cslib.Algorithms.Dijkstra.ListInstance.relaxEdges: the tentative distance of a vertex after scanning a list of edges.
Main results #
Cslib.Algorithms.Dijkstra.ListInstance.lightest_eq_some_iff: the matrix entry of a pair of endpoints is the least weight of the edges between them.Cslib.Algorithms.Dijkstra.ListInstance.lightest_eq_none_iff: it is absent exactly when there is no such edge.Cslib.Algorithms.Dijkstra.ListInstance.toInstance_maxWeight_le: the largest weight of the matrix instance is at most the largest edge weight.Cslib.Algorithms.Dijkstra.ListInstance.relaxEdges_eq_relax: scanning the edges out ofurelaxes the tentative distances.
References #
The least weight of an edge from u to v, and none when there is no such edge.
The weight-matrix instance with the same vertices and source, whose entry for u and v is
the least weight of an edge from u to v. Keeping a lightest edge between each pair preserves
distances.
The shortest-path distance from u to v: the distance of the weight-matrix instance,
Cslib.Algorithms.Dijkstra.Instance.dist.
The largest edge weight, and 0 when there is no edge.
The largest weight of the weight-matrix instance is at most the largest edge weight.
Scanning the edges out of u relaxes the tentative distances: from tentative distances
D, scanning the list of u lowers the tentative distance of v to its relaxation in the
weight-matrix instance.