V
- the graph vertex typeE
- the graph edge typepublic 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!).Modifier and Type | Class and Description |
---|---|
class |
PushRelabelMFImpl.VertexExtension
Vertex extension for the push-relabel algorithm, which contains an additional label.
|
MaximumFlowAlgorithm.MaximumFlow<E>, MaximumFlowAlgorithm.MaximumFlowImpl<E>
comparator, cutEdges, DEFAULT_EPSILON, directed_graph, edgeExtensionManager, maxFlow, maxFlowValue, network, sink, sinkPartition, source, sourcePartition, vertexExtensionManager
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.
|
Modifier and Type | Method and Description |
---|---|
double |
calculateMaximumFlow(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.
|
void |
initialize(PushRelabelMFImpl.VertexExtension source,
PushRelabelMFImpl.VertexExtension sink,
Queue<PushRelabelMFImpl.VertexExtension> active)
Initialization
|
protected void |
pushFlowThrough(org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.AnnotatedFlowEdge ex,
double f)
Push flow through an edge.
|
calculateMinCut, calculateSourcePartition, composeFlow, getCurrentSink, getCurrentSource, getCutCapacity, getCutEdges, getFlowDirection, getFlowMap, getMaximumFlowValue, getSinkPartition, getSourcePartition, init
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
buildMaximumFlow
public PushRelabelMFImpl(Graph<V,E> network)
network
- the networkpublic void initialize(PushRelabelMFImpl.VertexExtension source, PushRelabelMFImpl.VertexExtension sink, Queue<PushRelabelMFImpl.VertexExtension> active)
source
- the sourcesink
- the sinkactive
- resulting queue with all active verticespublic MaximumFlowAlgorithm.MaximumFlow<E> getMaximumFlow(V source, V sink)
MaximumFlowAlgorithm
source
- source of the flow inside the networksink
- sink of the flow inside the networkpublic double calculateMaximumFlow(V source, V sink)
source
- source vertexsink
- sink vertexprotected void pushFlowThrough(org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.AnnotatedFlowEdge ex, double f)
pushFlowThrough
in class MaximumFlowAlgorithmBase<V,E>
ex
- the edgef
- the amount of flow to push throughCopyright © 2017. All rights reserved.