public final class EdmondsKarpMaximumFlow<V,E> extends MaximumFlowAlgorithmBase<V,E>
This class computes maximum flow in a network using Edmonds-Karp algorithm. Be careful: for large networks this algorithm may consume significant amount of time (its upper-bound complexity is O(VE^2), where V - amount of vertices, E - amount of edges in the network).
For more details see Andrew V. Goldberg's Combinatorial Optimization (Lecture Notes).
MaximumFlowAlgorithm.MaximumFlow<V,E>, MaximumFlowAlgorithm.MaximumFlowImpl<V,E>
DEFAULT_EPSILON
Constructor and Description |
---|
EdmondsKarpMaximumFlow(DirectedGraph<V,E> network)
Constructs MaximumFlow instance to work with a copy of
network.
|
EdmondsKarpMaximumFlow(DirectedGraph<V,E> network,
double epsilon)
Constructs MaximumFlow instance to work with a copy of
network.
|
Modifier and Type | Method and Description |
---|---|
MaximumFlowAlgorithm.MaximumFlow<V,E> |
buildMaximumFlow(V source,
V sink)
Sets current source to source, current sink to sink,
then calculates maximum flow from source to sink.
|
protected org.jgrapht.alg.flow.EdmondsKarpMaximumFlow.EdgeExtension |
extendedEdge(E e) |
protected org.jgrapht.alg.flow.EdmondsKarpMaximumFlow.VertexExtension |
extendedVertex(V v) |
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.
|
compareFlowTo, composeFlow, edgeExtended, pushFlowThrough, vertexExtended
public EdmondsKarpMaximumFlow(DirectedGraph<V,E> network)
network
- network, where maximum flow will be calculatedpublic EdmondsKarpMaximumFlow(DirectedGraph<V,E> network, double epsilon)
network
- network, where maximum flow will be calculatedepsilon
- tolerance for comparing doublespublic MaximumFlowAlgorithm.MaximumFlow<V,E> buildMaximumFlow(V source, V sink)
source
- source vertexsink
- sink vertexprotected org.jgrapht.alg.flow.EdmondsKarpMaximumFlow.VertexExtension extendedVertex(V v)
protected org.jgrapht.alg.flow.EdmondsKarpMaximumFlow.EdgeExtension extendedEdge(E e)
public V getCurrentSource()
public V getCurrentSink()
Copyright © 2016. All rights reserved.