COIN-OR::LEMON - Graph Library

Changeset 2489:48dddc283cfc in lemon-0.x for doc


Ignore:
Timestamp:
10/09/07 17:46:12 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3328
Message:

Bug fix and redesign StdMap?
Improving map adaptors documentations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/groups.dox

    r2429 r2489  
    9898addition, multiplication etc.) or e.g. convert a map to another one
    9999of different Value type.
     100
     101The typical usage of this classes is the passing implicit maps to
     102algorithms.  If a function type algorithm is called then the function
     103type map adaptors can be used comfortable. For example let's see the
     104usage 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
     123The \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
     125and the previous created map. The composed map is proper function to
     126get color of each node.
     127
     128The usage with class type algorithms is little bit harder. In this
     129case the function type map adaptors can not be used, because the
     130function 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
     146We have a length map and a maximum speed map on a graph. The minimum
     147time to pass the edge can be calculated as the division of the two
     148maps which can be done implicitly with the \c DivMap template
     149class. We use the implicit minimum time map as the length map of the
     150\c Dijkstra algorithm.
    100151*/
    101152
     
    116167to work with paths.
    117168
    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.
     169All of them have similar interfaces, and it can be copied easily with
     170assignment operator and copy constructor. This make it easy and
     171efficient to have e.g. the Dijkstra algorithm to store its result in
     172any kind of path structure.
    121173
    122174\sa lemon::concepts::Path
Note: See TracChangeset for help on using the changeset viewer.