Skip to main content

spfa_loop

Function spfa_loop 

Source
pub(crate) fn spfa_loop<G, F, K>(
    graph: G,
    distances: Vec<K>,
    predecessors: Option<Vec<Option<G::NodeId>>>,
    queue: VecDeque<G::NodeId>,
    in_queue: Vec<bool>,
    edge_cost: F,
) -> Result<(Vec<K>, Option<Vec<Option<G::NodeId>>>), NegativeCycle>
Expand description

The main cycle of the SPFA algorithm. Calculating the predecessors is optional.

The queue must be pre-initialized by at least one source node. The content of in_queue must match to queue.