# HG changeset patch # User deba # Date 1113327496 0 # Node ID 639dadf8c00db10055e8453d9d84a177d2282517 # Parent 71e0777b65e0c5c6868496028a82e17c0bdd49e8 Source and Target EdgeMap. diff -r 71e0777b65e0 -r 639dadf8c00d src/lemon/maps.h --- a/src/lemon/maps.h Tue Apr 12 17:37:22 2005 +0000 +++ b/src/lemon/maps.h Tue Apr 12 17:38:16 2005 +0000 @@ -216,6 +216,12 @@ ///\param _m is the undelying map ///\param _v is the convert value ConvertMap(const M &_m) : m(_m) {}; + + /// \brief The subscript operator. + /// + /// The subscript operator. + /// \param edge The edge + /// \return The target of the edge Value operator[](Key k) const {return m[k];} }; @@ -230,6 +236,82 @@ return ConvertMap(m); } + /// \brief Returns the source of the given edge. + /// + /// The SourceMap gives back the source Node of the given edge. + /// \author Balazs Dezso + template + class SourceMap { + public: + typedef typename Graph::Node Value; + typedef typename Graph::Edge Key; + + /// \brief Constructor + /// + /// Constructor + /// \param _graph The graph that the map belongs to. + SourceMap(const Graph& _graph) : graph(_graph) {} + + /// \brief The subscript operator. + /// + /// The subscript operator. + /// \param edge The edge + /// \return The source of the edge + Value operator[](const Key& edge) { + return graph.source(edge); + } + + private: + const Graph& graph; + }; + + /// \brief Returns a \ref SourceMap class + + /// This function just returns an \ref SourceMap class. + /// \relates SourceMap + template + inline SourceMap sourceMap(const Graph&) { + return SourceMap(graph); + } + + /// \brief Returns the target of the given edge. + /// + /// The TargetMap gives back the target Node of the given edge. + /// \author Balazs Dezso + template + class TargetMap { + public: + typedef typename Graph::Node Value; + typedef typename Graph::Edge Key; + + /// \brief Constructor + /// + /// Constructor + /// \param _graph The graph that the map belongs to. + TargetMap(const Graph& _graph) : graph(_graph) {} + + /// \brief The subscript operator. + /// + /// The subscript operator. + /// \param edge The edge + /// \return The target of the edge + Value operator[](const Key& key) { + return graph.target(key); + } + + private: + const Graph& graph; + }; + + /// \brief Returns a \ref TargetMap class + + /// This function just returns an \ref TargetMap class. + /// \relates TargetMap + template + inline TargetMap targetMap(const Graph&) { + return TargetMap(graph); + } + ///Sum of two maps ///This \ref concept::ReadMap "read only map" returns the sum of the two