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.#include <lemon/min_cost_max_flow.h>
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) |
Set the flow map. | |
MinCostMaxFlow & | potentialMap (PotentialMap &map) |
Set the potential map. | |
Execution control | |
void | run () |
Query Functions | |
The results of the algorithm can be obtained using these functions. run() must be called before using them. | |
const FlowMap & | flowMap () const |
Return a const reference to the edge map storing the found flow. | |
const PotentialMap & | potentialMap () const |
Return a const reference to the node map storing the found potentials (the dual solution). | |
Capacity | flow (const Edge &edge) const |
Return the flow on the given edge. | |
Cost | potential (const Node &node) const |
Return the potential of the given node. | |
Cost | totalCost () const |
Return 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] |
Set the flow map.
(*this) MinCostMaxFlow& potentialMap | ( | PotentialMap & | map | ) | [inline] |
Set the potential map.
(*this) void run | ( | ) | [inline] |
Run the algorithm.
const FlowMap& flowMap | ( | ) | const [inline] |
Return a const reference to the edge map storing the found flow.
const PotentialMap& potentialMap | ( | ) | const [inline] |
Return 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] |
Return the potential of the given node.
Cost totalCost | ( | ) | const [inline] |
Return the total cost of the found flow. The complexity of the function is .