author | marci |
Fri, 19 Mar 2004 09:09:20 +0000 | |
changeset 206 | 47f62d789fe7 |
parent 204 | d8107ae24128 |
child 210 | 6bc65a8a99c6 |
permissions | -rw-r--r-- |
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@202 | 14 |
class MyMap |
alpar@202 | 15 |
{ |
alpar@205 | 16 |
double get(Graph::EdgeIt e) const { return M_PI;} |
alpar@202 | 17 |
}; |
alpar@202 | 18 |
\endcode |
alpar@202 | 19 |
|
alpar@204 | 20 |
Or if we accept the new map style, it will look like this: |
alpar@204 | 21 |
|
alpar@204 | 22 |
\code |
alpar@204 | 23 |
class MyMap |
alpar@204 | 24 |
{ |
alpar@205 | 25 |
double operator[](Graph::EdgeIt e) const { return 1;} |
alpar@204 | 26 |
}; |
alpar@204 | 27 |
\endcode |
alpar@204 | 28 |
|
alpar@204 | 29 |
|
alpar@202 | 30 |
A more complex example |
alpar@202 | 31 |
|
alpar@202 | 32 |
\code |
alpar@202 | 33 |
class MyLengthMap |
alpar@202 | 34 |
{ |
alpar@202 | 35 |
const Graph::EdgeMap &ol; |
alpar@202 | 36 |
const Graph::NodeMap &pot; |
alpar@202 | 37 |
|
alpar@202 | 38 |
double get(Graph::EdgeIt e) const { return ol.get(e)-pot.get(v)-pot.get(u);} |
alpar@202 | 39 |
|
alpar@202 | 40 |
MyComplexMap(const Graph::EdgeMap &o,const Graph::NodeMap &p) : |
alpar@202 | 41 |
ol(o), pot(p); |
alpar@202 | 42 |
}; |
alpar@202 | 43 |
\endcode |
alpar@202 | 44 |
|
alpar@202 | 45 |
*/ |