Class EdmondsKarpMaxFlow<V,E>
java.lang.Object
edu.uci.ics.jung.algorithms.util.IterativeProcess
edu.uci.ics.jung.algorithms.flows.EdmondsKarpMaxFlow<V,E>
- All Implemented Interfaces:
IterativeContext
Implements the Edmonds-Karp maximum flow algorithm for solving the maximum flow problem.
After the algorithm is executed,
the input
Map is populated with a Number for each edge that indicates
the flow along that edge.
An example of using this algorithm is as follows:
EdmondsKarpMaxFlow ek = new EdmondsKarpMaxFlow(graph, source, sink, edge_capacities, edge_flows, edge_factory); ek.evaluate(); // This instructs the class to compute the max flow
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.google.common.base.Supplier<E> private DirectedGraph<V, E> private intprivate DirectedGraph<V, E> private Vprivate V -
Constructor Summary
ConstructorsConstructorDescriptionEdmondsKarpMaxFlow(DirectedGraph<V, E> directedGraph, V source, V sink, com.google.common.base.Function<E, Number> edgeCapacityTransformer, Map<E, Number> edgeFlowMap, com.google.common.base.Supplier<E> edgeFactory) Constructs a new instance of the algorithm solver for a given graph, source, and sink. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidprotected voidPerform eventual clean-up operations (must be implement by subclass when needed).intprotected booleanprotected voidInitializes internal parameters to start the iterative process.voidstep()Evaluate the result of the current iteration.private voidMethods inherited from class IterativeProcess
done, evaluate, getDesiredPrecision, getIterations, getMaximumIterations, getPrecision, hasConverged, relativePrecision, reset, setDesiredPrecision, setMaximumIterations, setPrecision
-
Field Details
-
mFlowGraph
-
mOriginalGraph
-
source
-
target
-
mMaxFlow
private int mMaxFlow -
mSourcePartitionNodes
-
mSinkPartitionNodes
-
mMinCutEdges
-
residualCapacityMap
-
parentMap
-
parentCapacityMap
-
edgeCapacityTransformer
-
edgeFlowMap
-
edgeFactory
-
-
Constructor Details
-
EdmondsKarpMaxFlow
public EdmondsKarpMaxFlow(DirectedGraph<V, E> directedGraph, V source, V sink, com.google.common.base.Function<E, Number> edgeCapacityTransformer, Map<E, Number> edgeFlowMap, com.google.common.base.Supplier<E> edgeFactory) Constructs a new instance of the algorithm solver for a given graph, source, and sink. Source and sink vertices must be elements of the specified graph, and must be distinct.- Parameters:
directedGraph- the flow graphsource- the source vertexsink- the sink vertexedgeCapacityTransformer- the Function that gets the capacity for each edge.edgeFlowMap- the map where the solver will place the value of the flow for each edgeedgeFactory- used to create new edge instances for backEdges
-
-
Method Details
-
clearParentValues
private void clearParentValues() -
hasAugmentingPath
protected boolean hasAugmentingPath() -
step
public void step()Description copied from class:IterativeProcessEvaluate the result of the current iteration.- Specified by:
stepin interfaceIterativeContext- Specified by:
stepin classIterativeProcess
-
computeMinCut
private void computeMinCut() -
getMaxFlow
public int getMaxFlow()- Returns:
- the value of the maximum flow from the source to the sink.
-
getNodesInSinkPartition
-
getNodesInSourcePartition
-
getMinCutEdges
-
getFlowGraph
- Returns:
- the graph for which the maximum flow is calculated.
-
initializeIterations
protected void initializeIterations()Description copied from class:IterativeProcessInitializes internal parameters to start the iterative process.- Overrides:
initializeIterationsin classIterativeProcess
-
finalizeIterations
protected void finalizeIterations()Description copied from class:IterativeProcessPerform eventual clean-up operations (must be implement by subclass when needed).- Overrides:
finalizeIterationsin classIterativeProcess
-
updateResidualCapacities
private void updateResidualCapacities()
-