diff -r 39b6e65574c6 -r 0759d974de81 lemon/concepts/digraph.h --- a/lemon/concepts/digraph.h Thu Apr 02 22:34:03 2015 +0200 +++ b/lemon/concepts/digraph.h Sun Jan 05 22:24:56 2014 +0100 @@ -27,6 +27,7 @@ #include #include #include +#include namespace lemon { namespace concepts { @@ -147,6 +148,25 @@ NodeIt& operator++() { return *this; } }; + /// \brief Gets the collection of the nodes of the digraph. + /// + /// This function can be used for iterating on + /// the nodes of the digraph. 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 + /// ListDigraph 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 arc type of the digraph @@ -237,6 +257,27 @@ OutArcIt& operator++() { return *this; } }; + /// \brief Gets the collection of the outgoing arcs of a certain node + /// of the digraph. + /// + /// This function can be used for iterating on the + /// outgoing arcs of a certain node of the digraph. 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 Digraph 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 arcs of a certain node @@ -282,6 +323,27 @@ InArcIt& operator++() { return *this; } }; + /// \brief Gets the collection of the incoming arcs of a certain node + /// of the digraph. + /// + /// This function can be used for iterating on the + /// incoming arcs of a certain node of the digraph. 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 Digraph 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); + } + + /// Iterator class for the arcs. /// This iterator goes through each arc of the digraph. @@ -327,6 +389,27 @@ ArcIt& operator++() { return *this; } }; + /// \brief Gets the collection of the arcs of the digraph. + /// + /// This function can be used for iterating on the + /// arcs of the digraph. 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 + /// ListDigraph 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); + } + + /// \brief The source node of the arc. /// /// Returns the source node of the given arc.