This blocking flow algorithms builds a layered graph according to breadth-first search distance from the target node in the reversed residual graph. The layered graph contains each residual edge which steps one level down. After that the algorithm constructs a blocking flow on the layered graph and augments the overall flow with it. The number of the levels in the layered graph is strictly increasing in each augmenting phase therefore the number of the augmentings is at most . The length of each phase is at most , that the overall time complexity is .
_Graph | The directed graph type the algorithm runs on. | |
_CapacityMap | The capacity map type. | |
_Traits | Traits class to set various data types used by the algorithm. The default traits class is DinitzSleatorTarjanDefaultTraits. See DinitzSleatorTarjanDefaultTraits for the documentation of a Dinitz-Sleator-Tarjan traits class. |
#include <lemon/dinitz_sleator_tarjan.h>
Classes | |
struct | DefFlowMap |
class | InvalidArgument |
Public Member Functions | |
DinitzSleatorTarjan (const Graph &graph, const CapacityMap &capacity, Node source, Node target) | |
The constructor of the class. | |
~DinitzSleatorTarjan () | |
Destrcutor. | |
DinitzSleatorTarjan & | capacityMap (const CapacityMap &map) |
Sets the capacity map. | |
DinitzSleatorTarjan & | flowMap (FlowMap &map) |
Sets the flow map. | |
const FlowMap & | flowMap () |
Returns the flow map. | |
DinitzSleatorTarjan & | source (const Node &node) |
Sets the source node. | |
DinitzSleatorTarjan & | target (const Node &node) |
Sets the target node. | |
DinitzSleatorTarjan & | tolerance (const Tolerance &tolerance) const |
const Tolerance & | tolerance () const |
Execution control The simplest way to execute the | |
void | init () |
Initializes the algorithm. | |
template<typename FlowMap > | |
void | flowInit (const FlowMap &flowMap) |
Initializes the algorithm. | |
template<typename FlowMap > | |
bool | checkedFlowInit (const FlowMap &flowMap) |
Initializes the algorithm. | |
void | start () |
Executes the algorithm. | |
bool | augment () |
Augments the flow with a blocking flow on a layered graph. | |
void | run () |
runs the algorithm. | |
Query Functions | |
Value | flowValue () const |
Returns the value of the maximum flow. | |
Value | flow (const Edge &edge) const |
Returns the flow on the edge. | |
bool | minCut (const Node &node) const |
Returns true when the node is on the source side of minimum cut. | |
template<typename CutMap > | |
void | minCutMap (CutMap &cutMap) const |
Returns a minimum value cut. |
DinitzSleatorTarjan | ( | const Graph & | graph, | |
const CapacityMap & | capacity, | |||
Node | source, | |||
Node | target | |||
) | [inline] |
The constructor of the class.
graph | The directed graph the algorithm runs on. | |
capacity | The capacity of the edges. | |
source | The source node. | |
target | The target node. |
~DinitzSleatorTarjan | ( | ) | [inline] |
Destructor.
DinitzSleatorTarjan& capacityMap | ( | const CapacityMap & | map | ) | [inline] |
Sets the capacity map.
(*this) DinitzSleatorTarjan& flowMap | ( | FlowMap & | map | ) | [inline] |
Sets the flow map.
(*this) const FlowMap& flowMap | ( | ) | [inline] |
DinitzSleatorTarjan& source | ( | const Node & | node | ) | [inline] |
Sets the source node.
(*this) DinitzSleatorTarjan& target | ( | const Node & | node | ) | [inline] |
Sets the target node.
(*this) DinitzSleatorTarjan& tolerance | ( | const Tolerance & | tolerance | ) | const [inline] |
Sets the tolerance used by algorithm.
const Tolerance& tolerance | ( | ) | const [inline] |
Returns the tolerance used by algorithm.
void init | ( | ) | [inline] |
It sets the flow to empty flow.
void flowInit | ( | const FlowMap & | flowMap | ) | [inline] |
Initializes the flow to the flowMap
. The flowMap
should contain a feasible flow, ie. in each node excluding the source and the target the incoming flow should be equal to the outgoing flow.
bool checkedFlowInit | ( | const FlowMap & | flowMap | ) | [inline] |
Initializes the flow to the flowMap
. The flowMap
should contain a feasible flow, ie. in each node excluding the source and the target the incoming flow should be equal to the outgoing flow.
void start | ( | ) | [inline] |
It runs augmenting phases by adding blocking flow until the optimal solution is reached.
bool augment | ( | ) | [inline] |
This function builds a layered graph and then find a blocking flow on this graph. The number of the levels in the layered graph is strictly increasing in each augmenting phase therefore the number of the augmentings is at most . The length of each phase is at most , that the overall time complexity is .
void run | ( | ) | [inline] |
It is just a shorthand for:
ek.init(); ek.start();
Value flowValue | ( | ) | const [inline] |
Returns the value of the maximum flow by returning the excess of the target node t
. This value equals to the value of the maximum flow already after the first phase.
Value flow | ( | const Edge & | edge | ) | const [inline] |
Sets the flowMap
to the flow on the edges. This method can be called after the second phase of algorithm.
bool minCut | ( | const Node & | node | ) | const [inline] |
Returns true when the node is on the source side of minimum cut. This method can be called both after running startFirstPhase() and startSecondPhase().
void minCutMap | ( | CutMap & | cutMap | ) | const [inline] |
Sets cut
to the characteristic vector of a minimum value cut It simply calls the minMinCut member.
cut | Write node bool map. |