Documentation

CslibFrontier.Algorithms.ShortestPaths.Tripartite

The tripartite graph of a (min,+) product #

The (min,+) product A * B of two ι × ι matrices is a shortest-distance block of a graph with three copies of ι: tripartite A B on Fin 3 × ι has an edge (0, i) → (1, j) of weight A i j, an edge (1, j) → (2, k) of weight B j k and no other edges. Every walk with a finite weight climbs one layer per edge, so the graph has no cycles at all, hence no negative cycles, and the walks from (0, i) to (2, k) of finite weight are exactly the two-edge walks through some (1, j). Thus the shortest distance from (0, i) to (2, k) is (A * B) i k.

This is the reduction from (min,+) products to all-pairs shortest paths on 3 n vertices.

Main definitions #

Main results #

References #

def Cslib.Algorithms.ShortestPaths.tripartite {ι : Type u_2} {α : Type u_3} [Zero α] (A B : Matrix ι ι α) :
Matrix (Fin 3 × ι) (Fin 3 × ι) α

The tripartite graph on Fin 3 × ι of the (min,+) product A * B: edges (0, i) → (1, j) of weight A i j, edges (1, j) → (2, k) of weight B j k, and no others.

The tripartite graph has no negative cycles: its only closed walks of finite weight are the empty ones.

theorem Cslib.Algorithms.ShortestPaths.isGLB_tripartite {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {ι : Type u_2} [Fintype ι] (A B : Matrix ι ι (MinTropical R)) (i k : ι) :
IsGLB {x : MinTropical R | ∃ (l : List (Fin 3 × ι)), l.getLastD (0, i) = (2, k) ∧ walkWeight (tripartite A B) (0, i) l = x} ((A * B) i k)

In the tripartite graph, the shortest distance from (0, i) to (2, k) is the (min,+) product entry (A * B) i k.

theorem Cslib.Algorithms.ShortestPaths.IsShortestDistances.tripartite_block {R : Type u_1} [LinearOrderedAddCommMonoidWithTop R] {ι : Type u_2} [Fintype ι] {U : Type u_3} {A B : Matrix ι ι (MinTropical R)} (e : Fin 3 × ι ≃ U) {D : Matrix U U (MinTropical R)} (hD : IsShortestDistances ((tripartite A B).submatrix ⇑e.symm ⇑e.symm) D) (i k : ι) :
D (e (0, i)) (e (2, k)) = (A * B) i k

If D is the shortest-distance matrix of any relabelling e of the tripartite graph of A and B, then its block from layer 0 to layer 2 is the (min,+) product A * B.