COIN-OR::LEMON - Graph Library

source: lemon-0.x/doc/maps.dox @ 603:86458ad390a7

Last change on this file since 603:86458ad390a7 was 290:e37a05270e80, checked in by Alpar Juttner, 16 years ago
File size: 1.5 KB
Line 
1/*!
2
3\page maps How to write your own maps
4
5\section read-maps Readable Maps
6
7The readable maps are very frequently used as the input of the
8algorithms.  For this purpose the most straightforward is to use the
9maps provided by Hugo's graph structres. Very often however, it is more
10convenient and/or more efficient to write your own readable map.
11
12You can find some example below.
13
14This simple map assigns \f$\pi\f$ to each edge.
15
16\code
17struct MyMap
18{
19  typedef double ValueType;
20  double operator[](Graph::Edge e) const { return M_PI;}
21};
22\endcode
23
24An alternative way to define maps. For this, \c MapBase seems to
25be a better name then \c NullMap
26
27\code
28struct MyMap : public MapBase<Edge,double>
29{
30  double operator[](Graph::Edge e) const { return M_PI;}
31};
32\endcode
33
34Or, if we had \c KeyType and \c ValueType
35
36\code
37struct MyMap : public MapBase<Edge,double>
38{
39  ValueType operator[](KeyType e) const { return M_PI;}
40};
41\endcode
42
43
44Here is a more complex example. It provides a length function which is obtained
45from a base length function modified by a potential difference.
46
47\code
48class MyLengthMap
49{
50  const Graph::EdgeMap &ol;
51  const Graph::NodeMap &pot;
52 
53public:
54  typedef double ValueType;
55
56  double operator[](Graph::Edge e) const {
57    return ol.get(e)-pot.get(v)-pot.get(u);
58  }
59 
60  MyComplexMap(const Graph::EdgeMap &o,const Graph::NodeMap &p) :
61    ol(o), pot(p);
62};
63\endcode
64
65\todo Please improve on the english.
66\todo Don't we need \e to \e require a 'typedef xxx KeyType' tag, as well?
67*/
Note: See TracBrowser for help on using the repository browser.