Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Path and Flow Algorithms
[Graph Algorithms]


Detailed Description


Files

file  bfs.h
 Bfs algorithm.
file  dfs.h
 Dfs algorithm.
file  dijkstra.h
 Dijkstra algorithm.
file  min_cost_flow.h
 An algorithm for finding a flow of value k (for small values of k) having minimal total cost.
file  preflow.h
file  suurballe.h
 An algorithm for finding k paths of minimal total length.

Classes

class  Bfs
 BFS algorithm class. More...
class  Dfs
 DFS algorithm class. More...
class  Dijkstra
 Dijkstra algorithm class. More...
class  MinCostFlow
 Implementation of an algorithm for finding a flow of value k (for small values of k) having minimal total cost between 2 nodes. More...
class  Preflow
 Preflow algorithms class. More...
class  Suurballe
 Implementation of an algorithm for finding k edge-disjoint paths between 2 nodes of minimal total length. More...

Enumerations

enum  lemon::Preflow::FlowEnum
 Indicates the property of the starting flow map. More...
enum  lemon::Preflow::StatusEnum
 Indicates the state of the preflow algorithm. More...

Functions

template<class GR>
BfsWizard< BfsWizardBase<
GR > > 
lemon::bfs (const GR &g, typename GR::Node s=INVALID)
 Function type interface for Bfs algorithm.
template<class GR>
DfsWizard< DfsWizardBase<
GR > > 
lemon::dfs (const GR &g, typename GR::Node s=INVALID)
 Function type interface for Dfs algorithm.
template<class GR, class LM>
DijkstraWizard< DijkstraWizardBase<
GR, LM > > 
lemon::dijkstra (const GR &g, const LM &l, typename GR::Node s=INVALID)
 Function type interface for Dijkstra algorithm.
 lemon::Preflow::Preflow (const Graph &_gr, Node _s, Node _t, const CapacityMap &_cap, FlowMap &_f)
 The constructor of the class.
void lemon::Preflow::run ()
 Runs the preflow algorithm.
void lemon::Preflow::run (FlowEnum fp)
 Runs the preflow algorithm.
void lemon::Preflow::phase1 (FlowEnum fp)
 Runs the first phase of the preflow algorithm.
void lemon::Preflow::phase1 ()
 Runs the first phase of the preflow algorithm.
void lemon::Preflow::phase2 ()
 Runs the second phase of the preflow algorithm.
Num lemon::Preflow::flowValue () const
 Returns the value of the maximum flow.
template<typename _CutMap>
void lemon::Preflow::minCut (_CutMap &M) const
 Returns a minimum value cut.
template<typename _CutMap>
void lemon::Preflow::minMinCut (_CutMap &M) const
 Returns the inclusionwise minimum of the minimum value cuts.
template<typename _CutMap>
void lemon::Preflow::maxMinCut (_CutMap &M) const
 Returns the inclusionwise maximum of the minimum value cuts.
void lemon::Preflow::source (Node _s)
 Sets the source node to _s.
Node lemon::Preflow::source () const
 Returns the source node.
void lemon::Preflow::target (Node _t)
 Sets the target node to _t.
Node lemon::Preflow::target () const
 Returns the target node.
void lemon::Preflow::capacityMap (const CapacityMap &_cap)
 Sets the edge map of the capacities to _cap.
const CapacityMap & lemon::Preflow::capacityMap () const
 Returns a reference to capacity map.
void lemon::Preflow::flowMap (FlowMap &_f)
 Sets the edge map of the flows to _flow.
const FlowMap & lemon::Preflow::flowMap () const
 Returns a reference to flow map.
template<class GR, class CM, class FM>
Preflow< GR, typename CM::Value,
CM, FM > 
lemon::preflow (const GR &g, typename GR::Node source, typename GR::Node target, const CM &cap, FM &flow)
 Function type interface for Preflow algorithm.


Enumeration Type Documentation

enum FlowEnum [inherited]
 

Indicates the property of the starting flow map. The meanings are as follows:

  • ZERO_FLOW: constant zero flow
  • GEN_FLOW: any flow, i.e. the sum of the in-flows equals to the sum of the out-flows in every node except the source and the target.
  • PRE_FLOW: any preflow, i.e. the sum of the in-flows is at least the sum of the out-flows in every node except the source.
  • NO_FLOW: indicates an unspecified edge map. flow will be set to the constant zero flow in the beginning of the algorithm in this case.

enum StatusEnum [inherited]
 

Indicates the state of the preflow algorithm. The meanings are as follows:

  • AFTER_NOTHING: before running the algorithm or at an unspecified state.
  • AFTER_PREFLOW_PHASE_1: right after running phase1
  • AFTER_PREFLOW_PHASE_2: after running phase2()


Function Documentation

BfsWizard<BfsWizardBase<GR> > lemon::bfs const GR &  g,
typename GR::Node  s = INVALID
 

Function type interface for Bfs algorithm.

This function also has several named parameters, they are declared as the members of class BfsWizard. The following example shows how to use these parameters.

       bfs(g,source).predMap(preds).run();
Warning:
Don't forget to put the run() to the end of the parameter list.
See also:
BfsWizard

Bfs

DfsWizard<DfsWizardBase<GR> > lemon::dfs const GR &  g,
typename GR::Node  s = INVALID
 

Function type interface for Dfs algorithm.

This function also has several named parameters, they are declared as the members of class DfsWizard. The following example shows how to use these parameters.

       dfs(g,source).predMap(preds).run();
Warning:
Don't forget to put the run() to the end of the parameter list.
See also:
DfsWizard

Dfs

DijkstraWizard<DijkstraWizardBase<GR,LM> > lemon::dijkstra const GR &  g,
const LM &  l,
typename GR::Node  s = INVALID
 

Function type interface for Dijkstra algorithm.

This function also has several named parameters, they are declared as the members of class DijkstraWizard. The following example shows how to use these parameters.

       dijkstra(g,length,source).predMap(preds).run();
Warning:
Don't forget to put the run() to the end of the parameter list.
See also:
DijkstraWizard

Dijkstra

Preflow const Graph &  _gr,
Node  _s,
Node  _t,
const CapacityMap &  _cap,
FlowMap &  _f
[inline, inherited]
 

The constructor of the class.

Parameters:
_gr The directed graph the algorithm runs on.
_s The source node.
_t The target node.
_cap The capacity of the edges.
_f The flow of the edges. Except the graph, all of these parameters can be reset by calling source, target, capacityMap and flowMap, resp.

void run  )  [inline, inherited]
 

Runs the preflow algorithm.

void run FlowEnum  fp  )  [inline, inherited]
 

Runs the preflow algorithm.

Precondition:
The starting flow map must be
  • a constant zero flow if fp is ZERO_FLOW,
  • an arbitrary flow if fp is GEN_FLOW,
  • an arbitrary preflow if fp is PRE_FLOW,
  • any map if fp is NO_FLOW. If the starting flow map is a flow or a preflow then the algorithm terminates faster.

void phase1 FlowEnum  fp  )  [inline, inherited]
 

The preflow algorithm consists of two phases, this method runs the first phase. After the first phase the maximum flow value and a minimum value cut can already be computed, although a maximum flow is not yet obtained. So after calling this method flowValue returns the value of a maximum flow and minCut returns a minimum cut.

Warning:
minMinCut and maxMinCut do not give minimum value cuts unless calling phase2.
Precondition:
The starting flow must be
  • a constant zero flow if fp is ZERO_FLOW,
  • an arbitary flow if fp is GEN_FLOW,
  • an arbitary preflow if fp is PRE_FLOW,
  • any map if fp is NO_FLOW.

void phase1  )  [inline, inherited]
 

The preflow algorithm consists of two phases, this method runs the first phase. After the first phase the maximum flow value and a minimum value cut can already be computed, although a maximum flow is not yet obtained. So after calling this method flowValue returns the value of a maximum flow and minCut returns a minimum cut.

Warning:
minCut(), minMinCut() and maxMinCut() do not give minimum value cuts unless calling phase2().

void phase2  )  [inline, inherited]
 

The preflow algorithm consists of two phases, this method runs the second phase. After calling phase1() and then phase2(), flowMap() return a maximum flow, flowValue returns the value of a maximum flow, minCut returns a minimum cut, while the methods minMinCut and maxMinCut return the inclusionwise minimum and maximum cuts of minimum value, resp.

Precondition:
phase1 must be called before.

Num flowValue  )  const [inline, inherited]
 

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 running phase1.

void minCut _CutMap &  M  )  const [inline, inherited]
 

Sets M to the characteristic vector of a minimum value cut. This method can be called both after running phase1 and phase2. It is much faster after phase1.

Precondition:
M should be a bool-valued node-map.

If minCut() is called after phase2() then M should be initialized to false.

void minMinCut _CutMap &  M  )  const [inline, inherited]
 

Sets M to the characteristic vector of the minimum value cut which is inclusionwise minimum. It is computed by processing a bfs from the source node s in the residual graph.

Precondition:
M should be a node map of bools initialized to false.

phase2 should already be run.

void maxMinCut _CutMap &  M  )  const [inline, inherited]
 

Sets M to the characteristic vector of the minimum value cut which is inclusionwise maximum. It is computed by processing a backward bfs from the target node t in the residual graph.

Precondition:
phase2() or run() should already be run.

void source Node  _s  )  [inline, inherited]
 

Sets the source node to _s.

Node source  )  const [inline, inherited]
 

Returns the source node.

void target Node  _t  )  [inline, inherited]
 

Sets the target node to _t.

Node target  )  const [inline, inherited]
 

Returns the target node.

void capacityMap const CapacityMap &  _cap  )  [inline, inherited]
 

Sets the edge map of the capacities to _cap.

const CapacityMap& capacityMap  )  const [inline, inherited]
 

Returns a reference to capacity map.

void flowMap FlowMap &  _f  )  [inline, inherited]
 

Sets the edge map of the flows to _flow.

const FlowMap& flowMap  )  const [inline, inherited]
 

Returns a reference to flow map.

Preflow<GR,typename CM::Value,CM,FM> lemon::preflow const GR &  g,
typename GR::Node  source,
typename GR::Node  target,
const CM &  cap,
FM &  flow
 

Function type interface for Preflow algorithm.

See also:
Preflow


Generated on Sat Aug 27 14:14:56 2005 for LEMON by  doxygen 1.4.4