org.jgrapht.alg.flow
Class PushRelabelMFImpl<V,E>
- java.lang.Object
-
- org.jgrapht.alg.flow.MaximumFlowAlgorithmBase<V,E>
-
- org.jgrapht.alg.flow.PushRelabelMFImpl<V,E>
-
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
- MaximumFlowAlgorithm<V,E>, MinimumSTCutAlgorithm<V,E>
public class PushRelabelMFImpl<V,E> extends MaximumFlowAlgorithmBase<V,E>
Push-relabel maximum flow algorithm designed by Andrew V. Goldberg and Robert Tarjan. Current implementation complexity upper-bound is O(V^3). For more details see: "A new approach to the maximum flow problem" by Andrew V. Goldberg and Robert Tarjan STOC '86: Proceedings of the eighteenth annual ACM symposium on Theory of computing
This class can also computes minimum s-t cuts. Effectively, to compute a minimum s-t cut, the implementation first computes a minimum s-t flow, after which a BFS is run on the residual graph.
Note: even though the algorithm accepts any kind of graph, currently only Simple directed and undirected graphs are supported (and tested!).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description classPushRelabelMFImpl.VertexExtensionVertex extension for the push-relabel algorithm, which contains an additional label.-
Nested classes/interfaces inherited from interface org.jgrapht.alg.interfaces.MaximumFlowAlgorithm
MaximumFlowAlgorithm.MaximumFlow<E>, MaximumFlowAlgorithm.MaximumFlowImpl<E>
-
-
Field Summary
-
Fields inherited from class org.jgrapht.alg.flow.MaximumFlowAlgorithmBase
DEFAULT_EPSILON
-
-
Constructor Summary
Constructors Constructor and Description PushRelabelMFImpl(Graph<V,E> network)Construct a new push-relabel algorithm.PushRelabelMFImpl(Graph<V,E> network, double epsilon)Construct a new push-relabel algorithm.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublecalculateMaximumFlow(V source, V sink)Sets current source to source, current sink to sink, then calculates maximum flow from source to sink.MaximumFlowAlgorithm.MaximumFlow<E>getMaximumFlow(V source, V sink)Sets current source to source, current sink to sink, then calculates maximum flow from source to sink.voidinitialize(PushRelabelMFImpl.VertexExtension source, PushRelabelMFImpl.VertexExtension sink, java.util.Queue<PushRelabelMFImpl.VertexExtension> active)Initialization-
Methods inherited from class org.jgrapht.alg.flow.MaximumFlowAlgorithmBase
calculateMinCut, getCurrentSink, getCurrentSource, getCutCapacity, getCutEdges, getFlowDirection, getFlowMap, getMaximumFlowValue, getSinkPartition, getSourcePartition
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jgrapht.alg.interfaces.MaximumFlowAlgorithm
buildMaximumFlow
-
-
-
-
Constructor Detail
-
PushRelabelMFImpl
public PushRelabelMFImpl(Graph<V,E> network)
Construct a new push-relabel algorithm.- Parameters:
network- the network
-
-
Method Detail
-
initialize
public void initialize(PushRelabelMFImpl.VertexExtension source, PushRelabelMFImpl.VertexExtension sink, java.util.Queue<PushRelabelMFImpl.VertexExtension> active)
Initialization- Parameters:
source- the sourcesink- the sinkactive- resulting queue with all active vertices
-
getMaximumFlow
public MaximumFlowAlgorithm.MaximumFlow<E> getMaximumFlow(V source, V sink)
Description copied from interface:MaximumFlowAlgorithmSets current source to source, current sink to sink, then calculates maximum flow from source to sink. Returns an object containing detailed information about the flow.- Parameters:
source- source of the flow inside the networksink- sink of the flow inside the network- Returns:
- maximum flow
-
calculateMaximumFlow
public double calculateMaximumFlow(V source, V sink)
Sets current source to source, current sink to sink, then calculates maximum flow from source to sink. Note, that source and sink must be vertices of the network passed to the constructor, and they must be different.- Parameters:
source- source vertexsink- sink vertex- Returns:
- the value of the maximum flow
-
-
DataMelt 3.0 © DataMelt by jWork.ORG