#include <lemon/min_cost_max_flow.h>
MinCostMaxFlow uses Preflow for finding the maximum flow value and NetworkSimplex for finding a minimum cost flow of that value. According to our benchmark tests Preflow is generally the most efficient algorithm for the maximum flow problem and NetworkSimplex is the most efficient for the minimum cost flow problem in LEMON.
Graph | The directed graph type the algorithm runs on. | |
CapacityMap | The type of the capacity (upper bound) map. | |
CostMap | The type of the cost (length) map. |
CapacityMap::Value
must be convertible to CostMap::Value
.CostMap::Value
must be signed type.Public Types | |
typedef Graph::template EdgeMap< Capacity > | FlowMap |
The type of the flow map. | |
typedef Graph::template NodeMap< Cost > | PotentialMap |
The type of the potential map. | |
Public Member Functions | |
MinCostMaxFlow (const Graph &graph, const CapacityMap &capacity, const CostMap &cost, Node s, Node t) | |
Constructor. | |
~MinCostMaxFlow () | |
Destructor. | |
MinCostMaxFlow & | flowMap (FlowMap &map) |
Sets the flow map. | |
MinCostMaxFlow & | potentialMap (PotentialMap &map) |
Sets the potential map. | |
Execution control | |
The only way to execute the algorithm is to call the run() function. | |
void | run () |
Runs the algorithm. | |
Query Functions | |
The result of the algorithm can be obtained using these functions. run() must be called before using them. | |
const FlowMap & | flowMap () const |
Returns a const reference to the edge map storing the found flow. | |
const PotentialMap & | potentialMap () const |
Returns a const reference to the node map storing the found potentials (the dual solution). | |
Capacity | flow (const Edge &edge) const |
Returns the flow on the given edge. | |
Cost | potential (const Node &node) const |
Returns the potential of the given node. | |
Cost | totalCost () const |
Returns the total cost of the found flow. |
MinCostMaxFlow | ( | const Graph & | graph, | |
const CapacityMap & | capacity, | |||
const CostMap & | cost, | |||
Node | s, | |||
Node | t | |||
) | [inline] |
Constructor.
graph | The directed graph the algorithm runs on. | |
capacity | The capacities (upper bounds) of the edges. | |
cost | The cost (length) values of the edges. | |
s | The source node. | |
t | The target node. |
MinCostMaxFlow& flowMap | ( | FlowMap & | map | ) | [inline] |
Sets the flow map.
(*this) MinCostMaxFlow& potentialMap | ( | PotentialMap & | map | ) | [inline] |
Sets the potential map.
(*this) void run | ( | ) | [inline] |
Runs the algorithm.
const FlowMap& flowMap | ( | ) | const [inline] |
Returns a const reference to the edge map storing the found flow.
const PotentialMap& potentialMap | ( | ) | const [inline] |
Returns a const reference to the node map storing the found potentials (the dual solution).
Capacity flow | ( | const Edge & | edge | ) | const [inline] |
Cost potential | ( | const Node & | node | ) | const [inline] |
Returns the potential of the given node.
Cost totalCost | ( | ) | const [inline] |
Returns the total cost of the found flow. The complexity of the function is .