lemon/concepts/digraph.h
author Alpar Juttner <alpar@cs.elte.hu>
Tue, 28 Jul 2020 21:23:36 +0200
changeset 1210 da87dbdf3daf
parent 1130 0759d974de81
permissions -rw-r--r--
Resolve deprecation warnings of gcc 9 (#633)
alpar@209
     1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
deba@57
     2
 *
alpar@209
     3
 * This file is a part of LEMON, a generic C++ optimization library.
deba@57
     4
 *
alpar@1092
     5
 * Copyright (C) 2003-2013
deba@57
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@57
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@57
     8
 *
deba@57
     9
 * Permission to use, modify and distribute this software is granted
deba@57
    10
 * provided that this copyright notice appears in all copies. For
deba@57
    11
 * precise terms see the accompanying LICENSE file.
deba@57
    12
 *
deba@57
    13
 * This software is provided "AS IS" with no warranty of any kind,
deba@57
    14
 * express or implied, and with no claim as to its suitability for any
deba@57
    15
 * purpose.
deba@57
    16
 *
deba@57
    17
 */
deba@57
    18
deba@529
    19
#ifndef LEMON_CONCEPTS_DIGRAPH_H
deba@529
    20
#define LEMON_CONCEPTS_DIGRAPH_H
deba@57
    21
deba@57
    22
///\ingroup graph_concepts
deba@57
    23
///\file
deba@57
    24
///\brief The concept of directed graphs.
deba@57
    25
deba@220
    26
#include <lemon/core.h>
deba@57
    27
#include <lemon/concepts/maps.h>
deba@57
    28
#include <lemon/concept_check.h>
deba@57
    29
#include <lemon/concepts/graph_components.h>
ggab90@1130
    30
#include <lemon/bits/stl_iterators.h>
deba@57
    31
deba@57
    32
namespace lemon {
deba@57
    33
  namespace concepts {
deba@57
    34
deba@57
    35
    /// \ingroup graph_concepts
deba@57
    36
    ///
deba@57
    37
    /// \brief Class describing the concept of directed graphs.
deba@57
    38
    ///
kpeter@734
    39
    /// This class describes the common interface of all directed
kpeter@734
    40
    /// graphs (digraphs).
deba@57
    41
    ///
kpeter@734
    42
    /// Like all concept classes, it only provides an interface
kpeter@734
    43
    /// without any sensible implementation. So any general algorithm for
kpeter@734
    44
    /// directed graphs should compile with this class, but it will not
kpeter@734
    45
    /// run properly, of course.
kpeter@734
    46
    /// An actual digraph implementation like \ref ListDigraph or
kpeter@734
    47
    /// \ref SmartDigraph may have additional functionality.
deba@57
    48
    ///
kpeter@734
    49
    /// \sa Graph
deba@57
    50
    class Digraph {
deba@57
    51
    private:
kpeter@734
    52
      /// Diraphs are \e not copy constructible. Use DigraphCopy instead.
kpeter@734
    53
      Digraph(const Digraph &) {}
kpeter@734
    54
      /// \brief Assignment of a digraph to another one is \e not allowed.
kpeter@734
    55
      /// Use DigraphCopy instead.
kpeter@734
    56
      void operator=(const Digraph &) {}
alpar@209
    57
kpeter@734
    58
    public:
kpeter@734
    59
      /// Default constructor.
kpeter@734
    60
      Digraph() { }
alpar@209
    61
kpeter@734
    62
      /// The node type of the digraph
deba@57
    63
deba@57
    64
      /// This class identifies a node of the digraph. It also serves
deba@57
    65
      /// as a base class of the node iterators,
kpeter@734
    66
      /// thus they convert to this type.
deba@57
    67
      class Node {
deba@57
    68
      public:
deba@57
    69
        /// Default constructor
deba@57
    70
kpeter@734
    71
        /// Default constructor.
kpeter@734
    72
        /// \warning It sets the object to an undefined value.
deba@57
    73
        Node() { }
deba@57
    74
        /// Copy constructor.
deba@57
    75
deba@57
    76
        /// Copy constructor.
deba@57
    77
        ///
deba@57
    78
        Node(const Node&) { }
deba@57
    79
alpar@1210
    80
        /// Assignment operator
alpar@1210
    81
alpar@1210
    82
        /// Assignment operator.
alpar@1210
    83
        ///
alpar@1210
    84
        const Node &operator=(const Node&) { return *this; }
alpar@1210
    85
kpeter@734
    86
        /// %Invalid constructor \& conversion.
deba@57
    87
kpeter@734
    88
        /// Initializes the object to be invalid.
deba@57
    89
        /// \sa Invalid for more details.
deba@57
    90
        Node(Invalid) { }
deba@57
    91
        /// Equality operator
deba@57
    92
kpeter@734
    93
        /// Equality operator.
kpeter@734
    94
        ///
deba@57
    95
        /// Two iterators are equal if and only if they point to the
kpeter@734
    96
        /// same object or both are \c INVALID.
deba@57
    97
        bool operator==(Node) const { return true; }
deba@57
    98
deba@57
    99
        /// Inequality operator
alpar@209
   100
kpeter@734
   101
        /// Inequality operator.
deba@57
   102
        bool operator!=(Node) const { return true; }
deba@57
   103
alpar@209
   104
        /// Artificial ordering operator.
alpar@209
   105
kpeter@734
   106
        /// Artificial ordering operator.
alpar@209
   107
        ///
kpeter@734
   108
        /// \note This operator only has to define some strict ordering of
kpeter@734
   109
        /// the nodes; this order has nothing to do with the iteration
kpeter@734
   110
        /// ordering of the nodes.
alpar@209
   111
        bool operator<(Node) const { return false; }
deba@57
   112
      };
alpar@209
   113
kpeter@734
   114
      /// Iterator class for the nodes.
deba@57
   115
kpeter@734
   116
      /// This iterator goes through each node of the digraph.
kpeter@786
   117
      /// Its usage is quite simple, for example, you can count the number
kpeter@734
   118
      /// of nodes in a digraph \c g of type \c %Digraph like this:
deba@57
   119
      ///\code
deba@57
   120
      /// int count=0;
deba@57
   121
      /// for (Digraph::NodeIt n(g); n!=INVALID; ++n) ++count;
deba@57
   122
      ///\endcode
deba@57
   123
      class NodeIt : public Node {
deba@57
   124
      public:
deba@57
   125
        /// Default constructor
deba@57
   126
kpeter@734
   127
        /// Default constructor.
kpeter@734
   128
        /// \warning It sets the iterator to an undefined value.
deba@57
   129
        NodeIt() { }
deba@57
   130
        /// Copy constructor.
alpar@209
   131
deba@57
   132
        /// Copy constructor.
deba@57
   133
        ///
deba@57
   134
        NodeIt(const NodeIt& n) : Node(n) { }
alpar@1210
   135
        /// Assignment operator
alpar@1210
   136
alpar@1210
   137
        /// Assignment operator.
alpar@1210
   138
        ///
alpar@1210
   139
        const NodeIt &operator=(const NodeIt&) { return *this; }
alpar@1210
   140
kpeter@734
   141
        /// %Invalid constructor \& conversion.
deba@57
   142
kpeter@734
   143
        /// Initializes the iterator to be invalid.
deba@57
   144
        /// \sa Invalid for more details.
deba@57
   145
        NodeIt(Invalid) { }
deba@57
   146
        /// Sets the iterator to the first node.
deba@57
   147
kpeter@734
   148
        /// Sets the iterator to the first node of the given digraph.
deba@57
   149
        ///
kpeter@734
   150
        explicit NodeIt(const Digraph&) { }
kpeter@734
   151
        /// Sets the iterator to the given node.
deba@57
   152
kpeter@734
   153
        /// Sets the iterator to the given node of the given digraph.
kpeter@734
   154
        ///
deba@57
   155
        NodeIt(const Digraph&, const Node&) { }
deba@57
   156
        /// Next node.
deba@57
   157
deba@57
   158
        /// Assign the iterator to the next node.
deba@57
   159
        ///
deba@57
   160
        NodeIt& operator++() { return *this; }
deba@57
   161
      };
alpar@209
   162
ggab90@1130
   163
      /// \brief Gets the collection of the nodes of the digraph.
ggab90@1130
   164
      ///
ggab90@1130
   165
      /// This function can be used for iterating on
ggab90@1130
   166
      /// the nodes of the digraph. It returns a wrapped NodeIt, which looks
ggab90@1130
   167
      /// like an STL container (by having begin() and end())
ggab90@1130
   168
      /// which you can use in range-based for loops, STL algorithms, etc.
ggab90@1130
   169
      /// For example you can write:
ggab90@1130
   170
      ///\code
ggab90@1130
   171
      /// ListDigraph g;
ggab90@1130
   172
      /// for(auto v: g.nodes())
ggab90@1130
   173
      ///   doSomething(v);
ggab90@1130
   174
      ///
ggab90@1130
   175
      /// //Using an STL algorithm:
ggab90@1130
   176
      /// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
ggab90@1130
   177
      ///\endcode
ggab90@1130
   178
      LemonRangeWrapper1<NodeIt, Digraph> nodes() const {
ggab90@1130
   179
        return LemonRangeWrapper1<NodeIt, Digraph>(*this);
ggab90@1130
   180
      }
ggab90@1130
   181
alpar@209
   182
kpeter@734
   183
      /// The arc type of the digraph
deba@57
   184
deba@57
   185
      /// This class identifies an arc of the digraph. It also serves
deba@57
   186
      /// as a base class of the arc iterators,
deba@57
   187
      /// thus they will convert to this type.
deba@57
   188
      class Arc {
deba@57
   189
      public:
deba@57
   190
        /// Default constructor
deba@57
   191
kpeter@734
   192
        /// Default constructor.
kpeter@734
   193
        /// \warning It sets the object to an undefined value.
deba@57
   194
        Arc() { }
deba@57
   195
        /// Copy constructor.
deba@57
   196
deba@57
   197
        /// Copy constructor.
deba@57
   198
        ///
deba@57
   199
        Arc(const Arc&) { }
alpar@1210
   200
        /// Assignment operator
alpar@1210
   201
alpar@1210
   202
        /// Assignment operator.
alpar@1210
   203
        ///
alpar@1210
   204
        const Arc &operator=(const Arc&) { return *this; }
alpar@1210
   205
kpeter@734
   206
        /// %Invalid constructor \& conversion.
deba@57
   207
kpeter@734
   208
        /// Initializes the object to be invalid.
kpeter@734
   209
        /// \sa Invalid for more details.
deba@57
   210
        Arc(Invalid) { }
deba@57
   211
        /// Equality operator
deba@57
   212
kpeter@734
   213
        /// Equality operator.
kpeter@734
   214
        ///
deba@57
   215
        /// Two iterators are equal if and only if they point to the
kpeter@734
   216
        /// same object or both are \c INVALID.
deba@57
   217
        bool operator==(Arc) const { return true; }
deba@57
   218
        /// Inequality operator
deba@57
   219
kpeter@734
   220
        /// Inequality operator.
deba@57
   221
        bool operator!=(Arc) const { return true; }
deba@57
   222
alpar@209
   223
        /// Artificial ordering operator.
alpar@209
   224
kpeter@734
   225
        /// Artificial ordering operator.
alpar@209
   226
        ///
kpeter@734
   227
        /// \note This operator only has to define some strict ordering of
kpeter@734
   228
        /// the arcs; this order has nothing to do with the iteration
kpeter@734
   229
        /// ordering of the arcs.
alpar@209
   230
        bool operator<(Arc) const { return false; }
deba@57
   231
      };
alpar@209
   232
kpeter@734
   233
      /// Iterator class for the outgoing arcs of a node.
deba@57
   234
deba@57
   235
      /// This iterator goes trough the \e outgoing arcs of a certain node
deba@57
   236
      /// of a digraph.
kpeter@786
   237
      /// Its usage is quite simple, for example, you can count the number
deba@57
   238
      /// of outgoing arcs of a node \c n
kpeter@734
   239
      /// in a digraph \c g of type \c %Digraph as follows.
deba@57
   240
      ///\code
deba@57
   241
      /// int count=0;
kpeter@734
   242
      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
deba@57
   243
      ///\endcode
deba@57
   244
      class OutArcIt : public Arc {
deba@57
   245
      public:
deba@57
   246
        /// Default constructor
deba@57
   247
kpeter@734
   248
        /// Default constructor.
kpeter@734
   249
        /// \warning It sets the iterator to an undefined value.
deba@57
   250
        OutArcIt() { }
deba@57
   251
        /// Copy constructor.
deba@57
   252
deba@57
   253
        /// Copy constructor.
deba@57
   254
        ///
deba@57
   255
        OutArcIt(const OutArcIt& e) : Arc(e) { }
alpar@1210
   256
        /// Assignment operator
alpar@1210
   257
alpar@1210
   258
        /// Assignment operator.
alpar@1210
   259
        ///
alpar@1210
   260
        const OutArcIt &operator=(const OutArcIt&) { return *this; }
kpeter@734
   261
        /// %Invalid constructor \& conversion.
deba@57
   262
kpeter@734
   263
        /// Initializes the iterator to be invalid.
kpeter@734
   264
        /// \sa Invalid for more details.
kpeter@734
   265
        OutArcIt(Invalid) { }
kpeter@734
   266
        /// Sets the iterator to the first outgoing arc.
kpeter@734
   267
kpeter@734
   268
        /// Sets the iterator to the first outgoing arc of the given node.
deba@57
   269
        ///
kpeter@734
   270
        OutArcIt(const Digraph&, const Node&) { }
kpeter@734
   271
        /// Sets the iterator to the given arc.
alpar@209
   272
kpeter@734
   273
        /// Sets the iterator to the given arc of the given digraph.
kpeter@734
   274
        ///
deba@57
   275
        OutArcIt(const Digraph&, const Arc&) { }
kpeter@734
   276
        /// Next outgoing arc
alpar@209
   277
alpar@209
   278
        /// Assign the iterator to the next
deba@57
   279
        /// outgoing arc of the corresponding node.
deba@57
   280
        OutArcIt& operator++() { return *this; }
deba@57
   281
      };
deba@57
   282
ggab90@1130
   283
      /// \brief Gets the collection of the outgoing arcs of a certain node
ggab90@1130
   284
      /// of the digraph.
ggab90@1130
   285
      ///
ggab90@1130
   286
      /// This function can be used for iterating on the
ggab90@1130
   287
      /// outgoing arcs of a certain node of the digraph. It returns a wrapped
ggab90@1130
   288
      /// OutArcIt, which looks like an STL container
ggab90@1130
   289
      /// (by having begin() and end()) which you can use in range-based
ggab90@1130
   290
      /// for loops, STL algorithms, etc.
ggab90@1130
   291
      /// For example if g is a Digraph and u is a node, you can write:
ggab90@1130
   292
      ///\code
ggab90@1130
   293
      /// for(auto a: g.outArcs(u))
ggab90@1130
   294
      ///   doSomething(a);
ggab90@1130
   295
      ///
ggab90@1130
   296
      /// //Using an STL algorithm:
ggab90@1130
   297
      /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
ggab90@1130
   298
      ///\endcode
ggab90@1130
   299
      LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const {
ggab90@1130
   300
        return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u);
ggab90@1130
   301
      }
ggab90@1130
   302
ggab90@1130
   303
kpeter@734
   304
      /// Iterator class for the incoming arcs of a node.
deba@57
   305
deba@57
   306
      /// This iterator goes trough the \e incoming arcs of a certain node
deba@57
   307
      /// of a digraph.
kpeter@786
   308
      /// Its usage is quite simple, for example, you can count the number
kpeter@734
   309
      /// of incoming arcs of a node \c n
kpeter@734
   310
      /// in a digraph \c g of type \c %Digraph as follows.
deba@57
   311
      ///\code
deba@57
   312
      /// int count=0;
kpeter@734
   313
      /// for(Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
deba@57
   314
      ///\endcode
deba@57
   315
      class InArcIt : public Arc {
deba@57
   316
      public:
deba@57
   317
        /// Default constructor
deba@57
   318
kpeter@734
   319
        /// Default constructor.
kpeter@734
   320
        /// \warning It sets the iterator to an undefined value.
deba@57
   321
        InArcIt() { }
deba@57
   322
        /// Copy constructor.
deba@57
   323
deba@57
   324
        /// Copy constructor.
deba@57
   325
        ///
deba@57
   326
        InArcIt(const InArcIt& e) : Arc(e) { }
alpar@1210
   327
        /// Assignment operator
alpar@1210
   328
alpar@1210
   329
        /// Assignment operator.
alpar@1210
   330
        ///
alpar@1210
   331
        const InArcIt &operator=(const InArcIt&) { return *this; }
alpar@1210
   332
kpeter@734
   333
        /// %Invalid constructor \& conversion.
deba@57
   334
kpeter@734
   335
        /// Initializes the iterator to be invalid.
kpeter@734
   336
        /// \sa Invalid for more details.
kpeter@734
   337
        InArcIt(Invalid) { }
kpeter@734
   338
        /// Sets the iterator to the first incoming arc.
kpeter@734
   339
kpeter@734
   340
        /// Sets the iterator to the first incoming arc of the given node.
deba@57
   341
        ///
kpeter@734
   342
        InArcIt(const Digraph&, const Node&) { }
kpeter@734
   343
        /// Sets the iterator to the given arc.
alpar@209
   344
kpeter@734
   345
        /// Sets the iterator to the given arc of the given digraph.
kpeter@734
   346
        ///
deba@57
   347
        InArcIt(const Digraph&, const Arc&) { }
deba@57
   348
        /// Next incoming arc
deba@57
   349
kpeter@734
   350
        /// Assign the iterator to the next
kpeter@734
   351
        /// incoming arc of the corresponding node.
deba@57
   352
        InArcIt& operator++() { return *this; }
deba@57
   353
      };
deba@57
   354
ggab90@1130
   355
      /// \brief Gets the collection of the incoming arcs of a certain node
ggab90@1130
   356
      /// of the digraph.
ggab90@1130
   357
      ///
ggab90@1130
   358
      /// This function can be used for iterating on the
ggab90@1130
   359
      /// incoming arcs of a certain node of the digraph. It returns a wrapped
ggab90@1130
   360
      /// InArcIt, which looks like an STL container
ggab90@1130
   361
      /// (by having begin() and end()) which you can use in range-based
ggab90@1130
   362
      /// for loops, STL algorithms, etc.
ggab90@1130
   363
      /// For example if g is a Digraph and u is a node, you can write:
ggab90@1130
   364
      ///\code
ggab90@1130
   365
      /// for(auto a: g.inArcs(u))
ggab90@1130
   366
      ///   doSomething(a);
ggab90@1130
   367
      ///
ggab90@1130
   368
      /// //Using an STL algorithm:
ggab90@1130
   369
      /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
ggab90@1130
   370
      ///\endcode
ggab90@1130
   371
      LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const {
ggab90@1130
   372
        return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u);
ggab90@1130
   373
      }
ggab90@1130
   374
ggab90@1130
   375
kpeter@734
   376
      /// Iterator class for the arcs.
kpeter@734
   377
kpeter@734
   378
      /// This iterator goes through each arc of the digraph.
kpeter@786
   379
      /// Its usage is quite simple, for example, you can count the number
kpeter@734
   380
      /// of arcs in a digraph \c g of type \c %Digraph as follows:
deba@57
   381
      ///\code
deba@57
   382
      /// int count=0;
kpeter@734
   383
      /// for(Digraph::ArcIt a(g); a!=INVALID; ++a) ++count;
deba@57
   384
      ///\endcode
deba@57
   385
      class ArcIt : public Arc {
deba@57
   386
      public:
deba@57
   387
        /// Default constructor
deba@57
   388
kpeter@734
   389
        /// Default constructor.
kpeter@734
   390
        /// \warning It sets the iterator to an undefined value.
deba@57
   391
        ArcIt() { }
deba@57
   392
        /// Copy constructor.
deba@57
   393
deba@57
   394
        /// Copy constructor.
deba@57
   395
        ///
deba@57
   396
        ArcIt(const ArcIt& e) : Arc(e) { }
alpar@1210
   397
        /// Assignment operator
alpar@1210
   398
alpar@1210
   399
        /// Assignment operator.
alpar@1210
   400
        ///
alpar@1210
   401
        const ArcIt &operator=(const ArcIt&) { return *this; }
alpar@1210
   402
kpeter@734
   403
        /// %Invalid constructor \& conversion.
deba@57
   404
kpeter@734
   405
        /// Initializes the iterator to be invalid.
kpeter@734
   406
        /// \sa Invalid for more details.
kpeter@734
   407
        ArcIt(Invalid) { }
kpeter@734
   408
        /// Sets the iterator to the first arc.
kpeter@734
   409
kpeter@734
   410
        /// Sets the iterator to the first arc of the given digraph.
deba@57
   411
        ///
alpar@1093
   412
        explicit ArcIt(const Digraph& g) {
alpar@1093
   413
          ::lemon::ignore_unused_variable_warning(g);
alpar@1093
   414
        }
kpeter@734
   415
        /// Sets the iterator to the given arc.
alpar@209
   416
kpeter@734
   417
        /// Sets the iterator to the given arc of the given digraph.
kpeter@734
   418
        ///
alpar@209
   419
        ArcIt(const Digraph&, const Arc&) { }
kpeter@734
   420
        /// Next arc
alpar@209
   421
deba@57
   422
        /// Assign the iterator to the next arc.
kpeter@734
   423
        ///
deba@57
   424
        ArcIt& operator++() { return *this; }
deba@57
   425
      };
deba@57
   426
ggab90@1130
   427
      /// \brief Gets the collection of the arcs of the digraph.
ggab90@1130
   428
      ///
ggab90@1130
   429
      /// This function can be used for iterating on the
ggab90@1130
   430
      /// arcs of the digraph. It returns a wrapped
ggab90@1130
   431
      /// ArcIt, which looks like an STL container
ggab90@1130
   432
      /// (by having begin() and end()) which you can use in range-based
ggab90@1130
   433
      /// for loops, STL algorithms, etc.
ggab90@1130
   434
      /// For example you can write:
ggab90@1130
   435
      ///\code
ggab90@1130
   436
      /// ListDigraph g;
ggab90@1130
   437
      /// for(auto a: g.arcs())
ggab90@1130
   438
      ///   doSomething(a);
ggab90@1130
   439
      ///
ggab90@1130
   440
      /// //Using an STL algorithm:
ggab90@1130
   441
      /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
ggab90@1130
   442
      ///\endcode
ggab90@1130
   443
      LemonRangeWrapper1<ArcIt, Digraph> arcs() const {
ggab90@1130
   444
        return LemonRangeWrapper1<ArcIt, Digraph>(*this);
ggab90@1130
   445
      }
ggab90@1130
   446
ggab90@1130
   447
kpeter@734
   448
      /// \brief The source node of the arc.
deba@57
   449
      ///
kpeter@734
   450
      /// Returns the source node of the given arc.
deba@57
   451
      Node source(Arc) const { return INVALID; }
deba@57
   452
kpeter@734
   453
      /// \brief The target node of the arc.
kpeter@734
   454
      ///
kpeter@734
   455
      /// Returns the target node of the given arc.
kpeter@734
   456
      Node target(Arc) const { return INVALID; }
kpeter@734
   457
kpeter@734
   458
      /// \brief The ID of the node.
kpeter@734
   459
      ///
kpeter@734
   460
      /// Returns the ID of the given node.
alpar@209
   461
      int id(Node) const { return -1; }
deba@61
   462
kpeter@734
   463
      /// \brief The ID of the arc.
kpeter@734
   464
      ///
kpeter@734
   465
      /// Returns the ID of the given arc.
alpar@209
   466
      int id(Arc) const { return -1; }
deba@61
   467
kpeter@734
   468
      /// \brief The node with the given ID.
deba@61
   469
      ///
kpeter@734
   470
      /// Returns the node with the given ID.
kpeter@734
   471
      /// \pre The argument should be a valid node ID in the digraph.
alpar@209
   472
      Node nodeFromId(int) const { return INVALID; }
deba@61
   473
kpeter@734
   474
      /// \brief The arc with the given ID.
deba@61
   475
      ///
kpeter@734
   476
      /// Returns the arc with the given ID.
kpeter@734
   477
      /// \pre The argument should be a valid arc ID in the digraph.
alpar@209
   478
      Arc arcFromId(int) const { return INVALID; }
deba@61
   479
kpeter@734
   480
      /// \brief An upper bound on the node IDs.
kpeter@734
   481
      ///
kpeter@734
   482
      /// Returns an upper bound on the node IDs.
alpar@209
   483
      int maxNodeId() const { return -1; }
deba@61
   484
kpeter@734
   485
      /// \brief An upper bound on the arc IDs.
kpeter@734
   486
      ///
kpeter@734
   487
      /// Returns an upper bound on the arc IDs.
alpar@209
   488
      int maxArcId() const { return -1; }
deba@61
   489
deba@57
   490
      void first(Node&) const {}
deba@57
   491
      void next(Node&) const {}
deba@57
   492
deba@57
   493
      void first(Arc&) const {}
deba@57
   494
      void next(Arc&) const {}
deba@57
   495
deba@57
   496
deba@57
   497
      void firstIn(Arc&, const Node&) const {}
deba@57
   498
      void nextIn(Arc&) const {}
deba@57
   499
deba@57
   500
      void firstOut(Arc&, const Node&) const {}
deba@57
   501
      void nextOut(Arc&) const {}
deba@57
   502
deba@61
   503
      // The second parameter is dummy.
deba@61
   504
      Node fromId(int, Node) const { return INVALID; }
deba@61
   505
      // The second parameter is dummy.
deba@61
   506
      Arc fromId(int, Arc) const { return INVALID; }
deba@61
   507
deba@61
   508
      // Dummy parameter.
alpar@209
   509
      int maxId(Node) const { return -1; }
deba@61
   510
      // Dummy parameter.
alpar@209
   511
      int maxId(Arc) const { return -1; }
deba@61
   512
kpeter@734
   513
      /// \brief The opposite node on the arc.
kpeter@734
   514
      ///
kpeter@734
   515
      /// Returns the opposite node on the given arc.
kpeter@734
   516
      Node oppositeNode(Node, Arc) const { return INVALID; }
kpeter@734
   517
deba@57
   518
      /// \brief The base node of the iterator.
deba@57
   519
      ///
kpeter@734
   520
      /// Returns the base node of the given outgoing arc iterator
kpeter@734
   521
      /// (i.e. the source node of the corresponding arc).
kpeter@734
   522
      Node baseNode(OutArcIt) const { return INVALID; }
deba@57
   523
deba@57
   524
      /// \brief The running node of the iterator.
deba@57
   525
      ///
kpeter@734
   526
      /// Returns the running node of the given outgoing arc iterator
kpeter@734
   527
      /// (i.e. the target node of the corresponding arc).
kpeter@734
   528
      Node runningNode(OutArcIt) const { return INVALID; }
deba@57
   529
deba@57
   530
      /// \brief The base node of the iterator.
deba@57
   531
      ///
kpeter@1049
   532
      /// Returns the base node of the given incoming arc iterator
kpeter@734
   533
      /// (i.e. the target node of the corresponding arc).
kpeter@734
   534
      Node baseNode(InArcIt) const { return INVALID; }
deba@57
   535
deba@57
   536
      /// \brief The running node of the iterator.
deba@57
   537
      ///
kpeter@1049
   538
      /// Returns the running node of the given incoming arc iterator
kpeter@734
   539
      /// (i.e. the source node of the corresponding arc).
kpeter@734
   540
      Node runningNode(InArcIt) const { return INVALID; }
deba@57
   541
kpeter@734
   542
      /// \brief Standard graph map type for the nodes.
deba@57
   543
      ///
kpeter@734
   544
      /// Standard graph map type for the nodes.
kpeter@734
   545
      /// It conforms to the ReferenceMap concept.
alpar@209
   546
      template<class T>
kpeter@580
   547
      class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
deba@57
   548
      public:
deba@57
   549
kpeter@734
   550
        /// Constructor
kpeter@734
   551
        explicit NodeMap(const Digraph&) { }
kpeter@734
   552
        /// Constructor with given initial value
deba@57
   553
        NodeMap(const Digraph&, T) { }
deba@57
   554
kpeter@263
   555
      private:
deba@57
   556
        ///Copy constructor
alpar@877
   557
        NodeMap(const NodeMap& nm) :
kpeter@580
   558
          ReferenceMap<Node, T, T&, const T&>(nm) { }
alpar@1210
   559
      public:
deba@57
   560
        ///Assignment operator
alpar@1210
   561
        NodeMap& operator=(const NodeMap&) {
alpar@1210
   562
          return *this;
alpar@1210
   563
        }
alpar@1210
   564
        ///Template Assignment operator
deba@57
   565
        template <typename CMap>
alpar@209
   566
        NodeMap& operator=(const CMap&) {
deba@57
   567
          checkConcept<ReadMap<Node, T>, CMap>();
alpar@209
   568
          return *this;
deba@57
   569
        }
deba@57
   570
      };
deba@57
   571
kpeter@734
   572
      /// \brief Standard graph map type for the arcs.
deba@57
   573
      ///
kpeter@734
   574
      /// Standard graph map type for the arcs.
kpeter@734
   575
      /// It conforms to the ReferenceMap concept.
alpar@209
   576
      template<class T>
kpeter@580
   577
      class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
deba@57
   578
      public:
deba@57
   579
kpeter@734
   580
        /// Constructor
kpeter@734
   581
        explicit ArcMap(const Digraph&) { }
kpeter@734
   582
        /// Constructor with given initial value
deba@57
   583
        ArcMap(const Digraph&, T) { }
kpeter@734
   584
kpeter@263
   585
      private:
deba@57
   586
        ///Copy constructor
kpeter@580
   587
        ArcMap(const ArcMap& em) :
kpeter@580
   588
          ReferenceMap<Arc, T, T&, const T&>(em) { }
deba@57
   589
        ///Assignment operator
alpar@1210
   590
        ArcMap& operator=(const ArcMap&) {
alpar@1210
   591
          return *this;
alpar@1210
   592
        }
alpar@1210
   593
        ///Template Assignment operator
deba@57
   594
        template <typename CMap>
alpar@209
   595
        ArcMap& operator=(const CMap&) {
deba@57
   596
          checkConcept<ReadMap<Arc, T>, CMap>();
alpar@209
   597
          return *this;
deba@57
   598
        }
deba@57
   599
      };
deba@57
   600
deba@125
   601
      template <typename _Digraph>
deba@57
   602
      struct Constraints {
deba@57
   603
        void constraints() {
kpeter@580
   604
          checkConcept<BaseDigraphComponent, _Digraph>();
deba@125
   605
          checkConcept<IterableDigraphComponent<>, _Digraph>();
alpar@209
   606
          checkConcept<IDableDigraphComponent<>, _Digraph>();
deba@125
   607
          checkConcept<MappableDigraphComponent<>, _Digraph>();
deba@57
   608
        }
deba@57
   609
      };
deba@57
   610
deba@57
   611
    };
alpar@209
   612
alpar@209
   613
  } //namespace concepts
deba@57
   614
} //namespace lemon
deba@57
   615
deba@57
   616
deba@57
   617
deba@529
   618
#endif