template<typename GR, typename LEN, typename TR>
class lemon::Suurballe< GR, LEN, TR >
Suurballe implements an algorithm for finding arc-disjoint paths having minimum total length (cost) from a given source node to a given target node in a digraph.
Note that this problem is a special case of the minimum cost flow problem. This implementation is actually an efficient specialized version of the successive shortest path algorithm directly for this problem. Therefore this class provides query functions for flow values and node potentials (the dual solution) just like the minimum cost flow algorithms.
- Template Parameters
-
GR | The digraph type the algorithm runs on. |
LEN | The type of the length map. The default value is GR::ArcMap<int> . |
- Warning
- Length values should be non-negative.
- Note
- For finding node-disjoint paths, this algorithm can be used along with the SplitNodes adaptor.
|
| Suurballe (const Digraph &graph, const LengthMap &length) |
| Constructor.
|
|
| ~Suurballe () |
| Destructor.
|
|
Suurballe & | flowMap (FlowMap &map) |
| Set the flow map.
|
|
Suurballe & | potentialMap (PotentialMap &map) |
| Set the potential map.
|
|
|
The simplest way to execute the algorithm is to call the run() function.
If you need to execute the algorithm many times using the same source node, then you may call fullInit() once and start() for each target node.
If you only need the flow that is the union of the found arc-disjoint paths, then you may call findFlow() instead of start().
|
int | run (const Node &s, const Node &t, int k=2) |
| Run the algorithm.
|
|
void | init (const Node &s) |
| Initialize the algorithm.
|
|
void | fullInit (const Node &s) |
| Initialize the algorithm and perform Dijkstra.
|
|
int | start (const Node &t, int k=2) |
| Execute the algorithm.
|
|
int | findFlow (const Node &t, int k=2) |
| Execute the algorithm to find an optimal flow.
|
|
void | findPaths () |
| Compute the paths from the flow.
|
|
|
The results of the algorithm can be obtained using these functions.
The algorithm should be executed before using them.
|
Length | totalLength () const |
| Return the total length of the found paths.
|
|
int | flow (const Arc &arc) const |
| Return the flow value on the given arc.
|
|
const FlowMap & | flowMap () const |
| Return a const reference to an arc map storing the found flow.
|
|
Length | potential (const Node &node) const |
| Return the potential of the given node.
|
|
const PotentialMap & | potentialMap () const |
| Return a const reference to a node map storing the found potentials (the dual solution).
|
|
int | pathNum () const |
| Return the number of the found paths.
|
|
const Path & | path (int i) const |
| Return a const reference to the specified path.
|
|
template<typename GR , typename LEN , typename TR >
This function sets the flow map. If it is not used before calling run() or init(), an instance will be allocated automatically. The destructor deallocates this automatically allocated map, of course.
The found flow contains only 0 and 1 values, since it is the union of the found arc-disjoint paths.
- Returns
(*this)
template<typename GR , typename LEN , typename TR >
This function sets the potential map. If it is not used before calling run() or init(), an instance will be allocated automatically. The destructor deallocates this automatically allocated map, of course.
The node potentials provide the dual solution of the underlying minimum cost flow problem.
- Returns
(*this)
template<typename GR , typename LEN , typename TR >
void fullInit |
( |
const Node & |
s | ) |
|
|
inline |
This function initializes the algorithm and performs a full Dijkstra search from the given source node. It makes consecutive executions of start(t, k) faster, since they have to perform Dijkstra only k-1 times.
This initialization is usually worth using instead of init() if the algorithm is executed many times using the same source node.
- Parameters
-