diff -r 39b6e65574c6 -r 0759d974de81 lemon/concepts/graph.h --- a/lemon/concepts/graph.h Thu Apr 02 22:34:03 2015 +0200 +++ b/lemon/concepts/graph.h Sun Jan 05 22:24:56 2014 +0100 @@ -27,6 +27,7 @@ #include #include #include +#include namespace lemon { namespace concepts { @@ -180,6 +181,25 @@ NodeIt& operator++() { return *this; } }; + /// \brief Gets the collection of the nodes of the graph. + /// + /// This function can be used for iterating on + /// the nodes of the graph. It returns a wrapped NodeIt, which looks + /// like an STL container (by having begin() and end()) + /// which you can use in range-based for loops, STL algorithms, etc. + /// For example you can write: + ///\code + /// ListGraph g; + /// for(auto v: g.nodes()) + /// doSomething(v); + /// + /// //Using an STL algorithm: + /// copy(g.nodes().begin(), g.nodes().end(), vect.begin()); + ///\endcode + LemonRangeWrapper1 nodes() const { + return LemonRangeWrapper1(*this); + } + /// The edge type of the graph @@ -268,6 +288,27 @@ EdgeIt& operator++() { return *this; } }; + /// \brief Gets the collection of the edges of the graph. + /// + /// This function can be used for iterating on the + /// edges of the graph. It returns a wrapped + /// EdgeIt, which looks like an STL container + /// (by having begin() and end()) which you can use in range-based + /// for loops, STL algorithms, etc. + /// For example you can write: + ///\code + /// ListGraph g; + /// for(auto e: g.edges()) + /// doSomething(e); + /// + /// //Using an STL algorithm: + /// copy(g.edges().begin(), g.edges().end(), vect.begin()); + ///\endcode + LemonRangeWrapper1 edges() const { + return LemonRangeWrapper1(*this); + } + + /// Iterator class for the incident edges of a node. /// This iterator goes trough the incident undirected edges @@ -316,6 +357,28 @@ IncEdgeIt& operator++() { return *this; } }; + /// \brief Gets the collection of the incident undirected edges + /// of a certain node of the graph. + /// + /// This function can be used for iterating on the + /// incident undirected edges of a certain node of the graph. + /// It returns a wrapped + /// IncEdgeIt, which looks like an STL container + /// (by having begin() and end()) which you can use in range-based + /// for loops, STL algorithms, etc. + /// For example if g is a Graph and u is a Node, you can write: + ///\code + /// for(auto e: g.incEdges(u)) + /// doSomething(e); + /// + /// //Using an STL algorithm: + /// copy(g.incEdges(u).begin(), g.incEdges(u).end(), vect.begin()); + ///\endcode + LemonRangeWrapper2 incEdges(const Node& u) const { + return LemonRangeWrapper2(*this, u); + } + + /// The arc type of the graph /// This class identifies a directed arc of the graph. It also serves @@ -411,6 +474,27 @@ ArcIt& operator++() { return *this; } }; + /// \brief Gets the collection of the directed arcs of the graph. + /// + /// This function can be used for iterating on the + /// arcs of the graph. It returns a wrapped + /// ArcIt, which looks like an STL container + /// (by having begin() and end()) which you can use in range-based + /// for loops, STL algorithms, etc. + /// For example you can write: + ///\code + /// ListGraph g; + /// for(auto a: g.arcs()) + /// doSomething(a); + /// + /// //Using an STL algorithm: + /// copy(g.arcs().begin(), g.arcs().end(), vect.begin()); + ///\endcode + LemonRangeWrapper1 arcs() const { + return LemonRangeWrapper1(*this); + } + + /// Iterator class for the outgoing arcs of a node. /// This iterator goes trough the \e outgoing directed arcs of a @@ -459,6 +543,27 @@ OutArcIt& operator++() { return *this; } }; + /// \brief Gets the collection of the outgoing directed arcs of a + /// certain node of the graph. + /// + /// This function can be used for iterating on the + /// outgoing arcs of a certain node of the graph. It returns a wrapped + /// OutArcIt, which looks like an STL container + /// (by having begin() and end()) which you can use in range-based + /// for loops, STL algorithms, etc. + /// For example if g is a Graph and u is a Node, you can write: + ///\code + /// for(auto a: g.outArcs(u)) + /// doSomething(a); + /// + /// //Using an STL algorithm: + /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin()); + ///\endcode + LemonRangeWrapper2 outArcs(const Node& u) const { + return LemonRangeWrapper2(*this, u); + } + + /// Iterator class for the incoming arcs of a node. /// This iterator goes trough the \e incoming directed arcs of a @@ -507,6 +612,26 @@ InArcIt& operator++() { return *this; } }; + /// \brief Gets the collection of the incoming directed arcs of + /// a certain node of the graph. + /// + /// This function can be used for iterating on the + /// incoming directed arcs of a certain node of the graph. It returns + /// a wrapped InArcIt, which looks like an STL container + /// (by having begin() and end()) which you can use in range-based + /// for loops, STL algorithms, etc. + /// For example if g is a Graph and u is a Node, you can write: + ///\code + /// for(auto a: g.inArcs(u)) + /// doSomething(a); + /// + /// //Using an STL algorithm: + /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin()); + ///\endcode + LemonRangeWrapper2 inArcs(const Node& u) const { + return LemonRangeWrapper2(*this, u); + } + /// \brief Standard graph map type for the nodes. /// /// Standard graph map type for the nodes.