V
- the graph vertex typeE
- the graph edge typepublic abstract class MaximumFlowAlgorithmBase<V,E> extends Object implements MaximumFlowAlgorithm<V,E>, MinimumSTCutAlgorithm<V,E>
MaximumFlowAlgorithm.MaximumFlow<E>, MaximumFlowAlgorithm.MaximumFlowImpl<E>
FlowAlgorithm.Flow<E>, FlowAlgorithm.FlowImpl<E>
Modifier and Type | Field and Description |
---|---|
protected Comparator<Double> |
comparator |
protected Set<E> |
cutEdges |
static double |
DEFAULT_EPSILON
Default tolerance.
|
protected boolean |
directedGraph |
protected ExtensionManager<E,? extends org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.AnnotatedFlowEdge> |
edgeExtensionManager |
protected Map<E,Double> |
maxFlow |
protected double |
maxFlowValue |
protected Graph<V,E> |
network |
protected V |
sink |
protected Set<V> |
sinkPartition |
protected V |
source |
protected Set<V> |
sourcePartition |
protected ExtensionManager<V,? extends org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.VertexExtensionBase> |
vertexExtensionManager |
Constructor and Description |
---|
MaximumFlowAlgorithmBase(Graph<V,E> network,
double epsilon)
Construct a new maximum flow
|
Modifier and Type | Method and Description |
---|---|
double |
calculateMinCut(V source,
V sink)
Computes a minimum capacity $s-t$ cut.
|
protected void |
calculateSourcePartition()
Calculate the set of reachable vertices from $s$ in the residual graph.
|
protected Map<E,Double> |
composeFlow()
Create a map which specifies for each edge in the input map the amount of flow that flows
through it
|
V |
getCurrentSink()
Returns current sink vertex, or null if there was no
calculateMaximumFlow calls.
|
V |
getCurrentSource()
Returns current source vertex, or null if there was no
calculateMaximumFlow calls.
|
double |
getCutCapacity()
Returns the capacity of the cut obtained after the last invocation of
MinimumSTCutAlgorithm.calculateMinCut(Object, Object) |
Set<E> |
getCutEdges()
Returns the set of edges which run from $S$ to $T$, in the $s-t$ cut obtained after the last
invocation of
MinimumSTCutAlgorithm.calculateMinCut(Object, Object) In case of a directed graph, only the
edges with their tail in $S$ and their head in $T$ are returned. |
V |
getFlowDirection(E e)
Returns the direction of the flow on an edge $(u,v)$.
|
Map<E,Double> |
getFlowMap()
Returns maximum flow, that was calculated during last
calculateMaximumFlow call, or null, if there was no
calculateMaximumFlow calls.
|
double |
getMaximumFlowValue()
Returns maximum flow value, that was calculated during last
calculateMaximumFlow call.
|
Set<V> |
getSinkPartition()
Returns the sink partition $T$, $t \in T$, of the cut obtained after the last invocation of
MinimumSTCutAlgorithm.calculateMinCut(Object, Object) |
Set<V> |
getSourcePartition()
Returns the source partition $S$, $s \in S$, of the cut obtained after the last invocation of
MinimumSTCutAlgorithm.calculateMinCut(Object, Object) |
protected <VE extends org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.VertexExtensionBase> |
init(V source,
V sink,
ExtensionFactory<VE> vertexExtensionFactory,
ExtensionFactory<org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.AnnotatedFlowEdge> edgeExtensionFactory)
Prepares all data structures to start a new invocation of the Maximum Flow or Minimum Cut
algorithms
|
protected void |
pushFlowThrough(org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.AnnotatedFlowEdge edge,
double flow)
Increase flow in the direction denoted by edge $(u,v)$.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getMaximumFlow, getMaximumFlowValue
getFlow
public static final double DEFAULT_EPSILON
protected final boolean directedGraph
protected Comparator<Double> comparator
protected ExtensionManager<V,? extends org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.VertexExtensionBase> vertexExtensionManager
protected ExtensionManager<E,? extends org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.AnnotatedFlowEdge> edgeExtensionManager
protected V source
protected V sink
protected double maxFlowValue
protected <VE extends org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.VertexExtensionBase> void init(V source, V sink, ExtensionFactory<VE> vertexExtensionFactory, ExtensionFactory<org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.AnnotatedFlowEdge> edgeExtensionFactory)
VE
- vertex extension typesource
- sourcesink
- sinkvertexExtensionFactory
- vertex extension factoryedgeExtensionFactory
- edge extension factoryprotected void pushFlowThrough(org.jgrapht.alg.flow.MaximumFlowAlgorithmBase.AnnotatedFlowEdge edge, double flow)
edge
- desired direction in which the flow is increasedflow
- increase of flow in the the direction indicated by the forwardEdgeprotected Map<E,Double> composeFlow()
public V getCurrentSource()
public V getCurrentSink()
public double getMaximumFlowValue()
public Map<E,Double> getFlowMap()
getFlowMap
in interface FlowAlgorithm<V,E>
public V getFlowDirection(E e)
getFlowDirection
in interface FlowAlgorithm<V,E>
e
- edgepublic double calculateMinCut(V source, V sink)
MinimumSTCutAlgorithm
calculateMinCut
in interface MinimumSTCutAlgorithm<V,E>
source
- ssink
- tpublic double getCutCapacity()
MinimumSTCutAlgorithm
MinimumSTCutAlgorithm.calculateMinCut(Object, Object)
getCutCapacity
in interface MinimumSTCutAlgorithm<V,E>
public Set<V> getSourcePartition()
MinimumSTCutAlgorithm
MinimumSTCutAlgorithm.calculateMinCut(Object, Object)
getSourcePartition
in interface MinimumSTCutAlgorithm<V,E>
public Set<V> getSinkPartition()
MinimumSTCutAlgorithm
MinimumSTCutAlgorithm.calculateMinCut(Object, Object)
getSinkPartition
in interface MinimumSTCutAlgorithm<V,E>
public Set<E> getCutEdges()
MinimumSTCutAlgorithm
MinimumSTCutAlgorithm.calculateMinCut(Object, Object)
In case of a directed graph, only the
edges with their tail in $S$ and their head in $T$ are returned. In cased of a undirected
graph, all edges with one endpoint in $S$ and one endpoint in $T$ are returned.getCutEdges
in interface MinimumSTCutAlgorithm<V,E>
protected void calculateSourcePartition()
Copyright © 2019. All rights reserved.