[202] | 1 | /*! |
---|

| 2 | |
---|

[289] | 3 | \page maps How to write your own maps |
---|

[202] | 4 | |
---|

| 5 | \section read-maps Readable Maps |
---|

| 6 | |
---|

[289] | 7 | The readable maps are very frequently used as the input of the |
---|

| 8 | algorithms. For this purpose the most straightforward is to use the |
---|

| 9 | maps provided by Hugo's graph structres. Very often however, it is more |
---|

| 10 | convenient and/or more efficient to write your own readable map. |
---|

[202] | 11 | |
---|

[685] | 12 | You can find some examples below. |
---|

[202] | 13 | |
---|

[204] | 14 | This simple map assigns \f$\pi\f$ to each edge. |
---|

| 15 | |
---|

[202] | 16 | \code |
---|

[273] | 17 | struct 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] | 24 | An alternative way to define maps. For this, \c MapBase seems to |
---|

| 25 | be a better name then \c NullMap |
---|

| 26 | |
---|

| 27 | \code |
---|

| 28 | struct MyMap : public MapBase<Edge,double> |
---|

| 29 | { |
---|

| 30 | double operator[](Graph::Edge e) const { return M_PI;} |
---|

| 31 | }; |
---|

| 32 | \endcode |
---|

| 33 | |
---|

[290] | 34 | Or, if we had \c KeyType and \c ValueType |
---|

[289] | 35 | |
---|

| 36 | \code |
---|

| 37 | struct MyMap : public MapBase<Edge,double> |
---|

| 38 | { |
---|

| 39 | ValueType operator[](KeyType e) const { return M_PI;} |
---|

| 40 | }; |
---|

| 41 | \endcode |
---|

| 42 | |
---|

[204] | 43 | |
---|

[210] | 44 | Here is a more complex example. It provides a length function which is obtained |
---|

| 45 | from a base length function modified by a potential difference. |
---|

[202] | 46 | |
---|

| 47 | \code |
---|

| 48 | class MyLengthMap |
---|

| 49 | { |
---|

| 50 | const Graph::EdgeMap &ol; |
---|

| 51 | const Graph::NodeMap &pot; |
---|

| 52 | |
---|

[273] | 53 | public: |
---|

| 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 | */ |
---|