Function pathfinding::directed::edmonds_karp::edmonds_karp[][src]

pub fn edmonds_karp<N, C, IC, EK>(
    vertices: &[N],
    source: &N,
    sink: &N,
    caps: IC
) -> EKFlows<N, C> where
    N: Eq + Hash + Copy,
    C: Zero + Bounded + Signed + Ord + Copy,
    IC: IntoIterator<Item = ((N, N), C)>,
    EK: EdmondsKarp<C>, 

Compute the maximum flow that can go through a directed graph using the Edmonds Karp algorithm.

A maximum flow going from source to sink will be computed, and the various flow values along with the total will be returned.

Note that the capacity type C must be signed as the algorithm has to deal with negative residual capacities.

By creating an EdmondsKarp structure, it is possible to adjust the capacities after computing the maximum flow and rerun the algorithm without starting from scratch. This function is a helper function that remaps the N node type to appropriate indices.

Panics

This function panics if source or sink is not found in vertices.