aryagraph.algorithms.paths.k_shortest_paths#

aryagraph.algorithms.paths.k_shortest_paths(g: Graph, source: Hashable, target: Hashable, k: int, weight: str | Callable[[Hashable, Hashable, dict], float] | None = 'weight') → list[list[Hashable]][source]#

The k shortest loopless paths from source to target (Yen’s algorithm).

Paths are returned shortest first (fewer than k if fewer exist); ties keep discovery order. Weights must be non-negative. Raises NoPath if target is unreachable. O(k·n·(m + n log n)).