lemon/concepts/digraph.h
changeset 1130 0759d974de81
parent 1093 fb1c7da561ce
child 1210 da87dbdf3daf
     1.1 --- a/lemon/concepts/digraph.h	Thu Apr 02 22:34:03 2015 +0200
     1.2 +++ b/lemon/concepts/digraph.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/concepts/graph_components.h>
     1.7 +#include <lemon/bits/stl_iterators.h>
     1.8  
     1.9  namespace lemon {
    1.10    namespace concepts {
    1.11 @@ -147,6 +148,25 @@
    1.12          NodeIt& operator++() { return *this; }
    1.13        };
    1.14  
    1.15 +      /// \brief Gets the collection of the nodes of the digraph.
    1.16 +      ///
    1.17 +      /// This function can be used for iterating on
    1.18 +      /// the nodes of the digraph. 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 +      /// ListDigraph 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, Digraph> nodes() const {
    1.31 +        return LemonRangeWrapper1<NodeIt, Digraph>(*this);
    1.32 +      }
    1.33 +
    1.34  
    1.35        /// The arc type of the digraph
    1.36  
    1.37 @@ -237,6 +257,27 @@
    1.38          OutArcIt& operator++() { return *this; }
    1.39        };
    1.40  
    1.41 +      /// \brief Gets the collection of the outgoing arcs of a certain node
    1.42 +      /// of the digraph.
    1.43 +      ///
    1.44 +      /// This function can be used for iterating on the
    1.45 +      /// outgoing arcs of a certain node of the digraph. It returns a wrapped
    1.46 +      /// OutArcIt, which looks like an STL container
    1.47 +      /// (by having begin() and end()) which you can use in range-based
    1.48 +      /// for loops, STL algorithms, etc.
    1.49 +      /// For example if g is a Digraph and u is a node, you can write:
    1.50 +      ///\code
    1.51 +      /// for(auto a: g.outArcs(u))
    1.52 +      ///   doSomething(a);
    1.53 +      ///
    1.54 +      /// //Using an STL algorithm:
    1.55 +      /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
    1.56 +      ///\endcode
    1.57 +      LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const {
    1.58 +        return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u);
    1.59 +      }
    1.60 +
    1.61 +
    1.62        /// Iterator class for the incoming arcs of a node.
    1.63  
    1.64        /// This iterator goes trough the \e incoming arcs of a certain node
    1.65 @@ -282,6 +323,27 @@
    1.66          InArcIt& operator++() { return *this; }
    1.67        };
    1.68  
    1.69 +      /// \brief Gets the collection of the incoming arcs of a certain node
    1.70 +      /// of the digraph.
    1.71 +      ///
    1.72 +      /// This function can be used for iterating on the
    1.73 +      /// incoming arcs of a certain node of the digraph. It returns a wrapped
    1.74 +      /// InArcIt, which looks like an STL container
    1.75 +      /// (by having begin() and end()) which you can use in range-based
    1.76 +      /// for loops, STL algorithms, etc.
    1.77 +      /// For example if g is a Digraph and u is a node, you can write:
    1.78 +      ///\code
    1.79 +      /// for(auto a: g.inArcs(u))
    1.80 +      ///   doSomething(a);
    1.81 +      ///
    1.82 +      /// //Using an STL algorithm:
    1.83 +      /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
    1.84 +      ///\endcode
    1.85 +      LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const {
    1.86 +        return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u);
    1.87 +      }
    1.88 +
    1.89 +
    1.90        /// Iterator class for the arcs.
    1.91  
    1.92        /// This iterator goes through each arc of the digraph.
    1.93 @@ -327,6 +389,27 @@
    1.94          ArcIt& operator++() { return *this; }
    1.95        };
    1.96  
    1.97 +      /// \brief Gets the collection of the arcs of the digraph.
    1.98 +      ///
    1.99 +      /// This function can be used for iterating on the
   1.100 +      /// arcs of the digraph. It returns a wrapped
   1.101 +      /// ArcIt, which looks like an STL container
   1.102 +      /// (by having begin() and end()) which you can use in range-based
   1.103 +      /// for loops, STL algorithms, etc.
   1.104 +      /// For example you can write:
   1.105 +      ///\code
   1.106 +      /// ListDigraph g;
   1.107 +      /// for(auto a: g.arcs())
   1.108 +      ///   doSomething(a);
   1.109 +      ///
   1.110 +      /// //Using an STL algorithm:
   1.111 +      /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
   1.112 +      ///\endcode
   1.113 +      LemonRangeWrapper1<ArcIt, Digraph> arcs() const {
   1.114 +        return LemonRangeWrapper1<ArcIt, Digraph>(*this);
   1.115 +      }
   1.116 +
   1.117 +
   1.118        /// \brief The source node of the arc.
   1.119        ///
   1.120        /// Returns the source node of the given arc.