lemon/concepts/graph.h
changeset 1130 0759d974de81
parent 1093 fb1c7da561ce
child 1210 da87dbdf3daf
equal deleted inserted replaced
22:99cb656ba3ad 23:c2b382237846
    25 
    25 
    26 #include <lemon/concepts/graph_components.h>
    26 #include <lemon/concepts/graph_components.h>
    27 #include <lemon/concepts/maps.h>
    27 #include <lemon/concepts/maps.h>
    28 #include <lemon/concept_check.h>
    28 #include <lemon/concept_check.h>
    29 #include <lemon/core.h>
    29 #include <lemon/core.h>
       
    30 #include <lemon/bits/stl_iterators.h>
    30 
    31 
    31 namespace lemon {
    32 namespace lemon {
    32   namespace concepts {
    33   namespace concepts {
    33 
    34 
    34     /// \ingroup graph_concepts
    35     /// \ingroup graph_concepts
   178         /// Assign the iterator to the next node.
   179         /// Assign the iterator to the next node.
   179         ///
   180         ///
   180         NodeIt& operator++() { return *this; }
   181         NodeIt& operator++() { return *this; }
   181       };
   182       };
   182 
   183 
       
   184       /// \brief Gets the collection of the nodes of the graph.
       
   185       ///
       
   186       /// This function can be used for iterating on
       
   187       /// the nodes of the graph. It returns a wrapped NodeIt, which looks
       
   188       /// like an STL container (by having begin() and end())
       
   189       /// which you can use in range-based for loops, STL algorithms, etc.
       
   190       /// For example you can write:
       
   191       ///\code
       
   192       /// ListGraph g;
       
   193       /// for(auto v: g.nodes())
       
   194       ///   doSomething(v);
       
   195       ///
       
   196       /// //Using an STL algorithm:
       
   197       /// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
       
   198       ///\endcode
       
   199       LemonRangeWrapper1<NodeIt, Graph> nodes() const {
       
   200         return LemonRangeWrapper1<NodeIt, Graph>(*this);
       
   201       }
       
   202 
   183 
   203 
   184       /// The edge type of the graph
   204       /// The edge type of the graph
   185 
   205 
   186       /// This class identifies an edge of the graph. It also serves
   206       /// This class identifies an edge of the graph. It also serves
   187       /// as a base class of the edge iterators,
   207       /// as a base class of the edge iterators,
   265 
   285 
   266         /// Assign the iterator to the next edge.
   286         /// Assign the iterator to the next edge.
   267         ///
   287         ///
   268         EdgeIt& operator++() { return *this; }
   288         EdgeIt& operator++() { return *this; }
   269       };
   289       };
       
   290 
       
   291       /// \brief Gets the collection of the edges of the graph.
       
   292       ///
       
   293       /// This function can be used for iterating on the
       
   294       /// edges of the graph. It returns a wrapped
       
   295       /// EdgeIt, which looks like an STL container
       
   296       /// (by having begin() and end()) which you can use in range-based
       
   297       /// for loops, STL algorithms, etc.
       
   298       /// For example you can write:
       
   299       ///\code
       
   300       /// ListGraph g;
       
   301       /// for(auto e: g.edges())
       
   302       ///   doSomething(e);
       
   303       ///
       
   304       /// //Using an STL algorithm:
       
   305       /// copy(g.edges().begin(), g.edges().end(), vect.begin());
       
   306       ///\endcode
       
   307       LemonRangeWrapper1<EdgeIt, Graph> edges() const {
       
   308         return LemonRangeWrapper1<EdgeIt, Graph>(*this);
       
   309       }
       
   310 
   270 
   311 
   271       /// Iterator class for the incident edges of a node.
   312       /// Iterator class for the incident edges of a node.
   272 
   313 
   273       /// This iterator goes trough the incident undirected edges
   314       /// This iterator goes trough the incident undirected edges
   274       /// of a certain node of a graph.
   315       /// of a certain node of a graph.
   314         /// Assign the iterator to the next incident edge
   355         /// Assign the iterator to the next incident edge
   315         /// of the corresponding node.
   356         /// of the corresponding node.
   316         IncEdgeIt& operator++() { return *this; }
   357         IncEdgeIt& operator++() { return *this; }
   317       };
   358       };
   318 
   359 
       
   360       /// \brief Gets the collection of the incident undirected edges
       
   361       ///  of a certain node of the graph.
       
   362       ///
       
   363       /// This function can be used for iterating on the
       
   364       /// incident undirected edges of a certain node of the graph.
       
   365       /// It returns a wrapped
       
   366       /// IncEdgeIt, which looks like an STL container
       
   367       /// (by having begin() and end()) which you can use in range-based
       
   368       /// for loops, STL algorithms, etc.
       
   369       /// For example if g is a Graph and u is a Node, you can write:
       
   370       ///\code
       
   371       /// for(auto e: g.incEdges(u))
       
   372       ///   doSomething(e);
       
   373       ///
       
   374       /// //Using an STL algorithm:
       
   375       /// copy(g.incEdges(u).begin(), g.incEdges(u).end(), vect.begin());
       
   376       ///\endcode
       
   377       LemonRangeWrapper2<IncEdgeIt, Graph, Node> incEdges(const Node& u) const {
       
   378         return LemonRangeWrapper2<IncEdgeIt, Graph, Node>(*this, u);
       
   379       }
       
   380 
       
   381 
   319       /// The arc type of the graph
   382       /// The arc type of the graph
   320 
   383 
   321       /// This class identifies a directed arc of the graph. It also serves
   384       /// This class identifies a directed arc of the graph. It also serves
   322       /// as a base class of the arc iterators,
   385       /// as a base class of the arc iterators,
   323       /// thus they will convert to this type.
   386       /// thus they will convert to this type.
   408 
   471 
   409         /// Assign the iterator to the next arc.
   472         /// Assign the iterator to the next arc.
   410         ///
   473         ///
   411         ArcIt& operator++() { return *this; }
   474         ArcIt& operator++() { return *this; }
   412       };
   475       };
       
   476 
       
   477       /// \brief Gets the collection of the directed arcs of the graph.
       
   478       ///
       
   479       /// This function can be used for iterating on the
       
   480       /// arcs of the graph. It returns a wrapped
       
   481       /// ArcIt, which looks like an STL container
       
   482       /// (by having begin() and end()) which you can use in range-based
       
   483       /// for loops, STL algorithms, etc.
       
   484       /// For example you can write:
       
   485       ///\code
       
   486       /// ListGraph g;
       
   487       /// for(auto a: g.arcs())
       
   488       ///   doSomething(a);
       
   489       ///
       
   490       /// //Using an STL algorithm:
       
   491       /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
       
   492       ///\endcode
       
   493       LemonRangeWrapper1<ArcIt, Graph> arcs() const {
       
   494         return LemonRangeWrapper1<ArcIt, Graph>(*this);
       
   495       }
       
   496 
   413 
   497 
   414       /// Iterator class for the outgoing arcs of a node.
   498       /// Iterator class for the outgoing arcs of a node.
   415 
   499 
   416       /// This iterator goes trough the \e outgoing directed arcs of a
   500       /// This iterator goes trough the \e outgoing directed arcs of a
   417       /// certain node of a graph.
   501       /// certain node of a graph.
   457         /// Assign the iterator to the next
   541         /// Assign the iterator to the next
   458         /// outgoing arc of the corresponding node.
   542         /// outgoing arc of the corresponding node.
   459         OutArcIt& operator++() { return *this; }
   543         OutArcIt& operator++() { return *this; }
   460       };
   544       };
   461 
   545 
       
   546       /// \brief Gets the collection of the outgoing directed arcs of a
       
   547       /// certain node of the graph.
       
   548       ///
       
   549       /// This function can be used for iterating on the
       
   550       /// outgoing arcs of a certain node of the graph. It returns a wrapped
       
   551       /// OutArcIt, which looks like an STL container
       
   552       /// (by having begin() and end()) which you can use in range-based
       
   553       /// for loops, STL algorithms, etc.
       
   554       /// For example if g is a Graph and u is a Node, you can write:
       
   555       ///\code
       
   556       /// for(auto a: g.outArcs(u))
       
   557       ///   doSomething(a);
       
   558       ///
       
   559       /// //Using an STL algorithm:
       
   560       /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
       
   561       ///\endcode
       
   562       LemonRangeWrapper2<OutArcIt, Graph, Node> outArcs(const Node& u) const {
       
   563         return LemonRangeWrapper2<OutArcIt, Graph, Node>(*this, u);
       
   564       }
       
   565 
       
   566 
   462       /// Iterator class for the incoming arcs of a node.
   567       /// Iterator class for the incoming arcs of a node.
   463 
   568 
   464       /// This iterator goes trough the \e incoming directed arcs of a
   569       /// This iterator goes trough the \e incoming directed arcs of a
   465       /// certain node of a graph.
   570       /// certain node of a graph.
   466       /// Its usage is quite simple, for example, you can count the number
   571       /// Its usage is quite simple, for example, you can count the number
   504 
   609 
   505         /// Assign the iterator to the next
   610         /// Assign the iterator to the next
   506         /// incoming arc of the corresponding node.
   611         /// incoming arc of the corresponding node.
   507         InArcIt& operator++() { return *this; }
   612         InArcIt& operator++() { return *this; }
   508       };
   613       };
       
   614 
       
   615       /// \brief Gets the collection of the incoming directed arcs of
       
   616       /// a certain node of the graph.
       
   617       ///
       
   618       /// This function can be used for iterating on the
       
   619       /// incoming directed arcs of a certain node of the graph. It returns
       
   620       /// a wrapped InArcIt, which looks like an STL container
       
   621       /// (by having begin() and end()) which you can use in range-based
       
   622       /// for loops, STL algorithms, etc.
       
   623       /// For example if g is a Graph and u is a Node, you can write:
       
   624       ///\code
       
   625       /// for(auto a: g.inArcs(u))
       
   626       ///   doSomething(a);
       
   627       ///
       
   628       /// //Using an STL algorithm:
       
   629       /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
       
   630       ///\endcode
       
   631       LemonRangeWrapper2<InArcIt, Graph, Node> inArcs(const Node& u) const {
       
   632         return LemonRangeWrapper2<InArcIt, Graph, Node>(*this, u);
       
   633       }
   509 
   634 
   510       /// \brief Standard graph map type for the nodes.
   635       /// \brief Standard graph map type for the nodes.
   511       ///
   636       ///
   512       /// Standard graph map type for the nodes.
   637       /// Standard graph map type for the nodes.
   513       /// It conforms to the ReferenceMap concept.
   638       /// It conforms to the ReferenceMap concept.