equal
deleted
inserted
replaced
1 namespace lemon{ |
1 namespace lemon{ |
2 /*! |
2 /*! |
3 |
3 |
4 \page maps-page Maps |
4 \page maps-page Maps |
5 |
5 |
6 Maps play central role in LEMON. As their name suggests, they map a |
6 Maps play a central role in LEMON. As their name suggests, they map a |
7 certain range of \e keys to certain \e values. Each map has two |
7 certain range of \e keys to certain \e values. Each map has two |
8 <tt>typedef</tt>'s to determine the types of keys and values, like this: |
8 <tt>typedef</tt>'s to determine the types of keys and values, like this: |
9 |
9 |
10 \code |
10 \code |
11 typedef Edge Key; |
11 typedef Edge Key; |
44 where \c e is an instance of \c ListGraph::Edge. |
44 where \c e is an instance of \c ListGraph::Edge. |
45 (Or anything else |
45 (Or anything else |
46 that converts to \c ListGraph::Edge, like \c ListGraph::EdgeIt or |
46 that converts to \c ListGraph::Edge, like \c ListGraph::EdgeIt or |
47 \c ListGraph::OutEdgeIt etc.) |
47 \c ListGraph::OutEdgeIt etc.) |
48 |
48 |
49 There are two ways the assign a new value to a key |
49 There are two ways to assign a new value to a key |
50 |
50 |
51 - In case of a <em>reference map</em> <tt>operator[]</tt> |
51 - In case of a <em>reference map</em> <tt>operator[]</tt> |
52 gives you a reference to the |
52 gives you a reference to the |
53 value, thus you can use this. |
53 value, thus you can use this. |
54 \code |
54 \code |
68 |
68 |
69 \section how-to-write-your-own-map How to Write Your Own Maps |
69 \section how-to-write-your-own-map How to Write Your Own Maps |
70 |
70 |
71 \subsection read-maps Readable Maps |
71 \subsection read-maps Readable Maps |
72 |
72 |
73 Readable maps are very frequently used as the input of the |
73 Readable maps are very frequently used as the input of an |
74 algorithms. For this purpose the most straightforward way is the use of the |
74 algorithm. For this purpose the most straightforward way is the use of the |
75 default maps provided by LEMON's graph structures. |
75 default maps provided by LEMON's graph structures. |
76 Very often however, it is more |
76 Very often however, it is more |
77 convenient and/or more efficient to write your own readable map. |
77 convenient and/or more efficient to write your own readable map. |
78 |
78 |
79 You can find some examples below. In these examples \c Graph is the |
79 You can find some examples below. In these examples \c Graph is the |
113 const Graph::EdgeMap<double> &orig_len; |
113 const Graph::EdgeMap<double> &orig_len; |
114 const Graph::NodeMap<double> &pot; |
114 const Graph::NodeMap<double> &pot; |
115 |
115 |
116 public: |
116 public: |
117 Value operator[](Key e) const { |
117 Value operator[](Key e) const { |
118 return orig_len.get(e)-pot.get(G.target(e))-pot.get(G.source(e)); |
118 return orig_len.get(e)-(pot.get(G.target(e))-pot.get(G.source(e))); |
119 } |
119 } |
120 |
120 |
121 ReducedLengthMap(const Graph &_g, |
121 ReducedLengthMap(const Graph &_g, |
122 const Graph::EdgeMap &o, |
122 const Graph::EdgeMap &o, |
123 const Graph::NodeMap &p) |
123 const Graph::NodeMap &p) |