95 |
95 |
96 Most of them are \ref lemon::concepts::ReadMap "ReadMap"s. They can |
96 Most of them are \ref lemon::concepts::ReadMap "ReadMap"s. They can |
97 make arithmetic operations between one or two maps (negation, scaling, |
97 make arithmetic operations between one or two maps (negation, scaling, |
98 addition, multiplication etc.) or e.g. convert a map to another one |
98 addition, multiplication etc.) or e.g. convert a map to another one |
99 of different Value type. |
99 of different Value type. |
|
100 |
|
101 The typical usage of this classes is the passing implicit maps to |
|
102 algorithms. If a function type algorithm is called then the function |
|
103 type map adaptors can be used comfortable. For example let's see the |
|
104 usage of map adaptors with the \c graphToEps() function: |
|
105 \code |
|
106 Color nodeColor(int deg) { |
|
107 if (deg >= 2) { |
|
108 return Color(0.5, 0.0, 0.5); |
|
109 } else if (deg == 1) { |
|
110 return Color(1.0, 0.5, 1.0); |
|
111 } else { |
|
112 return Color(0.0, 0.0, 0.0); |
|
113 } |
|
114 } |
|
115 |
|
116 Graph::NodeMap<int> degree_map(graph); |
|
117 |
|
118 graphToEps(graph, "graph.eps") |
|
119 .coords(coords).scaleToA4().undirected() |
|
120 .nodeColors(composeMap(functorMap(nodeColor), degree_map)) |
|
121 .run(); |
|
122 \endcode |
|
123 The \c functorMap() function makes an \c int to \c Color map from the |
|
124 \e nodeColor() function. The \c composeMap() compose the \e degree_map |
|
125 and the previous created map. The composed map is proper function to |
|
126 get color of each node. |
|
127 |
|
128 The usage with class type algorithms is little bit harder. In this |
|
129 case the function type map adaptors can not be used, because the |
|
130 function map adaptors give back temporarly objects. |
|
131 \code |
|
132 Graph graph; |
|
133 |
|
134 typedef Graph::EdgeMap<double> DoubleEdgeMap; |
|
135 DoubleEdgeMap length(graph); |
|
136 DoubleEdgeMap speed(graph); |
|
137 |
|
138 typedef DivMap<DoubleEdgeMap, DoubleEdgeMap> TimeMap; |
|
139 |
|
140 TimeMap time(length, speed); |
|
141 |
|
142 Dijkstra<Graph, TimeMap> dijkstra(graph, time); |
|
143 dijkstra.run(source, target); |
|
144 \endcode |
|
145 |
|
146 We have a length map and a maximum speed map on a graph. The minimum |
|
147 time to pass the edge can be calculated as the division of the two |
|
148 maps which can be done implicitly with the \c DivMap template |
|
149 class. We use the implicit minimum time map as the length map of the |
|
150 \c Dijkstra algorithm. |
100 */ |
151 */ |
101 |
152 |
102 /** |
153 /** |
103 @defgroup matrices Matrices |
154 @defgroup matrices Matrices |
104 @ingroup datas |
155 @ingroup datas |
113 \brief Path structures implemented in LEMON. |
164 \brief Path structures implemented in LEMON. |
114 |
165 |
115 LEMON provides flexible data structures |
166 LEMON provides flexible data structures |
116 to work with paths. |
167 to work with paths. |
117 |
168 |
118 All of them have the same interface, especially they can be built or extended |
169 All of them have similar interfaces, and it can be copied easily with |
119 using a standard Builder subclass. This make is easy to have e.g. the Dijkstra |
170 assignment operator and copy constructor. This make it easy and |
120 algorithm to store its result in any kind of path structure. |
171 efficient to have e.g. the Dijkstra algorithm to store its result in |
|
172 any kind of path structure. |
121 |
173 |
122 \sa lemon::concepts::Path |
174 \sa lemon::concepts::Path |
123 |
175 |
124 */ |
176 */ |
125 |
177 |