Add a cost scaling min cost flow algorithm.
Add a cost scaling algorithm, which is performing generalized
push-relabel operations. It is almost as efficient as the capacity
scaling algorithm, but slower than network simplex.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
22 Here we discuss some advanced map techniques. Like writing your own maps or how to
23 extend/modify a maps functionality with adaptors.
25 \section custom_maps Writing Custom ReadMap
26 \subsection custom_read_maps Readable Maps
28 Readable maps are very frequently used as the input of an
29 algorithm. For this purpose the most straightforward way is the use of the
30 default maps provided by LEMON's graph structures.
31 Very often however, it is more
32 convenient and/or more efficient to write your own readable map.
34 You can find some examples below. In these examples \c Graph is the
35 type of the particular graph structure you use.
38 This simple map assigns \f$\pi\f$ to each edge.
44 typedef Graph::Edge Key;
45 double operator[](const Key &e) const { return PI;}
49 An alternative way to define maps is to use MapBase
52 struct MyMap : public MapBase<Graph::Edge,double>
54 Value operator[](const Key& e) const { return PI;}
58 Here is a bit more complex example.
59 It provides a length function obtained
60 from a base length function shifted by a potential difference.
63 class ReducedLengthMap : public MapBase<Graph::Edge,double>
66 const Graph::EdgeMap<double> &orig_len;
67 const Graph::NodeMap<double> &pot;
70 Value operator[](Key e) const {
71 return orig_len[e]-(pot[g.target(e)]-pot[g.source(e)]);
74 ReducedLengthMap(const Graph &_g,
75 const Graph::EdgeMap &_o,
76 const Graph::NodeMap &_p)
77 : g(_g), orig_len(_o), pot(_p) {};
81 Then, you can call e.g. Dijkstra algoritm on this map like this:
84 ReducedLengthMap rm(g,len,pot);
85 Dijkstra<Graph,ReducedLengthMap> dij(g,rm);