lemon/concepts/graph.h
changeset 1130 0759d974de81
parent 1093 fb1c7da561ce
child 1210 da87dbdf3daf
     1.1 --- a/lemon/concepts/graph.h	Thu Apr 02 22:34:03 2015 +0200
     1.2 +++ b/lemon/concepts/graph.h	Sun Jan 05 22:24:56 2014 +0100
     1.3 @@ -27,6 +27,7 @@
     1.4  #include <lemon/concepts/maps.h>
     1.5  #include <lemon/concept_check.h>
     1.6  #include <lemon/core.h>
     1.7 +#include <lemon/bits/stl_iterators.h>
     1.8  
     1.9  namespace lemon {
    1.10    namespace concepts {
    1.11 @@ -180,6 +181,25 @@
    1.12          NodeIt& operator++() { return *this; }
    1.13        };
    1.14  
    1.15 +      /// \brief Gets the collection of the nodes of the graph.
    1.16 +      ///
    1.17 +      /// This function can be used for iterating on
    1.18 +      /// the nodes of the graph. It returns a wrapped NodeIt, which looks
    1.19 +      /// like an STL container (by having begin() and end())
    1.20 +      /// which you can use in range-based for loops, STL algorithms, etc.
    1.21 +      /// For example you can write:
    1.22 +      ///\code
    1.23 +      /// ListGraph g;
    1.24 +      /// for(auto v: g.nodes())
    1.25 +      ///   doSomething(v);
    1.26 +      ///
    1.27 +      /// //Using an STL algorithm:
    1.28 +      /// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
    1.29 +      ///\endcode
    1.30 +      LemonRangeWrapper1<NodeIt, Graph> nodes() const {
    1.31 +        return LemonRangeWrapper1<NodeIt, Graph>(*this);
    1.32 +      }
    1.33 +
    1.34  
    1.35        /// The edge type of the graph
    1.36  
    1.37 @@ -268,6 +288,27 @@
    1.38          EdgeIt& operator++() { return *this; }
    1.39        };
    1.40  
    1.41 +      /// \brief Gets the collection of the edges of the graph.
    1.42 +      ///
    1.43 +      /// This function can be used for iterating on the
    1.44 +      /// edges of the graph. It returns a wrapped
    1.45 +      /// EdgeIt, which looks like an STL container
    1.46 +      /// (by having begin() and end()) which you can use in range-based
    1.47 +      /// for loops, STL algorithms, etc.
    1.48 +      /// For example you can write:
    1.49 +      ///\code
    1.50 +      /// ListGraph g;
    1.51 +      /// for(auto e: g.edges())
    1.52 +      ///   doSomething(e);
    1.53 +      ///
    1.54 +      /// //Using an STL algorithm:
    1.55 +      /// copy(g.edges().begin(), g.edges().end(), vect.begin());
    1.56 +      ///\endcode
    1.57 +      LemonRangeWrapper1<EdgeIt, Graph> edges() const {
    1.58 +        return LemonRangeWrapper1<EdgeIt, Graph>(*this);
    1.59 +      }
    1.60 +
    1.61 +
    1.62        /// Iterator class for the incident edges of a node.
    1.63  
    1.64        /// This iterator goes trough the incident undirected edges
    1.65 @@ -316,6 +357,28 @@
    1.66          IncEdgeIt& operator++() { return *this; }
    1.67        };
    1.68  
    1.69 +      /// \brief Gets the collection of the incident undirected edges
    1.70 +      ///  of a certain node of the graph.
    1.71 +      ///
    1.72 +      /// This function can be used for iterating on the
    1.73 +      /// incident undirected edges of a certain node of the graph.
    1.74 +      /// It returns a wrapped
    1.75 +      /// IncEdgeIt, which looks like an STL container
    1.76 +      /// (by having begin() and end()) which you can use in range-based
    1.77 +      /// for loops, STL algorithms, etc.
    1.78 +      /// For example if g is a Graph and u is a Node, you can write:
    1.79 +      ///\code
    1.80 +      /// for(auto e: g.incEdges(u))
    1.81 +      ///   doSomething(e);
    1.82 +      ///
    1.83 +      /// //Using an STL algorithm:
    1.84 +      /// copy(g.incEdges(u).begin(), g.incEdges(u).end(), vect.begin());
    1.85 +      ///\endcode
    1.86 +      LemonRangeWrapper2<IncEdgeIt, Graph, Node> incEdges(const Node& u) const {
    1.87 +        return LemonRangeWrapper2<IncEdgeIt, Graph, Node>(*this, u);
    1.88 +      }
    1.89 +
    1.90 +
    1.91        /// The arc type of the graph
    1.92  
    1.93        /// This class identifies a directed arc of the graph. It also serves
    1.94 @@ -411,6 +474,27 @@
    1.95          ArcIt& operator++() { return *this; }
    1.96        };
    1.97  
    1.98 +      /// \brief Gets the collection of the directed arcs of the graph.
    1.99 +      ///
   1.100 +      /// This function can be used for iterating on the
   1.101 +      /// arcs of the graph. It returns a wrapped
   1.102 +      /// ArcIt, which looks like an STL container
   1.103 +      /// (by having begin() and end()) which you can use in range-based
   1.104 +      /// for loops, STL algorithms, etc.
   1.105 +      /// For example you can write:
   1.106 +      ///\code
   1.107 +      /// ListGraph g;
   1.108 +      /// for(auto a: g.arcs())
   1.109 +      ///   doSomething(a);
   1.110 +      ///
   1.111 +      /// //Using an STL algorithm:
   1.112 +      /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
   1.113 +      ///\endcode
   1.114 +      LemonRangeWrapper1<ArcIt, Graph> arcs() const {
   1.115 +        return LemonRangeWrapper1<ArcIt, Graph>(*this);
   1.116 +      }
   1.117 +
   1.118 +
   1.119        /// Iterator class for the outgoing arcs of a node.
   1.120  
   1.121        /// This iterator goes trough the \e outgoing directed arcs of a
   1.122 @@ -459,6 +543,27 @@
   1.123          OutArcIt& operator++() { return *this; }
   1.124        };
   1.125  
   1.126 +      /// \brief Gets the collection of the outgoing directed arcs of a
   1.127 +      /// certain node of the graph.
   1.128 +      ///
   1.129 +      /// This function can be used for iterating on the
   1.130 +      /// outgoing arcs of a certain node of the graph. It returns a wrapped
   1.131 +      /// OutArcIt, which looks like an STL container
   1.132 +      /// (by having begin() and end()) which you can use in range-based
   1.133 +      /// for loops, STL algorithms, etc.
   1.134 +      /// For example if g is a Graph and u is a Node, you can write:
   1.135 +      ///\code
   1.136 +      /// for(auto a: g.outArcs(u))
   1.137 +      ///   doSomething(a);
   1.138 +      ///
   1.139 +      /// //Using an STL algorithm:
   1.140 +      /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
   1.141 +      ///\endcode
   1.142 +      LemonRangeWrapper2<OutArcIt, Graph, Node> outArcs(const Node& u) const {
   1.143 +        return LemonRangeWrapper2<OutArcIt, Graph, Node>(*this, u);
   1.144 +      }
   1.145 +
   1.146 +
   1.147        /// Iterator class for the incoming arcs of a node.
   1.148  
   1.149        /// This iterator goes trough the \e incoming directed arcs of a
   1.150 @@ -507,6 +612,26 @@
   1.151          InArcIt& operator++() { return *this; }
   1.152        };
   1.153  
   1.154 +      /// \brief Gets the collection of the incoming directed arcs of
   1.155 +      /// a certain node of the graph.
   1.156 +      ///
   1.157 +      /// This function can be used for iterating on the
   1.158 +      /// incoming directed arcs of a certain node of the graph. It returns
   1.159 +      /// a wrapped InArcIt, which looks like an STL container
   1.160 +      /// (by having begin() and end()) which you can use in range-based
   1.161 +      /// for loops, STL algorithms, etc.
   1.162 +      /// For example if g is a Graph and u is a Node, you can write:
   1.163 +      ///\code
   1.164 +      /// for(auto a: g.inArcs(u))
   1.165 +      ///   doSomething(a);
   1.166 +      ///
   1.167 +      /// //Using an STL algorithm:
   1.168 +      /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
   1.169 +      ///\endcode
   1.170 +      LemonRangeWrapper2<InArcIt, Graph, Node> inArcs(const Node& u) const {
   1.171 +        return LemonRangeWrapper2<InArcIt, Graph, Node>(*this, u);
   1.172 +      }
   1.173 +
   1.174        /// \brief Standard graph map type for the nodes.
   1.175        ///
   1.176        /// Standard graph map type for the nodes.