COIN-OR::LEMON - Graph Library

source: lemon/lemon/concepts/graph.h

Last change on this file was 1432:da87dbdf3daf, checked in by Alpar Juttner <alpar@…>, 4 years ago

Resolve deprecation warnings of gcc 9 (#633)

File size: 31.5 KB
RevLine 
[209]1/* -*- mode: C++; indent-tabs-mode: nil; -*-
[57]2 *
[209]3 * This file is a part of LEMON, a generic C++ optimization library.
[57]4 *
[1270]5 * Copyright (C) 2003-2013
[57]6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 *
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
12 *
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
15 * purpose.
16 *
17 */
18
19///\ingroup graph_concepts
20///\file
[781]21///\brief The concept of undirected graphs.
[57]22
[576]23#ifndef LEMON_CONCEPTS_GRAPH_H
24#define LEMON_CONCEPTS_GRAPH_H
[57]25
26#include <lemon/concepts/graph_components.h>
[781]27#include <lemon/concepts/maps.h>
28#include <lemon/concept_check.h>
[220]29#include <lemon/core.h>
[1336]30#include <lemon/bits/stl_iterators.h>
[57]31
32namespace lemon {
33  namespace concepts {
34
35    /// \ingroup graph_concepts
36    ///
[781]37    /// \brief Class describing the concept of undirected graphs.
[57]38    ///
[781]39    /// This class describes the common interface of all undirected
40    /// graphs.
[57]41    ///
[781]42    /// Like all concept classes, it only provides an interface
43    /// without any sensible implementation. So any general algorithm for
44    /// undirected graphs should compile with this class, but it will not
[57]45    /// run properly, of course.
[781]46    /// An actual graph implementation like \ref ListGraph or
[956]47    /// \ref SmartGraph may have additional functionality.
[57]48    ///
[781]49    /// The undirected graphs also fulfill the concept of \ref Digraph
50    /// "directed graphs", since each edge can also be regarded as two
51    /// oppositely directed arcs.
52    /// Undirected graphs provide an Edge type for the undirected edges and
53    /// an Arc type for the directed arcs. The Arc type is convertible to
54    /// Edge or inherited from it, i.e. the corresponding edge can be
55    /// obtained from an arc.
56    /// EdgeIt and EdgeMap classes can be used for the edges, while ArcIt
57    /// and ArcMap classes can be used for the arcs (just like in digraphs).
58    /// Both InArcIt and OutArcIt iterates on the same edges but with
59    /// opposite direction. IncEdgeIt also iterates on the same edges
60    /// as OutArcIt and InArcIt, but it is not convertible to Arc,
61    /// only to Edge.
[57]62    ///
[781]63    /// In LEMON, each undirected edge has an inherent orientation.
64    /// Thus it can defined if an arc is forward or backward oriented in
65    /// an undirected graph with respect to this default oriantation of
66    /// the represented edge.
67    /// With the direction() and direct() functions the direction
68    /// of an arc can be obtained and set, respectively.
[57]69    ///
[781]70    /// Only nodes and edges can be added to or removed from an undirected
71    /// graph and the corresponding arcs are added or removed automatically.
72    ///
73    /// \sa Digraph
[57]74    class Graph {
[781]75    private:
[1186]76      /// Graphs are \e not copy constructible. Use GraphCopy instead.
[781]77      Graph(const Graph&) {}
78      /// \brief Assignment of a graph to another one is \e not allowed.
[1186]79      /// Use GraphCopy instead.
[781]80      void operator=(const Graph&) {}
81
[57]82    public:
[781]83      /// Default constructor.
84      Graph() {}
85
86      /// \brief Undirected graphs should be tagged with \c UndirectedTag.
[57]87      ///
[781]88      /// Undirected graphs should be tagged with \c UndirectedTag.
[956]89      ///
[781]90      /// This tag helps the \c enable_if technics to make compile time
[209]91      /// specializations for undirected graphs.
[57]92      typedef True UndirectedTag;
93
[781]94      /// The node type of the graph
95
96      /// This class identifies a node of the graph. It also serves
97      /// as a base class of the node iterators,
98      /// thus they convert to this type.
[57]99      class Node {
100      public:
101        /// Default constructor
102
[781]103        /// Default constructor.
104        /// \warning It sets the object to an undefined value.
[57]105        Node() { }
106        /// Copy constructor.
107
108        /// Copy constructor.
109        ///
110        Node(const Node&) { }
[1432]111        /// Assignment operator
112
113        /// Assignment operator.
114        ///
115        const Node &operator=(const Node&) { return *this; }
[57]116
[781]117        /// %Invalid constructor \& conversion.
[57]118
[781]119        /// Initializes the object to be invalid.
[57]120        /// \sa Invalid for more details.
121        Node(Invalid) { }
122        /// Equality operator
123
[781]124        /// Equality operator.
125        ///
[57]126        /// Two iterators are equal if and only if they point to the
[781]127        /// same object or both are \c INVALID.
[57]128        bool operator==(Node) const { return true; }
129
130        /// Inequality operator
[209]131
[781]132        /// Inequality operator.
[57]133        bool operator!=(Node) const { return true; }
134
[209]135        /// Artificial ordering operator.
136
[781]137        /// Artificial ordering operator.
[209]138        ///
[781]139        /// \note This operator only has to define some strict ordering of
[209]140        /// the items; this order has nothing to do with the iteration
141        /// ordering of the items.
142        bool operator<(Node) const { return false; }
[57]143
144      };
[209]145
[781]146      /// Iterator class for the nodes.
[57]147
[781]148      /// This iterator goes through each node of the graph.
[833]149      /// Its usage is quite simple, for example, you can count the number
[781]150      /// of nodes in a graph \c g of type \c %Graph like this:
[57]151      ///\code
152      /// int count=0;
153      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
154      ///\endcode
155      class NodeIt : public Node {
156      public:
157        /// Default constructor
158
[781]159        /// Default constructor.
160        /// \warning It sets the iterator to an undefined value.
[57]161        NodeIt() { }
162        /// Copy constructor.
[209]163
[57]164        /// Copy constructor.
165        ///
166        NodeIt(const NodeIt& n) : Node(n) { }
[1432]167        /// Assignment operator
168
169        /// Assignment operator.
170        ///
171        const NodeIt &operator=(const NodeIt&) { return *this; }
172
[781]173        /// %Invalid constructor \& conversion.
[57]174
[781]175        /// Initializes the iterator to be invalid.
[57]176        /// \sa Invalid for more details.
177        NodeIt(Invalid) { }
178        /// Sets the iterator to the first node.
179
[781]180        /// Sets the iterator to the first node of the given digraph.
[57]181        ///
[781]182        explicit NodeIt(const Graph&) { }
183        /// Sets the iterator to the given node.
[57]184
[781]185        /// Sets the iterator to the given node of the given digraph.
186        ///
[57]187        NodeIt(const Graph&, const Node&) { }
188        /// Next node.
189
190        /// Assign the iterator to the next node.
191        ///
192        NodeIt& operator++() { return *this; }
193      };
[209]194
[1336]195      /// \brief Gets the collection of the nodes of the graph.
196      ///
197      /// This function can be used for iterating on
198      /// the nodes of the graph. It returns a wrapped NodeIt, which looks
199      /// like an STL container (by having begin() and end())
200      /// which you can use in range-based for loops, STL algorithms, etc.
201      /// For example you can write:
202      ///\code
203      /// ListGraph g;
204      /// for(auto v: g.nodes())
205      ///   doSomething(v);
206      ///
207      /// //Using an STL algorithm:
208      /// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
209      ///\endcode
210      LemonRangeWrapper1<NodeIt, Graph> nodes() const {
211        return LemonRangeWrapper1<NodeIt, Graph>(*this);
212      }
213
[209]214
[781]215      /// The edge type of the graph
[57]216
[781]217      /// This class identifies an edge of the graph. It also serves
218      /// as a base class of the edge iterators,
219      /// thus they will convert to this type.
[57]220      class Edge {
221      public:
222        /// Default constructor
223
[781]224        /// Default constructor.
225        /// \warning It sets the object to an undefined value.
[57]226        Edge() { }
227        /// Copy constructor.
228
229        /// Copy constructor.
230        ///
231        Edge(const Edge&) { }
[1432]232        /// Assignment operator
233
234        /// Assignment operator.
235        ///
236        const Edge &operator=(const Edge&) { return *this; }
237
[781]238        /// %Invalid constructor \& conversion.
[57]239
[781]240        /// Initializes the object to be invalid.
241        /// \sa Invalid for more details.
[57]242        Edge(Invalid) { }
243        /// Equality operator
244
[781]245        /// Equality operator.
246        ///
[57]247        /// Two iterators are equal if and only if they point to the
[781]248        /// same object or both are \c INVALID.
[57]249        bool operator==(Edge) const { return true; }
250        /// Inequality operator
251
[781]252        /// Inequality operator.
[57]253        bool operator!=(Edge) const { return true; }
254
[209]255        /// Artificial ordering operator.
256
[781]257        /// Artificial ordering operator.
[209]258        ///
[781]259        /// \note This operator only has to define some strict ordering of
260        /// the edges; this order has nothing to do with the iteration
261        /// ordering of the edges.
[209]262        bool operator<(Edge) const { return false; }
[57]263      };
264
[781]265      /// Iterator class for the edges.
[57]266
[781]267      /// This iterator goes through each edge of the graph.
[833]268      /// Its usage is quite simple, for example, you can count the number
[781]269      /// of edges in a graph \c g of type \c %Graph as follows:
[57]270      ///\code
271      /// int count=0;
272      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
273      ///\endcode
274      class EdgeIt : public Edge {
275      public:
276        /// Default constructor
277
[781]278        /// Default constructor.
279        /// \warning It sets the iterator to an undefined value.
[57]280        EdgeIt() { }
281        /// Copy constructor.
282
283        /// Copy constructor.
284        ///
285        EdgeIt(const EdgeIt& e) : Edge(e) { }
[1432]286        /// Assignment operator
287
288        /// Assignment operator.
289        ///
290        const EdgeIt &operator=(const EdgeIt&) { return *this; }
291
[781]292        /// %Invalid constructor \& conversion.
[57]293
[781]294        /// Initializes the iterator to be invalid.
295        /// \sa Invalid for more details.
296        EdgeIt(Invalid) { }
297        /// Sets the iterator to the first edge.
298
299        /// Sets the iterator to the first edge of the given graph.
[57]300        ///
[781]301        explicit EdgeIt(const Graph&) { }
302        /// Sets the iterator to the given edge.
[209]303
[781]304        /// Sets the iterator to the given edge of the given graph.
305        ///
[209]306        EdgeIt(const Graph&, const Edge&) { }
[57]307        /// Next edge
[209]308
[57]309        /// Assign the iterator to the next edge.
[781]310        ///
[57]311        EdgeIt& operator++() { return *this; }
312      };
313
[1336]314      /// \brief Gets the collection of the edges of the graph.
315      ///
316      /// This function can be used for iterating on the
317      /// edges of the graph. It returns a wrapped
318      /// EdgeIt, which looks like an STL container
319      /// (by having begin() and end()) which you can use in range-based
320      /// for loops, STL algorithms, etc.
321      /// For example you can write:
322      ///\code
323      /// ListGraph g;
324      /// for(auto e: g.edges())
325      ///   doSomething(e);
326      ///
327      /// //Using an STL algorithm:
328      /// copy(g.edges().begin(), g.edges().end(), vect.begin());
329      ///\endcode
330      LemonRangeWrapper1<EdgeIt, Graph> edges() const {
331        return LemonRangeWrapper1<EdgeIt, Graph>(*this);
332      }
333
334
[781]335      /// Iterator class for the incident edges of a node.
336
337      /// This iterator goes trough the incident undirected edges
338      /// of a certain node of a graph.
[833]339      /// Its usage is quite simple, for example, you can compute the
[781]340      /// degree (i.e. the number of incident edges) of a node \c n
341      /// in a graph \c g of type \c %Graph as follows.
[57]342      ///
343      ///\code
344      /// int count=0;
[78]345      /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
[57]346      ///\endcode
[781]347      ///
348      /// \warning Loop edges will be iterated twice.
[78]349      class IncEdgeIt : public Edge {
[57]350      public:
351        /// Default constructor
352
[781]353        /// Default constructor.
354        /// \warning It sets the iterator to an undefined value.
[78]355        IncEdgeIt() { }
[57]356        /// Copy constructor.
357
358        /// Copy constructor.
359        ///
[78]360        IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
[1432]361        /// Assignment operator
362
363        /// Assignment operator.
364        ///
365        const IncEdgeIt &operator=(const IncEdgeIt&) { return *this; }
366
[781]367        /// %Invalid constructor \& conversion.
[57]368
[781]369        /// Initializes the iterator to be invalid.
370        /// \sa Invalid for more details.
371        IncEdgeIt(Invalid) { }
372        /// Sets the iterator to the first incident edge.
373
374        /// Sets the iterator to the first incident edge of the given node.
[57]375        ///
[781]376        IncEdgeIt(const Graph&, const Node&) { }
377        /// Sets the iterator to the given edge.
[209]378
[781]379        /// Sets the iterator to the given edge of the given graph.
380        ///
381        IncEdgeIt(const Graph&, const Edge&) { }
382        /// Next incident edge
[57]383
[781]384        /// Assign the iterator to the next incident edge
[209]385        /// of the corresponding node.
[78]386        IncEdgeIt& operator++() { return *this; }
[57]387      };
388
[1336]389      /// \brief Gets the collection of the incident undirected edges
390      ///  of a certain node of the graph.
391      ///
392      /// This function can be used for iterating on the
393      /// incident undirected edges of a certain node of the graph.
394      /// It returns a wrapped
395      /// IncEdgeIt, which looks like an STL container
396      /// (by having begin() and end()) which you can use in range-based
397      /// for loops, STL algorithms, etc.
398      /// For example if g is a Graph and u is a Node, you can write:
399      ///\code
400      /// for(auto e: g.incEdges(u))
401      ///   doSomething(e);
402      ///
403      /// //Using an STL algorithm:
404      /// copy(g.incEdges(u).begin(), g.incEdges(u).end(), vect.begin());
405      ///\endcode
406      LemonRangeWrapper2<IncEdgeIt, Graph, Node> incEdges(const Node& u) const {
407        return LemonRangeWrapper2<IncEdgeIt, Graph, Node>(*this, u);
408      }
409
410
[781]411      /// The arc type of the graph
[57]412
[781]413      /// This class identifies a directed arc of the graph. It also serves
414      /// as a base class of the arc iterators,
415      /// thus they will convert to this type.
[704]416      class Arc {
[57]417      public:
418        /// Default constructor
419
[781]420        /// Default constructor.
421        /// \warning It sets the object to an undefined value.
[57]422        Arc() { }
423        /// Copy constructor.
424
425        /// Copy constructor.
426        ///
[704]427        Arc(const Arc&) { }
[1432]428        /// Assignment operator
429
430        /// Assignment operator.
431        ///
432        const Arc &operator=(const Arc&) { return *this; }
433
[781]434        /// %Invalid constructor \& conversion.
[57]435
[781]436        /// Initializes the object to be invalid.
437        /// \sa Invalid for more details.
[57]438        Arc(Invalid) { }
439        /// Equality operator
440
[781]441        /// Equality operator.
442        ///
[57]443        /// Two iterators are equal if and only if they point to the
[781]444        /// same object or both are \c INVALID.
[57]445        bool operator==(Arc) const { return true; }
446        /// Inequality operator
447
[781]448        /// Inequality operator.
[57]449        bool operator!=(Arc) const { return true; }
450
[209]451        /// Artificial ordering operator.
452
[781]453        /// Artificial ordering operator.
[209]454        ///
[781]455        /// \note This operator only has to define some strict ordering of
456        /// the arcs; this order has nothing to do with the iteration
457        /// ordering of the arcs.
[209]458        bool operator<(Arc) const { return false; }
459
[781]460        /// Converison to \c Edge
[956]461
[781]462        /// Converison to \c Edge.
463        ///
[704]464        operator Edge() const { return Edge(); }
[209]465      };
[57]466
[781]467      /// Iterator class for the arcs.
468
469      /// This iterator goes through each directed arc of the graph.
[833]470      /// Its usage is quite simple, for example, you can count the number
[781]471      /// of arcs in a graph \c g of type \c %Graph as follows:
[57]472      ///\code
473      /// int count=0;
[781]474      /// for(Graph::ArcIt a(g); a!=INVALID; ++a) ++count;
[57]475      ///\endcode
476      class ArcIt : public Arc {
477      public:
478        /// Default constructor
479
[781]480        /// Default constructor.
481        /// \warning It sets the iterator to an undefined value.
[57]482        ArcIt() { }
483        /// Copy constructor.
484
485        /// Copy constructor.
486        ///
487        ArcIt(const ArcIt& e) : Arc(e) { }
[1432]488        /// Assignment operator
489
490        /// Assignment operator.
491        ///
492        const ArcIt &operator=(const ArcIt&) { return *this; }
493
[781]494        /// %Invalid constructor \& conversion.
[57]495
[781]496        /// Initializes the iterator to be invalid.
497        /// \sa Invalid for more details.
498        ArcIt(Invalid) { }
499        /// Sets the iterator to the first arc.
500
501        /// Sets the iterator to the first arc of the given graph.
[57]502        ///
[1271]503        explicit ArcIt(const Graph &g) {
504          ::lemon::ignore_unused_variable_warning(g);
505        }
[781]506        /// Sets the iterator to the given arc.
[209]507
[781]508        /// Sets the iterator to the given arc of the given graph.
509        ///
[209]510        ArcIt(const Graph&, const Arc&) { }
[781]511        /// Next arc
[209]512
[57]513        /// Assign the iterator to the next arc.
[781]514        ///
[57]515        ArcIt& operator++() { return *this; }
516      };
[209]517
[1336]518      /// \brief Gets the collection of the directed arcs of the graph.
519      ///
520      /// This function can be used for iterating on the
521      /// arcs of the graph. It returns a wrapped
522      /// ArcIt, which looks like an STL container
523      /// (by having begin() and end()) which you can use in range-based
524      /// for loops, STL algorithms, etc.
525      /// For example you can write:
526      ///\code
527      /// ListGraph g;
528      /// for(auto a: g.arcs())
529      ///   doSomething(a);
530      ///
531      /// //Using an STL algorithm:
532      /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
533      ///\endcode
534      LemonRangeWrapper1<ArcIt, Graph> arcs() const {
535        return LemonRangeWrapper1<ArcIt, Graph>(*this);
536      }
537
538
[781]539      /// Iterator class for the outgoing arcs of a node.
[57]540
[781]541      /// This iterator goes trough the \e outgoing directed arcs of a
542      /// certain node of a graph.
[833]543      /// Its usage is quite simple, for example, you can count the number
[57]544      /// of outgoing arcs of a node \c n
[781]545      /// in a graph \c g of type \c %Graph as follows.
[57]546      ///\code
547      /// int count=0;
[781]548      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
[57]549      ///\endcode
550      class OutArcIt : public Arc {
551      public:
552        /// Default constructor
553
[781]554        /// Default constructor.
555        /// \warning It sets the iterator to an undefined value.
[57]556        OutArcIt() { }
557        /// Copy constructor.
558
559        /// Copy constructor.
560        ///
561        OutArcIt(const OutArcIt& e) : Arc(e) { }
[1432]562        /// Assignment operator
563
564        /// Assignment operator.
565        ///
566        const OutArcIt &operator=(const OutArcIt&) { return *this; }
567
[781]568        /// %Invalid constructor \& conversion.
[57]569
[781]570        /// Initializes the iterator to be invalid.
571        /// \sa Invalid for more details.
572        OutArcIt(Invalid) { }
573        /// Sets the iterator to the first outgoing arc.
574
575        /// Sets the iterator to the first outgoing arc of the given node.
[57]576        ///
577        OutArcIt(const Graph& n, const Node& g) {
[1257]578          ::lemon::ignore_unused_variable_warning(n);
579          ::lemon::ignore_unused_variable_warning(g);
[209]580        }
[781]581        /// Sets the iterator to the given arc.
[57]582
[781]583        /// Sets the iterator to the given arc of the given graph.
584        ///
[57]585        OutArcIt(const Graph&, const Arc&) { }
[781]586        /// Next outgoing arc
[209]587
588        /// Assign the iterator to the next
[57]589        /// outgoing arc of the corresponding node.
590        OutArcIt& operator++() { return *this; }
591      };
592
[1336]593      /// \brief Gets the collection of the outgoing directed arcs of a
594      /// certain node of the graph.
595      ///
596      /// This function can be used for iterating on the
597      /// outgoing arcs of a certain node of the graph. It returns a wrapped
598      /// OutArcIt, which looks like an STL container
599      /// (by having begin() and end()) which you can use in range-based
600      /// for loops, STL algorithms, etc.
601      /// For example if g is a Graph and u is a Node, you can write:
602      ///\code
603      /// for(auto a: g.outArcs(u))
604      ///   doSomething(a);
605      ///
606      /// //Using an STL algorithm:
607      /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
608      ///\endcode
609      LemonRangeWrapper2<OutArcIt, Graph, Node> outArcs(const Node& u) const {
610        return LemonRangeWrapper2<OutArcIt, Graph, Node>(*this, u);
611      }
612
613
[781]614      /// Iterator class for the incoming arcs of a node.
[57]615
[781]616      /// This iterator goes trough the \e incoming directed arcs of a
617      /// certain node of a graph.
[833]618      /// Its usage is quite simple, for example, you can count the number
[781]619      /// of incoming arcs of a node \c n
620      /// in a graph \c g of type \c %Graph as follows.
[57]621      ///\code
622      /// int count=0;
[781]623      /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
[57]624      ///\endcode
625      class InArcIt : public Arc {
626      public:
627        /// Default constructor
628
[781]629        /// Default constructor.
630        /// \warning It sets the iterator to an undefined value.
[57]631        InArcIt() { }
632        /// Copy constructor.
633
634        /// Copy constructor.
635        ///
636        InArcIt(const InArcIt& e) : Arc(e) { }
[1432]637        /// Assignment operator
638
639        /// Assignment operator.
640        ///
641        const InArcIt &operator=(const InArcIt&) { return *this; }
642
[781]643        /// %Invalid constructor \& conversion.
[57]644
[781]645        /// Initializes the iterator to be invalid.
646        /// \sa Invalid for more details.
647        InArcIt(Invalid) { }
648        /// Sets the iterator to the first incoming arc.
649
650        /// Sets the iterator to the first incoming arc of the given node.
[57]651        ///
[209]652        InArcIt(const Graph& g, const Node& n) {
[1257]653          ::lemon::ignore_unused_variable_warning(n);
654          ::lemon::ignore_unused_variable_warning(g);
[209]655        }
[781]656        /// Sets the iterator to the given arc.
[57]657
[781]658        /// Sets the iterator to the given arc of the given graph.
659        ///
[57]660        InArcIt(const Graph&, const Arc&) { }
661        /// Next incoming arc
662
[781]663        /// Assign the iterator to the next
664        /// incoming arc of the corresponding node.
[57]665        InArcIt& operator++() { return *this; }
666      };
667
[1336]668      /// \brief Gets the collection of the incoming directed arcs of
669      /// a certain node of the graph.
670      ///
671      /// This function can be used for iterating on the
672      /// incoming directed arcs of a certain node of the graph. It returns
673      /// a wrapped InArcIt, which looks like an STL container
674      /// (by having begin() and end()) which you can use in range-based
675      /// for loops, STL algorithms, etc.
676      /// For example if g is a Graph and u is a Node, you can write:
677      ///\code
678      /// for(auto a: g.inArcs(u))
679      ///   doSomething(a);
680      ///
681      /// //Using an STL algorithm:
682      /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
683      ///\endcode
684      LemonRangeWrapper2<InArcIt, Graph, Node> inArcs(const Node& u) const {
685        return LemonRangeWrapper2<InArcIt, Graph, Node>(*this, u);
686      }
687
[781]688      /// \brief Standard graph map type for the nodes.
[209]689      ///
[781]690      /// Standard graph map type for the nodes.
691      /// It conforms to the ReferenceMap concept.
[209]692      template<class T>
[627]693      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
[57]694      {
695      public:
696
[781]697        /// Constructor
698        explicit NodeMap(const Graph&) { }
699        /// Constructor with given initial value
[57]700        NodeMap(const Graph&, T) { }
701
[263]702      private:
[57]703        ///Copy constructor
[627]704        NodeMap(const NodeMap& nm) :
705          ReferenceMap<Node, T, T&, const T&>(nm) { }
[57]706        ///Assignment operator
[1432]707        NodeMap& operator=(const NodeMap&) {
708          return *this;
709        }
710        ///Template Assignment operator
[57]711        template <typename CMap>
[209]712        NodeMap& operator=(const CMap&) {
[57]713          checkConcept<ReadMap<Node, T>, CMap>();
[209]714          return *this;
[57]715        }
716      };
717
[781]718      /// \brief Standard graph map type for the arcs.
[57]719      ///
[781]720      /// Standard graph map type for the arcs.
721      /// It conforms to the ReferenceMap concept.
[209]722      template<class T>
[627]723      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
[57]724      {
725      public:
726
[781]727        /// Constructor
728        explicit ArcMap(const Graph&) { }
729        /// Constructor with given initial value
[57]730        ArcMap(const Graph&, T) { }
[781]731
[263]732      private:
[57]733        ///Copy constructor
[627]734        ArcMap(const ArcMap& em) :
735          ReferenceMap<Arc, T, T&, const T&>(em) { }
[57]736        ///Assignment operator
[1432]737        ArcMap& operator=(const ArcMap&) {
738          return *this;
739        }
740        ///Template Assignment operator
[57]741        template <typename CMap>
[209]742        ArcMap& operator=(const CMap&) {
[57]743          checkConcept<ReadMap<Arc, T>, CMap>();
[209]744          return *this;
[57]745        }
746      };
747
[781]748      /// \brief Standard graph map type for the edges.
749      ///
750      /// Standard graph map type for the edges.
751      /// It conforms to the ReferenceMap concept.
[209]752      template<class T>
[627]753      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
[57]754      {
755      public:
756
[781]757        /// Constructor
758        explicit EdgeMap(const Graph&) { }
759        /// Constructor with given initial value
[57]760        EdgeMap(const Graph&, T) { }
[781]761
[263]762      private:
[57]763        ///Copy constructor
[627]764        EdgeMap(const EdgeMap& em) :
765          ReferenceMap<Edge, T, T&, const T&>(em) {}
[57]766        ///Assignment operator
[1432]767        EdgeMap& operator=(const EdgeMap&) {
768          return *this;
769        }
770        ///Template Assignment operator
[57]771        template <typename CMap>
[209]772        EdgeMap& operator=(const CMap&) {
[57]773          checkConcept<ReadMap<Edge, T>, CMap>();
[209]774          return *this;
[57]775        }
776      };
777
[781]778      /// \brief The first node of the edge.
[57]779      ///
[781]780      /// Returns the first node of the given edge.
[57]781      ///
[833]782      /// Edges don't have source and target nodes, however, methods
[781]783      /// u() and v() are used to query the two end-nodes of an edge.
784      /// The orientation of an edge that arises this way is called
785      /// the inherent direction, it is used to define the default
786      /// direction for the corresponding arcs.
[606]787      /// \sa v()
788      /// \sa direction()
[57]789      Node u(Edge) const { return INVALID; }
790
[781]791      /// \brief The second node of the edge.
[606]792      ///
[781]793      /// Returns the second node of the given edge.
[606]794      ///
[833]795      /// Edges don't have source and target nodes, however, methods
[781]796      /// u() and v() are used to query the two end-nodes of an edge.
797      /// The orientation of an edge that arises this way is called
798      /// the inherent direction, it is used to define the default
799      /// direction for the corresponding arcs.
[606]800      /// \sa u()
801      /// \sa direction()
[57]802      Node v(Edge) const { return INVALID; }
803
[781]804      /// \brief The source node of the arc.
805      ///
806      /// Returns the source node of the given arc.
[57]807      Node source(Arc) const { return INVALID; }
808
[781]809      /// \brief The target node of the arc.
810      ///
811      /// Returns the target node of the given arc.
[57]812      Node target(Arc) const { return INVALID; }
813
[781]814      /// \brief The ID of the node.
815      ///
816      /// Returns the ID of the given node.
[209]817      int id(Node) const { return -1; }
[61]818
[781]819      /// \brief The ID of the edge.
820      ///
821      /// Returns the ID of the given edge.
[209]822      int id(Edge) const { return -1; }
[61]823
[781]824      /// \brief The ID of the arc.
825      ///
826      /// Returns the ID of the given arc.
[209]827      int id(Arc) const { return -1; }
[61]828
[781]829      /// \brief The node with the given ID.
[61]830      ///
[781]831      /// Returns the node with the given ID.
832      /// \pre The argument should be a valid node ID in the graph.
[209]833      Node nodeFromId(int) const { return INVALID; }
[61]834
[781]835      /// \brief The edge with the given ID.
[61]836      ///
[781]837      /// Returns the edge with the given ID.
838      /// \pre The argument should be a valid edge ID in the graph.
[209]839      Edge edgeFromId(int) const { return INVALID; }
[61]840
[781]841      /// \brief The arc with the given ID.
[61]842      ///
[781]843      /// Returns the arc with the given ID.
844      /// \pre The argument should be a valid arc ID in the graph.
[209]845      Arc arcFromId(int) const { return INVALID; }
[61]846
[781]847      /// \brief An upper bound on the node IDs.
848      ///
849      /// Returns an upper bound on the node IDs.
[209]850      int maxNodeId() const { return -1; }
[61]851
[781]852      /// \brief An upper bound on the edge IDs.
853      ///
854      /// Returns an upper bound on the edge IDs.
[209]855      int maxEdgeId() const { return -1; }
[61]856
[781]857      /// \brief An upper bound on the arc IDs.
858      ///
859      /// Returns an upper bound on the arc IDs.
[209]860      int maxArcId() const { return -1; }
[61]861
[781]862      /// \brief The direction of the arc.
863      ///
864      /// Returns \c true if the direction of the given arc is the same as
865      /// the inherent orientation of the represented edge.
866      bool direction(Arc) const { return true; }
867
868      /// \brief Direct the edge.
869      ///
870      /// Direct the given edge. The returned arc
871      /// represents the given edge and its direction comes
872      /// from the bool parameter. If it is \c true, then the direction
873      /// of the arc is the same as the inherent orientation of the edge.
874      Arc direct(Edge, bool) const {
875        return INVALID;
876      }
877
878      /// \brief Direct the edge.
879      ///
880      /// Direct the given edge. The returned arc represents the given
881      /// edge and its source node is the given node.
882      Arc direct(Edge, Node) const {
883        return INVALID;
884      }
885
886      /// \brief The oppositely directed arc.
887      ///
888      /// Returns the oppositely directed arc representing the same edge.
889      Arc oppositeArc(Arc) const { return INVALID; }
890
891      /// \brief The opposite node on the edge.
892      ///
893      /// Returns the opposite node on the given edge.
894      Node oppositeNode(Node, Edge) const { return INVALID; }
895
[57]896      void first(Node&) const {}
897      void next(Node&) const {}
898
899      void first(Edge&) const {}
900      void next(Edge&) const {}
901
902      void first(Arc&) const {}
903      void next(Arc&) const {}
904
905      void firstOut(Arc&, Node) const {}
906      void nextOut(Arc&) const {}
907
908      void firstIn(Arc&, Node) const {}
909      void nextIn(Arc&) const {}
910
911      void firstInc(Edge &, bool &, const Node &) const {}
912      void nextInc(Edge &, bool &) const {}
913
[61]914      // The second parameter is dummy.
915      Node fromId(int, Node) const { return INVALID; }
916      // The second parameter is dummy.
917      Edge fromId(int, Edge) const { return INVALID; }
918      // The second parameter is dummy.
919      Arc fromId(int, Arc) const { return INVALID; }
920
921      // Dummy parameter.
[209]922      int maxId(Node) const { return -1; }
[61]923      // Dummy parameter.
[209]924      int maxId(Edge) const { return -1; }
[61]925      // Dummy parameter.
[209]926      int maxId(Arc) const { return -1; }
[61]927
[781]928      /// \brief The base node of the iterator.
[57]929      ///
[781]930      /// Returns the base node of the given incident edge iterator.
931      Node baseNode(IncEdgeIt) const { return INVALID; }
932
933      /// \brief The running node of the iterator.
[57]934      ///
[781]935      /// Returns the running node of the given incident edge iterator.
936      Node runningNode(IncEdgeIt) const { return INVALID; }
[57]937
[781]938      /// \brief The base node of the iterator.
[57]939      ///
[781]940      /// Returns the base node of the given outgoing arc iterator
941      /// (i.e. the source node of the corresponding arc).
942      Node baseNode(OutArcIt) const { return INVALID; }
943
944      /// \brief The running node of the iterator.
[57]945      ///
[781]946      /// Returns the running node of the given outgoing arc iterator
947      /// (i.e. the target node of the corresponding arc).
948      Node runningNode(OutArcIt) const { return INVALID; }
[57]949
[781]950      /// \brief The base node of the iterator.
[57]951      ///
[1217]952      /// Returns the base node of the given incoming arc iterator
[781]953      /// (i.e. the target node of the corresponding arc).
954      Node baseNode(InArcIt) const { return INVALID; }
[209]955
[781]956      /// \brief The running node of the iterator.
[57]957      ///
[1217]958      /// Returns the running node of the given incoming arc iterator
[781]959      /// (i.e. the source node of the corresponding arc).
960      Node runningNode(InArcIt) const { return INVALID; }
[57]961
[125]962      template <typename _Graph>
[57]963      struct Constraints {
[209]964        void constraints() {
[627]965          checkConcept<BaseGraphComponent, _Graph>();
[209]966          checkConcept<IterableGraphComponent<>, _Graph>();
967          checkConcept<IDableGraphComponent<>, _Graph>();
968          checkConcept<MappableGraphComponent<>, _Graph>();
969        }
[57]970      };
971
972    };
973
974  }
975
976}
977
978#endif
Note: See TracBrowser for help on using the repository browser.