[Lemon-commits] [lemon_svn] deba: r1785 - hugo/trunk/src/lemon

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:47:37 CET 2006


Author: deba
Date: Tue Apr 12 19:38:16 2005
New Revision: 1785

Modified:
   hugo/trunk/src/lemon/maps.h

Log:
Source and Target EdgeMap. 


Modified: hugo/trunk/src/lemon/maps.h
==============================================================================
--- hugo/trunk/src/lemon/maps.h	(original)
+++ hugo/trunk/src/lemon/maps.h	Tue Apr 12 19:38:16 2005
@@ -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,T>(m);
   }
 
+  /// \brief Returns the source of the given edge.
+  ///
+  /// The SourceMap gives back the source Node of the given edge. 
+  /// \author Balazs Dezso
+  template <typename Graph>
+  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 <typename Graph>
+  inline SourceMap<Graph> sourceMap(const Graph&) {
+    return SourceMap<Graph>(graph);
+  } 
+
+  /// \brief Returns the target of the given edge.
+  ///
+  /// The TargetMap gives back the target Node of the given edge. 
+  /// \author Balazs Dezso
+  template <typename Graph>
+  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 <typename Graph>
+  inline TargetMap<Graph> targetMap(const Graph&) {
+    return TargetMap<Graph>(graph);
+  }
+
   ///Sum of two maps
 
   ///This \ref concept::ReadMap "read only map" returns the sum of the two



More information about the Lemon-commits mailing list