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 implementation is based on On Implementing the Push—Relabel Method for the Maximum Flow Problem by B. V. Cherkassky and A.V. Goldberg (Cherkassky, B. & Goldberg, A. Algorithmica (1997) 19: 390. https://doi.org/10.1007/PL00009180) and Introduction to Algorithms (3rd Edition).
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 height.
|
MaximumFlowAlgorithm.MaximumFlow<E>, MaximumFlowAlgorithm.MaximumFlowImpl<E>
FlowAlgorithm.Flow<E>, FlowAlgorithm.FlowImpl<E>
Modifier and Type | Field and Description |
---|---|
static boolean |
USE_GAP_RELABELING_HEURISTIC |
static boolean |
USE_GLOBAL_RELABELING_HEURISTIC |
cutEdges, DEFAULT_EPSILON, directedGraph, 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
getMaximumFlowValue
getFlow
public static boolean USE_GLOBAL_RELABELING_HEURISTIC
public static boolean USE_GAP_RELABELING_HEURISTIC
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 © 2019. All rights reserved.