Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2
Maximum Flow
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);