You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mark Junker edited this page Jun 7, 2018
·
1 revision
The Edmond and Karp algorithm computes a maximum flow for directed graph with positive capacities and flows.
// we need a graph, a source and a sinkIMutableVertexAndEdgeListGraph<TVertex,TEdge>graph= ...;TVertexsource= ...;TVertexsink= ...;// A function with maps an edge to its capacityFunc<TEdge,double>capacityFunc=(edge =>1);// A function which takes a vertex and returns the edge connecting to its predecessor in the flow networkTryFunc<TVertex,TEdge>flowPredecessors;// A function used to create new edges during the execution of the algorithm. These edges are removed before the computation returnsEdgeFactory<TVertex,TEdge>edgeFactory=(source,target)=>newEdge<TVertex>(source,target);// computing the maximum flow using Edmonds Karp.doubleflow=AlgorithmExtensions.MaximumFlowEdmondsKarp<TVertex,TEdge>(graph,capacityFunc,source,sink,outflowPredecessors,edgeFactory);