Package org.graph4j.flow
Class MaximumFlowBase
java.lang.Object
org.graph4j.flow.MaximumFlowBase
- All Implemented Interfaces:
MaximumFlowAlgorithm
- Direct Known Subclasses:
DinicMaximumFlow,EdmondsKarpMaximumFlow,PushRelabelMaximumFlow
- Author:
- Cristian Frăsinaru
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMaximumFlowBase(Network graph) Creates an algorithm for computing the maximum flow in a network.MaximumFlowBase(Network graph, FlowData initialFlow) Creates an algorithm for computing the maximum flow in a network, initializing the edge flows using the values in the specified ininitialFlow. -
Method Summary
Modifier and TypeMethodDescriptionabstract voiddoublegetFlowValue(int v, int u) Returns the value of the maximum flow on the specified edge.Creates a data structure storing the flow value for all edges.doubleReturns the value of the maximum flow of the network.protected voidinitFlow()Methods 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
-
graph
-
initialFlow
-
numVertices
protected final int numVertices -
source
protected int source -
sink
protected int sink -
sourceIndex
protected int sourceIndex -
sinkIndex
protected int sinkIndex -
computed
protected boolean computed -
sourcePart
-
sinkPart
-
cutEdges
-
ekAlg
-
-
Constructor Details
-
MaximumFlowBase
Creates an algorithm for computing the maximum flow in a network. If the network edges have flow values the algorithm will take them into account.- Parameters:
graph- the input network.
-
MaximumFlowBase
Creates an algorithm for computing the maximum flow in a network, initializing the edge flows using the values in the specified ininitialFlow.- Parameters:
graph- the input network.initialFlow- the initial flow.
-
-
Method Details
-
initFlow
protected void initFlow() -
getMaximumFlowValue
public double getMaximumFlowValue()Description copied from interface:MaximumFlowAlgorithmReturns the value of the maximum flow of the network.- Specified by:
getMaximumFlowValuein interfaceMaximumFlowAlgorithm- Returns:
- the maximum value of the flow.
-
getFlowValue
public double getFlowValue(int v, int u) Description copied from interface:MaximumFlowAlgorithmReturns the value of the maximum flow on the specified edge.- Specified by:
getFlowValuein interfaceMaximumFlowAlgorithm- Parameters:
v- a vertex number.u- a vertex number.- Returns:
- the maximum flow on (v,u) edge.
-
getMaximumFlowData
Description copied from interface:MaximumFlowAlgorithmCreates a data structure storing the flow value for all edges.- Specified by:
getMaximumFlowDatain interfaceMaximumFlowAlgorithm- Returns:
- a data structure storing the flow value for all edges.
-
getSourcePart
- Specified by:
getSourcePartin interfaceMaximumFlowAlgorithm- Returns:
- the partition set of a minimum cut containing the source vertex.
-
getSinkPart
- Specified by:
getSinkPartin interfaceMaximumFlowAlgorithm- Returns:
- the partition set of a minimum cut containing the sink vertex.
-
getMinimumCutEdges
- Specified by:
getMinimumCutEdgesin interfaceMaximumFlowAlgorithm- Returns:
- the edges of a minimum cut set.
-
computeMaximumFlow
public abstract void computeMaximumFlow()
-