Skip to main content

Module k_shortest

Module k_shortest 

Source
Expand description

The K shortest loopless paths between two vertices by Yen’s algorithm (SciPy’s yen).

See the book entry Matchings, k shortest paths and Laplacians.

Functions§

yen
The k shortest loopless paths from source to sink, shortest first, as (length, vertices) (SciPy’s yen). Yen’s algorithm takes each path found so far and, for every vertex on it (the spur), finds the shortest path from the spur that leaves the common prefix differently from every path already found, avoiding the prefix’s vertices; the best of these candidates is the next path. Weights must be non-negative. Fewer than k paths are returned if fewer exist.