MinCostFlow Class Template Reference
[Path and Flow Algorithms]

#include <min_cost_flow.h>

Inheritance diagram for MinCostFlow:

Inheritance graph
[legend]
List of all members.

Detailed Description

template<typename Graph, typename LengthMap, typename CapacityMap>
class lemon::MinCostFlow< Graph, LengthMap, CapacityMap >

The class MinCostFlow implements an algorithm for finding a flow of value k having minimal total cost from a given source node to a given target node in an edge-weighted directed graph. To this end, the edge-capacities and edge-weitghs have to be nonnegative. The edge-capacities should be integers, but the edge-weights can be integers, reals or of other comparable numeric type. This algorithm is intended to use only for small values of k, since it is only polynomial in k, not in the length of k (which is log k). In order to find the minimum cost flow of value k it finds the minimum cost flow of value i for every i between 0 and k.

Parameters:
Graph The directed graph type the algorithm runs on.
LengthMap The type of the length map.
CapacityMap The capacity map type.
Author:
Attila Bernath

Definition at line 60 of file min_cost_flow.h.

Public Member Functions

 MinCostFlow (Graph &_G, LengthMap &_length, CapacityMap &_cap)
 The constructor of the class.
int run (Node s, Node t, int k)
 Runs the algorithm.
Length totalLength ()
 Gives back the total weight of the found flow.
const EdgeIntMap & getFlow () const
 Returns a const reference to the EdgeMap flow.
const PotentialMap & getPotential () const
 Returns a const reference to the NodeMap potential (the dual solution).
bool checkComplementarySlackness ()
 Checking the complementary slackness optimality criteria.


Constructor & Destructor Documentation

MinCostFlow Graph &  _G,
LengthMap &  _length,
CapacityMap &  _cap
[inline]
 

Parameters:
_G The directed graph the algorithm runs on.
_length The length (weight or cost) of the edges.
_cap The capacity of the edges.
Definition at line 126 of file min_cost_flow.h.


Member Function Documentation

int run Node  s,
Node  t,
int  k
[inline]
 

Runs the algorithm. Returns k if there is a flow of value at least k edge-disjoint from s to t. Otherwise it returns the maximum value of a flow from s to t.

Parameters:
s The source node.
t The target node.
k The value of the flow we are looking for.

Todo:
May be it does make sense to be able to start with a nonzero feasible primal-dual solution pair as well.
Definition at line 143 of file min_cost_flow.h.

Length totalLength  )  [inline]
 

This function gives back the total weight of the found flow. Assumes that run() has been run and nothing changed since then. Definition at line 202 of file min_cost_flow.h.

const EdgeIntMap& getFlow  )  const [inline]
 

Returns a const reference to the EdgeMap flow.

Precondition:
run() must be called before using this function.
Definition at line 211 of file min_cost_flow.h.

const PotentialMap& getPotential  )  const [inline]
 

Returns a const reference to the NodeMap potential (the dual solution).

Precondition:
run() must be called before using this function.
Definition at line 217 of file min_cost_flow.h.

bool checkComplementarySlackness  )  [inline]
 

This function checks, whether the given solution is optimal If executed after the call of run() then it should return with true. This function only checks optimality, doesn't bother with feasibility. It is meant for testing purposes.

Todo:
better comparison is needed for real types, moreover, this comparison here is superfluous.
Definition at line 226 of file min_cost_flow.h.


The documentation for this class was generated from the following file:
Generated on Thu Sep 30 12:18:38 2004 for LEMON by doxygen 1.3.8