1.1 --- a/doc/groups.dox Tue Oct 09 09:36:54 2007 +0000
1.2 +++ b/doc/groups.dox Tue Oct 09 15:46:12 2007 +0000
1.3 @@ -97,6 +97,57 @@
1.4 make arithmetic operations between one or two maps (negation, scaling,
1.5 addition, multiplication etc.) or e.g. convert a map to another one
1.6 of different Value type.
1.7 +
1.8 +The typical usage of this classes is the passing implicit maps to
1.9 +algorithms. If a function type algorithm is called then the function
1.10 +type map adaptors can be used comfortable. For example let's see the
1.11 +usage of map adaptors with the \c graphToEps() function:
1.12 +\code
1.13 + Color nodeColor(int deg) {
1.14 + if (deg >= 2) {
1.15 + return Color(0.5, 0.0, 0.5);
1.16 + } else if (deg == 1) {
1.17 + return Color(1.0, 0.5, 1.0);
1.18 + } else {
1.19 + return Color(0.0, 0.0, 0.0);
1.20 + }
1.21 + }
1.22 +
1.23 + Graph::NodeMap<int> degree_map(graph);
1.24 +
1.25 + graphToEps(graph, "graph.eps")
1.26 + .coords(coords).scaleToA4().undirected()
1.27 + .nodeColors(composeMap(functorMap(nodeColor), degree_map))
1.28 + .run();
1.29 +\endcode
1.30 +The \c functorMap() function makes an \c int to \c Color map from the
1.31 +\e nodeColor() function. The \c composeMap() compose the \e degree_map
1.32 +and the previous created map. The composed map is proper function to
1.33 +get color of each node.
1.34 +
1.35 +The usage with class type algorithms is little bit harder. In this
1.36 +case the function type map adaptors can not be used, because the
1.37 +function map adaptors give back temporarly objects.
1.38 +\code
1.39 + Graph graph;
1.40 +
1.41 + typedef Graph::EdgeMap<double> DoubleEdgeMap;
1.42 + DoubleEdgeMap length(graph);
1.43 + DoubleEdgeMap speed(graph);
1.44 +
1.45 + typedef DivMap<DoubleEdgeMap, DoubleEdgeMap> TimeMap;
1.46 +
1.47 + TimeMap time(length, speed);
1.48 +
1.49 + Dijkstra<Graph, TimeMap> dijkstra(graph, time);
1.50 + dijkstra.run(source, target);
1.51 +\endcode
1.52 +
1.53 +We have a length map and a maximum speed map on a graph. The minimum
1.54 +time to pass the edge can be calculated as the division of the two
1.55 +maps which can be done implicitly with the \c DivMap template
1.56 +class. We use the implicit minimum time map as the length map of the
1.57 +\c Dijkstra algorithm.
1.58 */
1.59
1.60 /**
1.61 @@ -115,9 +166,10 @@
1.62 LEMON provides flexible data structures
1.63 to work with paths.
1.64
1.65 -All of them have the same interface, especially they can be built or extended
1.66 -using a standard Builder subclass. This make is easy to have e.g. the Dijkstra
1.67 -algorithm to store its result in any kind of path structure.
1.68 +All of them have similar interfaces, and it can be copied easily with
1.69 +assignment operator and copy constructor. This make it easy and
1.70 +efficient to have e.g. the Dijkstra algorithm to store its result in
1.71 +any kind of path structure.
1.72
1.73 \sa lemon::concepts::Path
1.74