Skip to main content

yen

Function yen 

Source
pub fn yen(
    g: &Graph,
    source: usize,
    sink: usize,
    k: usize,
) -> Result<Vec<(f64, Vec<usize>)>, ErrorsJSL>
Expand description

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.