COIN-OR::LEMON - Graph Library

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


Ignore:
Timestamp:
01/05/14 22:24:56 (10 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?
Location:
lemon/concepts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lemon/concepts/bpgraph.h

    r1092 r1130  
    2828#include <lemon/concept_check.h>
    2929#include <lemon/core.h>
     30#include <lemon/bits/stl_iterators.h>
    3031
    3132namespace lemon {
     
    222223      };
    223224
     225      /// \brief Gets the collection of the red nodes of the graph.
     226      ///
     227      /// This function can be used for iterating on
     228      /// the red nodes of the graph. It returns a wrapped RedNodeIt,
     229      /// which looks like an STL container (by having begin() and end())
     230      /// which you can use in range-based for loops, stl algorithms, etc.
     231      /// For example if g is a BpGraph, you can write:
     232      ///\code
     233      /// for(auto v: g.redNodes())
     234      ///   doSomething(v);
     235      ///\endcode
     236      LemonRangeWrapper1<RedNodeIt, BpGraph> redNodes() const {
     237        return LemonRangeWrapper1<RedNodeIt, BpGraph>(*this);
     238      }
     239
     240
    224241      /// Iterator class for the blue nodes.
    225242
     
    265282      };
    266283
     284      /// \brief Gets the collection of the blue nodes of the graph.
     285      ///
     286      /// This function can be used for iterating on
     287      /// the blue nodes of the graph. It returns a wrapped BlueNodeIt,
     288      /// which looks like an STL container (by having begin() and end())
     289      /// which you can use in range-based for loops, stl algorithms, etc.
     290      /// For example if g is a BpGraph, you can write:
     291      ///\code
     292      /// for(auto v: g.blueNodes())
     293      ///   doSomething(v);
     294      ///\endcode
     295      LemonRangeWrapper1<BlueNodeIt, BpGraph> blueNodes() const {
     296        return LemonRangeWrapper1<BlueNodeIt, BpGraph>(*this);
     297      }
     298
     299
    267300      /// Iterator class for the nodes.
    268301
     
    307340        NodeIt& operator++() { return *this; }
    308341      };
     342
     343      /// \brief Gets the collection of the nodes of the graph.
     344      ///
     345      /// This function can be used for iterating on
     346      /// the nodes of the graph. It returns a wrapped NodeIt,
     347      /// which looks like an STL container (by having begin() and end())
     348      /// which you can use in range-based for loops, stl algorithms, etc.
     349      /// For example if g is a BpGraph, you can write:
     350      ///\code
     351      /// for(auto v: g.nodes())
     352      ///   doSomething(v);
     353      ///\endcode
     354      LemonRangeWrapper1<NodeIt, BpGraph> nodes() const {
     355        return LemonRangeWrapper1<NodeIt, BpGraph>(*this);
     356      }
     357
    309358
    310359
     
    395444        EdgeIt& operator++() { return *this; }
    396445      };
     446
     447      /// \brief Gets the collection of the edges of the graph.
     448      ///
     449      /// This function can be used for iterating on the
     450      /// edges of the graph. It returns a wrapped
     451      /// EdgeIt, which looks like an STL container
     452      /// (by having begin() and end()) which you can use in range-based
     453      /// for loops, stl algorithms, etc.
     454      /// For example if g is a BpGraph, you can write:
     455      ///\code
     456      /// for(auto e: g.edges())
     457      ///   doSomething(e);
     458      ///\endcode
     459      LemonRangeWrapper1<EdgeIt, BpGraph> edges() const {
     460        return LemonRangeWrapper1<EdgeIt, BpGraph>(*this);
     461      }
     462
    397463
    398464      /// Iterator class for the incident edges of a node.
     
    444510      };
    445511
     512      /// \brief Gets the collection of the incident edges
     513      ///  of a certain node of the graph.
     514      ///
     515      /// This function can be used for iterating on the
     516      /// incident undirected edges of a certain node of the graph.
     517      /// It returns a wrapped
     518      /// IncEdgeIt, which looks like an STL container
     519      /// (by having begin() and end()) which you can use in range-based
     520      /// for loops, stl algorithms, etc.
     521      /// For example if g is a BpGraph and u is a Node, you can write:
     522      ///\code
     523      /// for(auto e: g.incEdges(u))
     524      ///   doSomething(e);
     525      ///\endcode
     526      LemonRangeWrapper2<IncEdgeIt, BpGraph, Node> incEdges(const Node& u) const {
     527        return LemonRangeWrapper2<IncEdgeIt, BpGraph, Node>(*this, u);
     528      }
     529
     530
    446531      /// The arc type of the graph
    447532
     
    540625      };
    541626
     627      /// \brief Gets the collection of the directed arcs of the graph.
     628      ///
     629      /// This function can be used for iterating on the
     630      /// arcs of the graph. It returns a wrapped
     631      /// ArcIt, which looks like an STL container
     632      /// (by having begin() and end()) which you can use in range-based
     633      /// for loops, stl algorithms, etc.
     634      /// For example if g is a BpGraph you can write:
     635      ///\code
     636      /// for(auto a: g.arcs())
     637      ///   doSomething(a);
     638      ///\endcode
     639      LemonRangeWrapper1<ArcIt, BpGraph> arcs() const {
     640        return LemonRangeWrapper1<ArcIt, BpGraph>(*this);
     641      }
     642
     643
    542644      /// Iterator class for the outgoing arcs of a node.
    543645
     
    588690      };
    589691
     692      /// \brief Gets the collection of the outgoing directed arcs of a
     693      /// certain node of the graph.
     694      ///
     695      /// This function can be used for iterating on the
     696      /// outgoing arcs of a certain node of the graph. It returns a wrapped
     697      /// OutArcIt, which looks like an STL container
     698      /// (by having begin() and end()) which you can use in range-based
     699      /// for loops, stl algorithms, etc.
     700      /// For example if g is a BpGraph and u is a Node, you can write:
     701      ///\code
     702      /// for(auto a: g.outArcs(u))
     703      ///   doSomething(a);
     704      ///\endcode
     705      LemonRangeWrapper2<OutArcIt, BpGraph, Node> outArcs(const Node& u) const {
     706        return LemonRangeWrapper2<OutArcIt, BpGraph, Node>(*this, u);
     707      }
     708
     709
    590710      /// Iterator class for the incoming arcs of a node.
    591711
     
    635755        InArcIt& operator++() { return *this; }
    636756      };
     757
     758      /// \brief Gets the collection of the incoming directed arcs of a
     759      /// certain node of the graph.
     760      ///
     761      /// This function can be used for iterating on the
     762      /// incoming arcs of a certain node of the graph. It returns a wrapped
     763      /// InArcIt, which looks like an STL container
     764      /// (by having begin() and end()) which you can use in range-based
     765      /// for loops, stl algorithms, etc.
     766      /// For example if g is a BpGraph and u is a Node, you can write:
     767      ///\code
     768      /// for(auto a: g.inArcs(u))
     769      ///   doSomething(a);
     770      ///\endcode
     771      LemonRangeWrapper2<InArcIt, BpGraph, Node> inArcs(const Node& u) const {
     772        return LemonRangeWrapper2<InArcIt, BpGraph, Node>(*this, u);
     773      }
     774
    637775
    638776      /// \brief Standard graph map type for the nodes.
  • lemon/concepts/digraph.h

    r1093 r1130  
    2828#include <lemon/concept_check.h>
    2929#include <lemon/concepts/graph_components.h>
     30#include <lemon/bits/stl_iterators.h>
    3031
    3132namespace lemon {
     
    148149      };
    149150
     151      /// \brief Gets the collection of the nodes of the digraph.
     152      ///
     153      /// This function can be used for iterating on
     154      /// the nodes of the digraph. It returns a wrapped NodeIt, which looks
     155      /// like an STL container (by having begin() and end())
     156      /// which you can use in range-based for loops, STL algorithms, etc.
     157      /// For example you can write:
     158      ///\code
     159      /// ListDigraph g;
     160      /// for(auto v: g.nodes())
     161      ///   doSomething(v);
     162      ///
     163      /// //Using an STL algorithm:
     164      /// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
     165      ///\endcode
     166      LemonRangeWrapper1<NodeIt, Digraph> nodes() const {
     167        return LemonRangeWrapper1<NodeIt, Digraph>(*this);
     168      }
     169
    150170
    151171      /// The arc type of the digraph
     
    238258      };
    239259
     260      /// \brief Gets the collection of the outgoing arcs of a certain node
     261      /// of the digraph.
     262      ///
     263      /// This function can be used for iterating on the
     264      /// outgoing arcs of a certain node of the digraph. It returns a wrapped
     265      /// OutArcIt, which looks like an STL container
     266      /// (by having begin() and end()) which you can use in range-based
     267      /// for loops, STL algorithms, etc.
     268      /// For example if g is a Digraph and u is a node, you can write:
     269      ///\code
     270      /// for(auto a: g.outArcs(u))
     271      ///   doSomething(a);
     272      ///
     273      /// //Using an STL algorithm:
     274      /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
     275      ///\endcode
     276      LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const {
     277        return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u);
     278      }
     279
     280
    240281      /// Iterator class for the incoming arcs of a node.
    241282
     
    283324      };
    284325
     326      /// \brief Gets the collection of the incoming arcs of a certain node
     327      /// of the digraph.
     328      ///
     329      /// This function can be used for iterating on the
     330      /// incoming arcs of a certain node of the digraph. It returns a wrapped
     331      /// InArcIt, which looks like an STL container
     332      /// (by having begin() and end()) which you can use in range-based
     333      /// for loops, STL algorithms, etc.
     334      /// For example if g is a Digraph and u is a node, you can write:
     335      ///\code
     336      /// for(auto a: g.inArcs(u))
     337      ///   doSomething(a);
     338      ///
     339      /// //Using an STL algorithm:
     340      /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
     341      ///\endcode
     342      LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const {
     343        return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u);
     344      }
     345
     346
    285347      /// Iterator class for the arcs.
    286348
     
    327389        ArcIt& operator++() { return *this; }
    328390      };
     391
     392      /// \brief Gets the collection of the arcs of the digraph.
     393      ///
     394      /// This function can be used for iterating on the
     395      /// arcs of the digraph. It returns a wrapped
     396      /// ArcIt, which looks like an STL container
     397      /// (by having begin() and end()) which you can use in range-based
     398      /// for loops, STL algorithms, etc.
     399      /// For example you can write:
     400      ///\code
     401      /// ListDigraph g;
     402      /// for(auto a: g.arcs())
     403      ///   doSomething(a);
     404      ///
     405      /// //Using an STL algorithm:
     406      /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
     407      ///\endcode
     408      LemonRangeWrapper1<ArcIt, Digraph> arcs() const {
     409        return LemonRangeWrapper1<ArcIt, Digraph>(*this);
     410      }
     411
    329412
    330413      /// \brief The source node of the arc.
  • 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.
  • lemon/concepts/path.h

    r1092 r1130  
    2727#include <lemon/core.h>
    2828#include <lemon/concept_check.h>
     29#include <lemon/bits/stl_iterators.h>
    2930
    3031namespace lemon {
     
    116117      };
    117118
     119      /// \brief Gets the collection of the arcs of the path.
     120      ///
     121      /// This function can be used for iterating on the
     122      /// arcs of the path. It returns a wrapped
     123      /// ArcIt, which looks like an STL container
     124      /// (by having begin() and end()) which you can use in range-based
     125      /// for loops, STL algorithms, etc.
     126      /// For example you can write:
     127      ///\code
     128      /// for(auto a: p.arcs())
     129      ///   doSomething(a);
     130      ///\endcode
     131      LemonRangeWrapper1<ArcIt, Path> arcs() const {
     132        return LemonRangeWrapper1<ArcIt, Path>(*this);
     133      }
     134
     135
    118136      template <typename _Path>
    119137      struct Constraints {
     
    264282
    265283      };
     284
     285      /// \brief Gets the collection of the arcs of the path.
     286      ///
     287      /// This function can be used for iterating on the
     288      /// arcs of the path. It returns a wrapped
     289      /// ArcIt, which looks like an STL container
     290      /// (by having begin() and end()) which you can use in range-based
     291      /// for loops, STL algorithms, etc.
     292      /// For example you can write:
     293      ///\code
     294      /// for(auto a: p.arcs())
     295      ///   doSomething(a);
     296      ///\endcode
     297      LemonRangeWrapper1<ArcIt, PathDumper> arcs() const {
     298        return LemonRangeWrapper1<ArcIt, PathDumper>(*this);
     299      }
     300
    266301
    267302      /// \brief LEMON style iterator for enumerating the arcs of a path
     
    294329      };
    295330
     331      /// \brief Gets the collection of the arcs of the path
     332      /// in reverse direction.
     333      ///
     334      /// This function can be used for iterating on the
     335      /// arcs of the path in reverse direction. It returns a wrapped
     336      /// RevArcIt, which looks like an STL container
     337      /// (by having begin() and end()) which you can use in range-based
     338      /// for loops, STL algorithms, etc.
     339      /// For example you can write:
     340      ///\code
     341      /// for(auto a: p.revArcs())
     342      ///   doSomething(a);
     343      ///\endcode
     344      LemonRangeWrapper1<RevArcIt, PathDumper> revArcs() const {
     345        return LemonRangeWrapper1<RevArcIt, PathDumper>(*this);
     346      }
     347
     348
    296349      template <typename _Path>
    297350      struct Constraints {
Note: See TracChangeset for help on using the changeset viewer.