Changeset 2489:48dddc283cfc in lemon-0.x for doc/groups.dox
- Timestamp:
- 10/09/07 17:46:12 (17 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3328
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/groups.dox
r2429 r2489 98 98 addition, multiplication etc.) or e.g. convert a map to another one 99 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 … … 116 167 to work with paths. 117 168 118 All of them have the same interface, especially they can be built or extended 119 using a standard Builder subclass. This make is easy to have e.g. the Dijkstra 120 algorithm to store its result in any kind of path structure. 169 All of them have similar interfaces, and it can be copied easily with 170 assignment operator and copy constructor. This make it easy and 171 efficient to have e.g. the Dijkstra algorithm to store its result in 172 any kind of path structure. 121 173 122 174 \sa lemon::concepts::Path
Note: See TracChangeset
for help on using the changeset viewer.