doc/maps.dox
author marci
Sat, 03 Apr 2004 14:22:33 +0000
changeset 279 be43902fadb7
parent 210 6bc65a8a99c6
child 289 98adf9276de0
permissions -rw-r--r--
minor changes
alpar@202
     1
/*!
alpar@202
     2
alpar@202
     3
\page maps How to write maps
alpar@202
     4
alpar@202
     5
\section read-maps Readable Maps
alpar@202
     6
alpar@202
     7
It is quite easy to write your own readmap for the edges or nodes of a graph.
alpar@202
     8
alpar@202
     9
You can find some example below.
alpar@202
    10
alpar@204
    11
This simple map assigns \f$\pi\f$ to each edge.
alpar@204
    12
alpar@202
    13
\code
alpar@273
    14
struct MyMap 
alpar@202
    15
{
alpar@273
    16
  typedef double ValueType;
alpar@273
    17
  double operator[](Graph::EdgeIt e) const { return M_PI;}
alpar@204
    18
};
alpar@204
    19
\endcode
alpar@204
    20
alpar@204
    21
alpar@210
    22
Here is a more complex example. It provides a length function which is obtained
alpar@210
    23
from a base length function modified by a potential difference.
alpar@210
    24
\todo Please improve on the english. 
alpar@202
    25
alpar@202
    26
\code
alpar@202
    27
class MyLengthMap 
alpar@202
    28
{
alpar@202
    29
  const Graph::EdgeMap &ol;
alpar@202
    30
  const Graph::NodeMap &pot;
alpar@202
    31
  
alpar@273
    32
public:
alpar@273
    33
  typedef double ValueType;
alpar@273
    34
alpar@210
    35
  double operator[](Graph::EdgeIt e) const {
alpar@210
    36
    return ol.get(e)-pot.get(v)-pot.get(u);
alpar@210
    37
  }
alpar@202
    38
  
alpar@202
    39
  MyComplexMap(const Graph::EdgeMap &o,const Graph::NodeMap &p) :
alpar@202
    40
    ol(o), pot(p);
alpar@202
    41
};
alpar@202
    42
\endcode
alpar@202
    43
alpar@273
    44
\todo Don't we need \e to \e require a 'typedef xxx KeyType' tag, as well?
alpar@202
    45
*/