alpar@202: /*! alpar@202: alpar@289: \page maps How to write your own maps alpar@202: alpar@202: \section read-maps Readable Maps alpar@202: alpar@289: The readable maps are very frequently used as the input of the alpar@289: algorithms. For this purpose the most straightforward is to use the alpar@289: maps provided by Hugo's graph structres. Very often however, it is more alpar@289: convenient and/or more efficient to write your own readable map. alpar@202: alpar@202: You can find some example below. alpar@202: alpar@204: This simple map assigns \f$\pi\f$ to each edge. alpar@204: alpar@202: \code alpar@273: struct MyMap alpar@202: { alpar@273: typedef double ValueType; alpar@289: double operator[](Graph::Edge e) const { return M_PI;} alpar@204: }; alpar@204: \endcode alpar@204: alpar@289: An alternative way to define maps. For this, \c MapBase seems to alpar@289: be a better name then \c NullMap alpar@289: alpar@289: \code alpar@289: struct MyMap : public MapBase alpar@289: { alpar@289: double operator[](Graph::Edge e) const { return M_PI;} alpar@289: }; alpar@289: \endcode alpar@289: alpar@290: Or, if we had \c KeyType and \c ValueType alpar@289: alpar@289: \code alpar@289: struct MyMap : public MapBase alpar@289: { alpar@289: ValueType operator[](KeyType e) const { return M_PI;} alpar@289: }; alpar@289: \endcode alpar@289: alpar@204: alpar@210: Here is a more complex example. It provides a length function which is obtained alpar@210: from a base length function modified by a potential difference. alpar@202: alpar@202: \code alpar@202: class MyLengthMap alpar@202: { alpar@202: const Graph::EdgeMap &ol; alpar@202: const Graph::NodeMap &pot; alpar@202: alpar@273: public: alpar@273: typedef double ValueType; alpar@273: alpar@289: double operator[](Graph::Edge e) const { alpar@210: return ol.get(e)-pot.get(v)-pot.get(u); alpar@210: } alpar@202: alpar@202: MyComplexMap(const Graph::EdgeMap &o,const Graph::NodeMap &p) : alpar@202: ol(o), pot(p); alpar@202: }; alpar@202: \endcode alpar@202: alpar@289: \todo Please improve on the english. alpar@273: \todo Don't we need \e to \e require a 'typedef xxx KeyType' tag, as well? alpar@202: */