Package org.graph4j.flow
Class EdmondsKarpMaximumFlow
java.lang.Object
org.graph4j.flow.MaximumFlowBase
org.graph4j.flow.EdmondsKarpMaximumFlow
- All Implemented Interfaces:
MaximumFlowAlgorithm
The Edmonds–Karp algorithm is an implementation of the Ford–Fulkerson method
for computing the maximum flow in a network. The algorithm finds shortest
augmenting paths (in terms of the number of edges) using Breadth-First Search
(BFS).
The time complexity of the algorithm is min(O(nmU),O(n m2), where
n is the number of vertices, m is the number of edges and
U is an upper bound of edge capacities.
- Author:
- Cristian Frăsinaru
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean[]protected int[]protected VertexQueueprotected double[]protected boolean[]Fields inherited from class org.graph4j.flow.MaximumFlowBase
computed, cutEdges, ekAlg, graph, initialFlow, numVertices, sink, sinkIndex, sinkPart, source, sourceIndex, sourcePart -
Constructor Summary
ConstructorsConstructorDescriptionEdmondsKarpMaximumFlow(Network graph) EdmondsKarpMaximumFlow(Network graph, FlowData initialFlow) -
Method Summary
Modifier and TypeMethodDescriptionvoidMethods inherited from class org.graph4j.flow.MaximumFlowBase
getFlowValue, getMaximumFlowData, getMaximumFlowValue, getMinimumCutEdges, initFlowMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.graph4j.flow.MaximumFlowAlgorithm
getFlowValue
-
Field Details
-
visited
protected boolean[] visited -
forward
protected boolean[] forward -
parent
protected int[] parent -
residual
protected double[] residual -
queue
-
-
Constructor Details
-
EdmondsKarpMaximumFlow
-
EdmondsKarpMaximumFlow
-
-
Method Details
-
computeMaximumFlow
public void computeMaximumFlow()- Specified by:
computeMaximumFlowin classMaximumFlowBase
-
getSourcePart
- Specified by:
getSourcePartin interfaceMaximumFlowAlgorithm- Overrides:
getSourcePartin classMaximumFlowBase- Returns:
- the partition set of a minimum cut containing the source vertex.
-
getSinkPart
- Specified by:
getSinkPartin interfaceMaximumFlowAlgorithm- Overrides:
getSinkPartin classMaximumFlowBase- Returns:
- the partition set of a minimum cut containing the sink vertex.
-