COIN-OR::LEMON - Graph Library

Changeset 1130:0759d974de81 in lemon-main for lemon/concepts/graph.h


Ignore:
Timestamp:
01/05/14 22:24:56 (6 years ago)
Author:
Gabor Gevay <ggab90@…>
Branch:
default
Phase:
public
Message:

STL style iterators (#325)

For

  • graph types,
  • graph adaptors,
  • paths,
  • iterable maps,
  • LP rows/cols and
  • active nodes is BellmanFord?
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/concepts/graph.h

    r1093 r1130  
    2828#include <lemon/concept_check.h>
    2929#include <lemon/core.h>
     30#include <lemon/bits/stl_iterators.h>
    3031
    3132namespace lemon {
     
    181182      };
    182183
     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
    183203
    184204      /// The edge type of the graph
     
    268288        EdgeIt& operator++() { return *this; }
    269289      };
     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
    270311
    271312      /// Iterator class for the incident edges of a node.
     
    317358      };
    318359
     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
    319382      /// The arc type of the graph
    320383
     
    411474        ArcIt& operator++() { return *this; }
    412475      };
     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
    413497
    414498      /// Iterator class for the outgoing arcs of a node.
     
    460544      };
    461545
     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
    462567      /// Iterator class for the incoming arcs of a node.
    463568
     
    507612        InArcIt& operator++() { return *this; }
    508613      };
     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      }
    509634
    510635      /// \brief Standard graph map type for the nodes.
Note: See TracChangeset for help on using the changeset viewer.