Changeset 1083:8043b93e5973 in lemon-0.x for doc/maps.dox
- Timestamp:
- 01/16/05 23:29:28 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1479
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/maps.dox
r1043 r1083 1 namespace lemon{ 1 2 /*! 2 3 4 3 5 4 \page maps-page Maps … … 14 13 \endcode 15 14 16 A map can \e readable (ReadMap, for short), \e writable (WriteMap) or both 17 (ReadWrite Map). There also exists a special type of 18 ReadWrite map called <em>reference map</em>. In addition that you can 15 A map can \e readable (\ref lemon::concept::ReadMap "ReadMap", for short), 16 \e writable (\ref lemon::concept::WriteMap "WriteMap") or both 17 (\ref lemon::concept::ReadWriteMap "ReadWriteMap"). 18 There also exists a special type of 19 ReadWrite map called \ref lemon::concept::ReferenceMap "reference map". 20 In addition that you can 19 21 read and write the values of a key, a reference map 20 22 can also give you a reference to the … … 29 31 ListGraph G; 30 32 \endcode 31 and you want to assign floating point value to each edge, you can do33 and you want to assign a floating point value to each edge, you can do 32 34 it like this. 33 35 \code 34 36 ListGraph::EdgeMap<double> length(G); 35 37 \endcode 38 Note that you must give the underlying graph to the constructor. 36 39 37 40 The value of a readable map can be obtained by <tt>operator[]</tt>. … … 42 45 (Or anything else 43 46 that converts to \c ListGraph::Edge, like \c ListGraph::EdgeIt or 44 \c ListGraph::OutEdgeIt )47 \c ListGraph::OutEdgeIt etc.) 45 48 46 49 There are two ways the assign a new value to a key … … 61 64 The first case is more comfortable and if you store complex structures in your 62 65 map, it might be more efficient. However, there are writable but 63 not reference maps, so if you want to write a ngeneric algorithm, you should64 insist on the second method.66 not reference maps, so if you want to write a generic algorithm, you should 67 insist on the second way. 65 68 66 69 \section how-to-write-your-own-map How to Write Your Own Maps … … 68 71 \subsection read-maps Readable Maps 69 72 70 The readable maps are very frequently used as the input of the73 Readable maps are very frequently used as the input of the 71 74 algorithms. For this purpose the most straightforward way is the use of the 72 75 default maps provided by LEMON's graph structures. … … 101 104 102 105 Here is a bit more complex example. 103 It provides a length function which isobtained106 It provides a length function obtained 104 107 from a base length function shifted by a potential difference. 105 108 106 109 \code 107 class MyLengthMap : public MapBase<Graph::Edge,double>110 class ReducedLengthMap : public MapBase<Graph::Edge,double> 108 111 { 109 const Graph & G;112 const Graph &g; 110 113 const Graph::EdgeMap<double> &orig_len; 111 114 const Graph::NodeMap<double> &pot; … … 116 119 } 117 120 118 MyLengthMap(const Graph &g, const Graph::EdgeMap &o,const Graph::NodeMap &p) 121 ReducedLengthMap(const Graph &_g, 122 const Graph::EdgeMap &o, 123 const Graph::NodeMap &p) 119 124 : G(g), orig_len(o), pot(p) {}; 120 125 }; 126 \endcode 127 128 Then, you can call e.g. Dijkstra algoritm on this map like this: 129 \code 130 ... 131 ReducedLengthMap rm(g,len,pot); 132 Dijkstra<Graph,ReducedLengthMap> dij(g,rm); 133 dij.run(s); 134 ... 121 135 \endcode 122 136 … … 131 145 132 146 */ 147 }
Note: See TracChangeset
for help on using the changeset viewer.