Shortest distances as (min,+) matrix powers #
Over MinTropical R the matrix product is the (min,+) product, so (W ^ m) i j is the least
weight of a walk from i to j with exactly m edges, and ((1 + W) ^ k) i j is the least
weight of a walk with at most k edges. Without negative cycles a shortest walk can be taken
without repeated vertices, hence with at most card V - 1 edges: (1 + W) ^ k is the
shortest-distance matrix for every k ≥ card V - 1. The same powers detect negative cycles:
W has none iff the diagonal of (1 + W) ^ card V is at least the tropical one.
Without negative cycles 1 + W is withOneDiag W, the weight matrix with zero-weight loops,
which is the initial matrix of Floyd–Warshall and of repeated squaring.
Main definitions #
Cslib.Algorithms.ShortestPaths.withOneDiag:Wwith every diagonal entry replaced by1.
Main results #
Cslib.Algorithms.ShortestPaths.pow_apply_le_walkWeight,Cslib.Algorithms.ShortestPaths.exists_walk_of_pow:(W ^ m) i jis the least weight of a walk fromitojwithmedges.Cslib.Algorithms.ShortestPaths.one_add_pow_apply_le,Cslib.Algorithms.ShortestPaths.exists_walk_of_one_add_pow: the same for(1 + W) ^ kand walks with at mostkedges.Cslib.Algorithms.ShortestPaths.isShortestDistances_one_add_pow: without negative cycles,(1 + W) ^ kis the shortest-distance matrix for everyk ≥ card V - 1.Cslib.Algorithms.ShortestPaths.isShortestDistances_withOneDiag_pow: the same forwithOneDiag W.Cslib.Algorithms.ShortestPaths.noNegCycle_iff_one_le_one_add_pow_diag: negative-cycle detection, and aDecidablePred NoNegCycleinstance.
References #
W with every diagonal entry replaced by 1, the tropical 0: the matrix of W with a
zero-weight loop at every vertex.
Without negative cycles, adding the tropical identity replaces the diagonal by 1.
(W ^ m) i j is at most the weight of every walk from i to j with m edges.
(W ^ m) i j is 0 or the weight of a walk from i to j with m edges.
((1 + W) ^ k) i j is at most the weight of every walk from i to j with at most k
edges.
((1 + W) ^ k) i j is 0 or the weight of a walk from i to j with at most k edges.
Shortest distances as tropical powers. Without negative cycles, (1 + W) ^ k is the
shortest-distance matrix of W for every k ≥ card V - 1.
Without negative cycles the powers of 1 + W are constant from card V - 1 on.
Without negative cycles, withOneDiag W ^ k is the shortest-distance matrix of W for every
k ≥ card V - 1.
Negative-cycle detection. W has no negative cycles iff every diagonal entry of
(1 + W) ^ card V is at least 1, the tropical 0.