COIN-OR::LEMON - Graph Library

source: lemon-0.x/doc/maps.dox @ 339:768ebc700bae

Last change on this file since 339:768ebc700bae was 290:e37a05270e80, checked in by Alpar Juttner, 21 years ago
File size: 1.5 KB
RevLine 
[202]1/*!
2
[289]3\page maps How to write your own maps
[202]4
5\section read-maps Readable Maps
6
[289]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.
[202]11
12You can find some example below.
13
[204]14This simple map assigns \f$\pi\f$ to each edge.
15
[202]16\code
[273]17struct MyMap
[202]18{
[273]19  typedef double ValueType;
[289]20  double operator[](Graph::Edge e) const { return M_PI;}
[204]21};
22\endcode
23
[289]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
[290]34Or, if we had \c KeyType and \c ValueType
[289]35
36\code
37struct MyMap : public MapBase<Edge,double>
38{
39  ValueType operator[](KeyType e) const { return M_PI;}
40};
41\endcode
42
[204]43
[210]44Here is a more complex example. It provides a length function which is obtained
45from a base length function modified by a potential difference.
[202]46
47\code
48class MyLengthMap
49{
50  const Graph::EdgeMap &ol;
51  const Graph::NodeMap &pot;
52 
[273]53public:
54  typedef double ValueType;
55
[289]56  double operator[](Graph::Edge e) const {
[210]57    return ol.get(e)-pot.get(v)-pot.get(u);
58  }
[202]59 
60  MyComplexMap(const Graph::EdgeMap &o,const Graph::NodeMap &p) :
61    ol(o), pot(p);
62};
63\endcode
64
[289]65\todo Please improve on the english.
[273]66\todo Don't we need \e to \e require a 'typedef xxx KeyType' tag, as well?
[202]67*/
Note: See TracBrowser for help on using the repository browser.