doc/maps.dox
changeset 1083 8043b93e5973
parent 1043 52a2201a88e9
child 1167 ccbca6ba8b59
     1.1 --- a/doc/maps.dox	Sun Jan 16 22:27:34 2005 +0000
     1.2 +++ b/doc/maps.dox	Sun Jan 16 22:29:28 2005 +0000
     1.3 @@ -1,7 +1,6 @@
     1.4 +namespace lemon{
     1.5  /*!
     1.6  
     1.7 -
     1.8 -
     1.9  \page maps-page Maps
    1.10  
    1.11  Maps play central role in LEMON. As their name suggests, they map a
    1.12 @@ -13,9 +12,12 @@
    1.13    typedef double Value;
    1.14  \endcode
    1.15  
    1.16 -A map can \e readable (ReadMap, for short), \e writable (WriteMap) or both
    1.17 -(ReadWrite Map). There also exists a special type of
    1.18 -ReadWrite map called <em>reference map</em>. In addition that you can
    1.19 +A map can \e readable (\ref lemon::concept::ReadMap "ReadMap", for short),
    1.20 +\e writable (\ref lemon::concept::WriteMap "WriteMap") or both
    1.21 +(\ref lemon::concept::ReadWriteMap "ReadWriteMap").
    1.22 +There also exists a special type of
    1.23 +ReadWrite map called \ref lemon::concept::ReferenceMap "reference map".
    1.24 +In addition that you can
    1.25  read and write the values of a key, a reference map
    1.26  can also give you a reference to the
    1.27  value belonging to a key, so you have a direct access to the memory address
    1.28 @@ -28,11 +30,12 @@
    1.29  \code
    1.30    ListGraph G;
    1.31  \endcode
    1.32 -and you want to assign floating point value to each edge, you can do
    1.33 +and you want to assign a floating point value to each edge, you can do
    1.34  it like this.
    1.35  \code
    1.36    ListGraph::EdgeMap<double> length(G);
    1.37  \endcode
    1.38 +Note that you must give the underlying graph to the constructor.
    1.39  
    1.40  The value of a readable map can be obtained by <tt>operator[]</tt>.
    1.41  \code
    1.42 @@ -41,7 +44,7 @@
    1.43  where \c e is an instance of \c ListGraph::Edge.
    1.44  (Or anything else
    1.45  that converts to \c ListGraph::Edge, like  \c ListGraph::EdgeIt or
    1.46 -\c ListGraph::OutEdgeIt)
    1.47 +\c ListGraph::OutEdgeIt etc.)
    1.48  
    1.49  There are two ways the assign a new value to a key
    1.50  
    1.51 @@ -60,14 +63,14 @@
    1.52  
    1.53  The first case is more comfortable and if you store complex structures in your
    1.54  map, it might be more efficient. However, there are writable but
    1.55 -not reference maps, so if you want to write an generic algorithm, you should
    1.56 -insist on the second method.
    1.57 +not reference maps, so if you want to write a generic algorithm, you should
    1.58 +insist on the second way.
    1.59  
    1.60  \section how-to-write-your-own-map How to Write Your Own Maps
    1.61  
    1.62  \subsection read-maps Readable Maps
    1.63  
    1.64 -The readable maps are very frequently used as the input of the
    1.65 +Readable maps are very frequently used as the input of the
    1.66  algorithms.  For this purpose the most straightforward way is the use of the
    1.67  default maps provided by LEMON's graph structures.
    1.68  Very often however, it is more
    1.69 @@ -100,13 +103,13 @@
    1.70  \endcode
    1.71  
    1.72  Here is a bit more complex example.
    1.73 -It provides a length function which is obtained
    1.74 +It provides a length function obtained
    1.75  from a base length function shifted by a potential difference.
    1.76  
    1.77  \code
    1.78 -class MyLengthMap  : public MapBase<Graph::Edge,double>
    1.79 +class ReducedLengthMap  : public MapBase<Graph::Edge,double>
    1.80  {
    1.81 -  const Graph &G;
    1.82 +  const Graph &g;
    1.83    const Graph::EdgeMap<double> &orig_len;
    1.84    const Graph::NodeMap<double> &pot;
    1.85    
    1.86 @@ -115,11 +118,22 @@
    1.87      return orig_len.get(e)-pot.get(G.target(e))-pot.get(G.source(e));
    1.88    }
    1.89    
    1.90 -  MyLengthMap(const Graph &g, const Graph::EdgeMap &o,const Graph::NodeMap &p)
    1.91 +  ReducedLengthMap(const Graph &_g,
    1.92 +                   const Graph::EdgeMap &o,
    1.93 +                   const Graph::NodeMap &p)
    1.94      : G(g), orig_len(o), pot(p) {};
    1.95  };
    1.96  \endcode
    1.97  
    1.98 +Then, you can call e.g. Dijkstra algoritm on this map like this:
    1.99 +\code
   1.100 +  ...
   1.101 +  ReducedLengthMap rm(g,len,pot);
   1.102 +  Dijkstra<Graph,ReducedLengthMap> dij(g,rm);
   1.103 +  dij.run(s);
   1.104 +  ...
   1.105 +\endcode
   1.106 +
   1.107  
   1.108  \subsection write-maps Writable Maps
   1.109  
   1.110 @@ -130,3 +144,4 @@
   1.111  To be written...
   1.112  
   1.113  */
   1.114 +}
   1.115 \ No newline at end of file