Documentation

CslibFrontier.Algorithms.Dijkstra.Defs

The single-source shortest-path problem #

This file defines the single-source shortest-path problem solved by Dijkstra's algorithm Dijkstra Cormen et al., Section 24.3. Nothing here refers to a machine: the word-RAM statements (CslibFrontier.Algorithms.WordRAM.Dijkstra.HeapStatement) and the interface client (CslibFrontier.Algorithms.Lean.Dijkstra.Client) both import it.

An instance (Cslib.Algorithms.Dijkstra.Instance) is a directed graph on Fin n with natural-number edge weights, given by its weight matrix, and a source vertex. The distance Cslib.Algorithms.Dijkstra.Instance.dist is the infimum, in ℕ∞, of the weights of the paths (Quiver.Path, Quiver.Path.addWeight) between two vertices; it is ⊤ when there is no path.

Main definitions #

Main results #

References #

An instance of the single-source shortest-path problem: a directed graph on Fin n with natural-number edge weights, given by its weight matrix, and a source vertex. The entry weight u v is some c for an edge from u to v of weight c, and none for no edge.

  • n : ℕ

    The number of vertices.

  • weight : Fin self.n → Fin self.n → Option ℕ

    The weight matrix.

  • source : Fin self.n

    The source.

The vertices of an instance, as a quiver: an arrow from u to v is a weight c with I.weight u v = some c, so there is at most one.

Instances For

    The weight of an arrow.

    noncomputable def Cslib.Algorithms.Dijkstra.Instance.dist (I : Instance) (u v : Fin I.n) :

    The shortest-path distance from u to v: the infimum of the weights of the paths from u to v, and ⊤ when there is none.

    Every vertex is at distance 0 from itself, by the empty path.

    The largest edge weight, and 0 when there is no edge.