Source and Target EdgeMap.
1.1 --- a/src/lemon/maps.h Tue Apr 12 17:37:22 2005 +0000
1.2 +++ b/src/lemon/maps.h Tue Apr 12 17:38:16 2005 +0000
1.3 @@ -216,6 +216,12 @@
1.4 ///\param _m is the undelying map
1.5 ///\param _v is the convert value
1.6 ConvertMap(const M &_m) : m(_m) {};
1.7 +
1.8 + /// \brief The subscript operator.
1.9 + ///
1.10 + /// The subscript operator.
1.11 + /// \param edge The edge
1.12 + /// \return The target of the edge
1.13 Value operator[](Key k) const {return m[k];}
1.14 };
1.15
1.16 @@ -230,6 +236,82 @@
1.17 return ConvertMap<M,T>(m);
1.18 }
1.19
1.20 + /// \brief Returns the source of the given edge.
1.21 + ///
1.22 + /// The SourceMap gives back the source Node of the given edge.
1.23 + /// \author Balazs Dezso
1.24 + template <typename Graph>
1.25 + class SourceMap {
1.26 + public:
1.27 + typedef typename Graph::Node Value;
1.28 + typedef typename Graph::Edge Key;
1.29 +
1.30 + /// \brief Constructor
1.31 + ///
1.32 + /// Constructor
1.33 + /// \param _graph The graph that the map belongs to.
1.34 + SourceMap(const Graph& _graph) : graph(_graph) {}
1.35 +
1.36 + /// \brief The subscript operator.
1.37 + ///
1.38 + /// The subscript operator.
1.39 + /// \param edge The edge
1.40 + /// \return The source of the edge
1.41 + Value operator[](const Key& edge) {
1.42 + return graph.source(edge);
1.43 + }
1.44 +
1.45 + private:
1.46 + const Graph& graph;
1.47 + };
1.48 +
1.49 + /// \brief Returns a \ref SourceMap class
1.50 +
1.51 + /// This function just returns an \ref SourceMap class.
1.52 + /// \relates SourceMap
1.53 + template <typename Graph>
1.54 + inline SourceMap<Graph> sourceMap(const Graph&) {
1.55 + return SourceMap<Graph>(graph);
1.56 + }
1.57 +
1.58 + /// \brief Returns the target of the given edge.
1.59 + ///
1.60 + /// The TargetMap gives back the target Node of the given edge.
1.61 + /// \author Balazs Dezso
1.62 + template <typename Graph>
1.63 + class TargetMap {
1.64 + public:
1.65 + typedef typename Graph::Node Value;
1.66 + typedef typename Graph::Edge Key;
1.67 +
1.68 + /// \brief Constructor
1.69 + ///
1.70 + /// Constructor
1.71 + /// \param _graph The graph that the map belongs to.
1.72 + TargetMap(const Graph& _graph) : graph(_graph) {}
1.73 +
1.74 + /// \brief The subscript operator.
1.75 + ///
1.76 + /// The subscript operator.
1.77 + /// \param edge The edge
1.78 + /// \return The target of the edge
1.79 + Value operator[](const Key& key) {
1.80 + return graph.target(key);
1.81 + }
1.82 +
1.83 + private:
1.84 + const Graph& graph;
1.85 + };
1.86 +
1.87 + /// \brief Returns a \ref TargetMap class
1.88 +
1.89 + /// This function just returns an \ref TargetMap class.
1.90 + /// \relates TargetMap
1.91 + template <typename Graph>
1.92 + inline TargetMap<Graph> targetMap(const Graph&) {
1.93 + return TargetMap<Graph>(graph);
1.94 + }
1.95 +
1.96 ///Sum of two maps
1.97
1.98 ///This \ref concept::ReadMap "read only map" returns the sum of the two