lemon/concepts/digraph.h
author Gabor Gevay <ggab90@gmail.com>
Sun, 05 Jan 2014 22:24:56 +0100
changeset 1336 0759d974de81
parent 1271 fb1c7da561ce
child 1432 da87dbdf3daf
permissions -rw-r--r--
STL style iterators (#325)

For
* graph types,
* graph adaptors,
* paths,
* iterable maps,
* LP rows/cols and
* active nodes is BellmanFord
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@1270
     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@576
    19
#ifndef LEMON_CONCEPTS_DIGRAPH_H
deba@576
    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@1336
    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@781
    39
    /// This class describes the common interface of all directed
kpeter@781
    40
    /// graphs (digraphs).
deba@57
    41
    ///
kpeter@781
    42
    /// Like all concept classes, it only provides an interface
kpeter@781
    43
    /// without any sensible implementation. So any general algorithm for
kpeter@781
    44
    /// directed graphs should compile with this class, but it will not
kpeter@781
    45
    /// run properly, of course.
kpeter@781
    46
    /// An actual digraph implementation like \ref ListDigraph or
kpeter@781
    47
    /// \ref SmartDigraph may have additional functionality.
deba@57
    48
    ///
kpeter@781
    49
    /// \sa Graph
deba@57
    50
    class Digraph {
deba@57
    51
    private:
kpeter@781
    52
      /// Diraphs are \e not copy constructible. Use DigraphCopy instead.
kpeter@781
    53
      Digraph(const Digraph &) {}
kpeter@781
    54
      /// \brief Assignment of a digraph to another one is \e not allowed.
kpeter@781
    55
      /// Use DigraphCopy instead.
kpeter@781
    56
      void operator=(const Digraph &) {}
alpar@209
    57
kpeter@781
    58
    public:
kpeter@781
    59
      /// Default constructor.
kpeter@781
    60
      Digraph() { }
alpar@209
    61
kpeter@781
    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@781
    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@781
    71
        /// Default constructor.
kpeter@781
    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
kpeter@781
    80
        /// %Invalid constructor \& conversion.
deba@57
    81
kpeter@781
    82
        /// Initializes the object to be invalid.
deba@57
    83
        /// \sa Invalid for more details.
deba@57
    84
        Node(Invalid) { }
deba@57
    85
        /// Equality operator
deba@57
    86
kpeter@781
    87
        /// Equality operator.
kpeter@781
    88
        ///
deba@57
    89
        /// Two iterators are equal if and only if they point to the
kpeter@781
    90
        /// same object or both are \c INVALID.
deba@57
    91
        bool operator==(Node) const { return true; }
deba@57
    92
deba@57
    93
        /// Inequality operator
alpar@209
    94
kpeter@781
    95
        /// Inequality operator.
deba@57
    96
        bool operator!=(Node) const { return true; }
deba@57
    97
alpar@209
    98
        /// Artificial ordering operator.
alpar@209
    99
kpeter@781
   100
        /// Artificial ordering operator.
alpar@209
   101
        ///
kpeter@781
   102
        /// \note This operator only has to define some strict ordering of
kpeter@781
   103
        /// the nodes; this order has nothing to do with the iteration
kpeter@781
   104
        /// ordering of the nodes.
alpar@209
   105
        bool operator<(Node) const { return false; }
deba@57
   106
      };
alpar@209
   107
kpeter@781
   108
      /// Iterator class for the nodes.
deba@57
   109
kpeter@781
   110
      /// This iterator goes through each node of the digraph.
kpeter@833
   111
      /// Its usage is quite simple, for example, you can count the number
kpeter@781
   112
      /// of nodes in a digraph \c g of type \c %Digraph like this:
deba@57
   113
      ///\code
deba@57
   114
      /// int count=0;
deba@57
   115
      /// for (Digraph::NodeIt n(g); n!=INVALID; ++n) ++count;
deba@57
   116
      ///\endcode
deba@57
   117
      class NodeIt : public Node {
deba@57
   118
      public:
deba@57
   119
        /// Default constructor
deba@57
   120
kpeter@781
   121
        /// Default constructor.
kpeter@781
   122
        /// \warning It sets the iterator to an undefined value.
deba@57
   123
        NodeIt() { }
deba@57
   124
        /// Copy constructor.
alpar@209
   125
deba@57
   126
        /// Copy constructor.
deba@57
   127
        ///
deba@57
   128
        NodeIt(const NodeIt& n) : Node(n) { }
kpeter@781
   129
        /// %Invalid constructor \& conversion.
deba@57
   130
kpeter@781
   131
        /// Initializes the iterator to be invalid.
deba@57
   132
        /// \sa Invalid for more details.
deba@57
   133
        NodeIt(Invalid) { }
deba@57
   134
        /// Sets the iterator to the first node.
deba@57
   135
kpeter@781
   136
        /// Sets the iterator to the first node of the given digraph.
deba@57
   137
        ///
kpeter@781
   138
        explicit NodeIt(const Digraph&) { }
kpeter@781
   139
        /// Sets the iterator to the given node.
deba@57
   140
kpeter@781
   141
        /// Sets the iterator to the given node of the given digraph.
kpeter@781
   142
        ///
deba@57
   143
        NodeIt(const Digraph&, const Node&) { }
deba@57
   144
        /// Next node.
deba@57
   145
deba@57
   146
        /// Assign the iterator to the next node.
deba@57
   147
        ///
deba@57
   148
        NodeIt& operator++() { return *this; }
deba@57
   149
      };
alpar@209
   150
ggab90@1336
   151
      /// \brief Gets the collection of the nodes of the digraph.
ggab90@1336
   152
      ///
ggab90@1336
   153
      /// This function can be used for iterating on
ggab90@1336
   154
      /// the nodes of the digraph. It returns a wrapped NodeIt, which looks
ggab90@1336
   155
      /// like an STL container (by having begin() and end())
ggab90@1336
   156
      /// which you can use in range-based for loops, STL algorithms, etc.
ggab90@1336
   157
      /// For example you can write:
ggab90@1336
   158
      ///\code
ggab90@1336
   159
      /// ListDigraph g;
ggab90@1336
   160
      /// for(auto v: g.nodes())
ggab90@1336
   161
      ///   doSomething(v);
ggab90@1336
   162
      ///
ggab90@1336
   163
      /// //Using an STL algorithm:
ggab90@1336
   164
      /// copy(g.nodes().begin(), g.nodes().end(), vect.begin());
ggab90@1336
   165
      ///\endcode
ggab90@1336
   166
      LemonRangeWrapper1<NodeIt, Digraph> nodes() const {
ggab90@1336
   167
        return LemonRangeWrapper1<NodeIt, Digraph>(*this);
ggab90@1336
   168
      }
ggab90@1336
   169
alpar@209
   170
kpeter@781
   171
      /// The arc type of the digraph
deba@57
   172
deba@57
   173
      /// This class identifies an arc of the digraph. It also serves
deba@57
   174
      /// as a base class of the arc iterators,
deba@57
   175
      /// thus they will convert to this type.
deba@57
   176
      class Arc {
deba@57
   177
      public:
deba@57
   178
        /// Default constructor
deba@57
   179
kpeter@781
   180
        /// Default constructor.
kpeter@781
   181
        /// \warning It sets the object to an undefined value.
deba@57
   182
        Arc() { }
deba@57
   183
        /// Copy constructor.
deba@57
   184
deba@57
   185
        /// Copy constructor.
deba@57
   186
        ///
deba@57
   187
        Arc(const Arc&) { }
kpeter@781
   188
        /// %Invalid constructor \& conversion.
deba@57
   189
kpeter@781
   190
        /// Initializes the object to be invalid.
kpeter@781
   191
        /// \sa Invalid for more details.
deba@57
   192
        Arc(Invalid) { }
deba@57
   193
        /// Equality operator
deba@57
   194
kpeter@781
   195
        /// Equality operator.
kpeter@781
   196
        ///
deba@57
   197
        /// Two iterators are equal if and only if they point to the
kpeter@781
   198
        /// same object or both are \c INVALID.
deba@57
   199
        bool operator==(Arc) const { return true; }
deba@57
   200
        /// Inequality operator
deba@57
   201
kpeter@781
   202
        /// Inequality operator.
deba@57
   203
        bool operator!=(Arc) const { return true; }
deba@57
   204
alpar@209
   205
        /// Artificial ordering operator.
alpar@209
   206
kpeter@781
   207
        /// Artificial ordering operator.
alpar@209
   208
        ///
kpeter@781
   209
        /// \note This operator only has to define some strict ordering of
kpeter@781
   210
        /// the arcs; this order has nothing to do with the iteration
kpeter@781
   211
        /// ordering of the arcs.
alpar@209
   212
        bool operator<(Arc) const { return false; }
deba@57
   213
      };
alpar@209
   214
kpeter@781
   215
      /// Iterator class for the outgoing arcs of a node.
deba@57
   216
deba@57
   217
      /// This iterator goes trough the \e outgoing arcs of a certain node
deba@57
   218
      /// of a digraph.
kpeter@833
   219
      /// Its usage is quite simple, for example, you can count the number
deba@57
   220
      /// of outgoing arcs of a node \c n
kpeter@781
   221
      /// in a digraph \c g of type \c %Digraph as follows.
deba@57
   222
      ///\code
deba@57
   223
      /// int count=0;
kpeter@781
   224
      /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
deba@57
   225
      ///\endcode
deba@57
   226
      class OutArcIt : public Arc {
deba@57
   227
      public:
deba@57
   228
        /// Default constructor
deba@57
   229
kpeter@781
   230
        /// Default constructor.
kpeter@781
   231
        /// \warning It sets the iterator to an undefined value.
deba@57
   232
        OutArcIt() { }
deba@57
   233
        /// Copy constructor.
deba@57
   234
deba@57
   235
        /// Copy constructor.
deba@57
   236
        ///
deba@57
   237
        OutArcIt(const OutArcIt& e) : Arc(e) { }
kpeter@781
   238
        /// %Invalid constructor \& conversion.
deba@57
   239
kpeter@781
   240
        /// Initializes the iterator to be invalid.
kpeter@781
   241
        /// \sa Invalid for more details.
kpeter@781
   242
        OutArcIt(Invalid) { }
kpeter@781
   243
        /// Sets the iterator to the first outgoing arc.
kpeter@781
   244
kpeter@781
   245
        /// Sets the iterator to the first outgoing arc of the given node.
deba@57
   246
        ///
kpeter@781
   247
        OutArcIt(const Digraph&, const Node&) { }
kpeter@781
   248
        /// Sets the iterator to the given arc.
alpar@209
   249
kpeter@781
   250
        /// Sets the iterator to the given arc of the given digraph.
kpeter@781
   251
        ///
deba@57
   252
        OutArcIt(const Digraph&, const Arc&) { }
kpeter@781
   253
        /// Next outgoing arc
alpar@209
   254
alpar@209
   255
        /// Assign the iterator to the next
deba@57
   256
        /// outgoing arc of the corresponding node.
deba@57
   257
        OutArcIt& operator++() { return *this; }
deba@57
   258
      };
deba@57
   259
ggab90@1336
   260
      /// \brief Gets the collection of the outgoing arcs of a certain node
ggab90@1336
   261
      /// of the digraph.
ggab90@1336
   262
      ///
ggab90@1336
   263
      /// This function can be used for iterating on the
ggab90@1336
   264
      /// outgoing arcs of a certain node of the digraph. It returns a wrapped
ggab90@1336
   265
      /// OutArcIt, which looks like an STL container
ggab90@1336
   266
      /// (by having begin() and end()) which you can use in range-based
ggab90@1336
   267
      /// for loops, STL algorithms, etc.
ggab90@1336
   268
      /// For example if g is a Digraph and u is a node, you can write:
ggab90@1336
   269
      ///\code
ggab90@1336
   270
      /// for(auto a: g.outArcs(u))
ggab90@1336
   271
      ///   doSomething(a);
ggab90@1336
   272
      ///
ggab90@1336
   273
      /// //Using an STL algorithm:
ggab90@1336
   274
      /// copy(g.outArcs(u).begin(), g.outArcs(u).end(), vect.begin());
ggab90@1336
   275
      ///\endcode
ggab90@1336
   276
      LemonRangeWrapper2<OutArcIt, Digraph, Node> outArcs(const Node& u) const {
ggab90@1336
   277
        return LemonRangeWrapper2<OutArcIt, Digraph, Node>(*this, u);
ggab90@1336
   278
      }
ggab90@1336
   279
ggab90@1336
   280
kpeter@781
   281
      /// Iterator class for the incoming arcs of a node.
deba@57
   282
deba@57
   283
      /// This iterator goes trough the \e incoming arcs of a certain node
deba@57
   284
      /// of a digraph.
kpeter@833
   285
      /// Its usage is quite simple, for example, you can count the number
kpeter@781
   286
      /// of incoming arcs of a node \c n
kpeter@781
   287
      /// in a digraph \c g of type \c %Digraph as follows.
deba@57
   288
      ///\code
deba@57
   289
      /// int count=0;
kpeter@781
   290
      /// for(Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
deba@57
   291
      ///\endcode
deba@57
   292
      class InArcIt : public Arc {
deba@57
   293
      public:
deba@57
   294
        /// Default constructor
deba@57
   295
kpeter@781
   296
        /// Default constructor.
kpeter@781
   297
        /// \warning It sets the iterator to an undefined value.
deba@57
   298
        InArcIt() { }
deba@57
   299
        /// Copy constructor.
deba@57
   300
deba@57
   301
        /// Copy constructor.
deba@57
   302
        ///
deba@57
   303
        InArcIt(const InArcIt& e) : Arc(e) { }
kpeter@781
   304
        /// %Invalid constructor \& conversion.
deba@57
   305
kpeter@781
   306
        /// Initializes the iterator to be invalid.
kpeter@781
   307
        /// \sa Invalid for more details.
kpeter@781
   308
        InArcIt(Invalid) { }
kpeter@781
   309
        /// Sets the iterator to the first incoming arc.
kpeter@781
   310
kpeter@781
   311
        /// Sets the iterator to the first incoming arc of the given node.
deba@57
   312
        ///
kpeter@781
   313
        InArcIt(const Digraph&, const Node&) { }
kpeter@781
   314
        /// Sets the iterator to the given arc.
alpar@209
   315
kpeter@781
   316
        /// Sets the iterator to the given arc of the given digraph.
kpeter@781
   317
        ///
deba@57
   318
        InArcIt(const Digraph&, const Arc&) { }
deba@57
   319
        /// Next incoming arc
deba@57
   320
kpeter@781
   321
        /// Assign the iterator to the next
kpeter@781
   322
        /// incoming arc of the corresponding node.
deba@57
   323
        InArcIt& operator++() { return *this; }
deba@57
   324
      };
deba@57
   325
ggab90@1336
   326
      /// \brief Gets the collection of the incoming arcs of a certain node
ggab90@1336
   327
      /// of the digraph.
ggab90@1336
   328
      ///
ggab90@1336
   329
      /// This function can be used for iterating on the
ggab90@1336
   330
      /// incoming arcs of a certain node of the digraph. It returns a wrapped
ggab90@1336
   331
      /// InArcIt, which looks like an STL container
ggab90@1336
   332
      /// (by having begin() and end()) which you can use in range-based
ggab90@1336
   333
      /// for loops, STL algorithms, etc.
ggab90@1336
   334
      /// For example if g is a Digraph and u is a node, you can write:
ggab90@1336
   335
      ///\code
ggab90@1336
   336
      /// for(auto a: g.inArcs(u))
ggab90@1336
   337
      ///   doSomething(a);
ggab90@1336
   338
      ///
ggab90@1336
   339
      /// //Using an STL algorithm:
ggab90@1336
   340
      /// copy(g.inArcs(u).begin(), g.inArcs(u).end(), vect.begin());
ggab90@1336
   341
      ///\endcode
ggab90@1336
   342
      LemonRangeWrapper2<InArcIt, Digraph, Node> inArcs(const Node& u) const {
ggab90@1336
   343
        return LemonRangeWrapper2<InArcIt, Digraph, Node>(*this, u);
ggab90@1336
   344
      }
ggab90@1336
   345
ggab90@1336
   346
kpeter@781
   347
      /// Iterator class for the arcs.
kpeter@781
   348
kpeter@781
   349
      /// This iterator goes through each arc of the digraph.
kpeter@833
   350
      /// Its usage is quite simple, for example, you can count the number
kpeter@781
   351
      /// of arcs in a digraph \c g of type \c %Digraph as follows:
deba@57
   352
      ///\code
deba@57
   353
      /// int count=0;
kpeter@781
   354
      /// for(Digraph::ArcIt a(g); a!=INVALID; ++a) ++count;
deba@57
   355
      ///\endcode
deba@57
   356
      class ArcIt : public Arc {
deba@57
   357
      public:
deba@57
   358
        /// Default constructor
deba@57
   359
kpeter@781
   360
        /// Default constructor.
kpeter@781
   361
        /// \warning It sets the iterator to an undefined value.
deba@57
   362
        ArcIt() { }
deba@57
   363
        /// Copy constructor.
deba@57
   364
deba@57
   365
        /// Copy constructor.
deba@57
   366
        ///
deba@57
   367
        ArcIt(const ArcIt& e) : Arc(e) { }
kpeter@781
   368
        /// %Invalid constructor \& conversion.
deba@57
   369
kpeter@781
   370
        /// Initializes the iterator to be invalid.
kpeter@781
   371
        /// \sa Invalid for more details.
kpeter@781
   372
        ArcIt(Invalid) { }
kpeter@781
   373
        /// Sets the iterator to the first arc.
kpeter@781
   374
kpeter@781
   375
        /// Sets the iterator to the first arc of the given digraph.
deba@57
   376
        ///
alpar@1271
   377
        explicit ArcIt(const Digraph& g) {
alpar@1271
   378
          ::lemon::ignore_unused_variable_warning(g);
alpar@1271
   379
        }
kpeter@781
   380
        /// Sets the iterator to the given arc.
alpar@209
   381
kpeter@781
   382
        /// Sets the iterator to the given arc of the given digraph.
kpeter@781
   383
        ///
alpar@209
   384
        ArcIt(const Digraph&, const Arc&) { }
kpeter@781
   385
        /// Next arc
alpar@209
   386
deba@57
   387
        /// Assign the iterator to the next arc.
kpeter@781
   388
        ///
deba@57
   389
        ArcIt& operator++() { return *this; }
deba@57
   390
      };
deba@57
   391
ggab90@1336
   392
      /// \brief Gets the collection of the arcs of the digraph.
ggab90@1336
   393
      ///
ggab90@1336
   394
      /// This function can be used for iterating on the
ggab90@1336
   395
      /// arcs of the digraph. It returns a wrapped
ggab90@1336
   396
      /// ArcIt, which looks like an STL container
ggab90@1336
   397
      /// (by having begin() and end()) which you can use in range-based
ggab90@1336
   398
      /// for loops, STL algorithms, etc.
ggab90@1336
   399
      /// For example you can write:
ggab90@1336
   400
      ///\code
ggab90@1336
   401
      /// ListDigraph g;
ggab90@1336
   402
      /// for(auto a: g.arcs())
ggab90@1336
   403
      ///   doSomething(a);
ggab90@1336
   404
      ///
ggab90@1336
   405
      /// //Using an STL algorithm:
ggab90@1336
   406
      /// copy(g.arcs().begin(), g.arcs().end(), vect.begin());
ggab90@1336
   407
      ///\endcode
ggab90@1336
   408
      LemonRangeWrapper1<ArcIt, Digraph> arcs() const {
ggab90@1336
   409
        return LemonRangeWrapper1<ArcIt, Digraph>(*this);
ggab90@1336
   410
      }
ggab90@1336
   411
ggab90@1336
   412
kpeter@781
   413
      /// \brief The source node of the arc.
deba@57
   414
      ///
kpeter@781
   415
      /// Returns the source node of the given arc.
deba@57
   416
      Node source(Arc) const { return INVALID; }
deba@57
   417
kpeter@781
   418
      /// \brief The target node of the arc.
kpeter@781
   419
      ///
kpeter@781
   420
      /// Returns the target node of the given arc.
kpeter@781
   421
      Node target(Arc) const { return INVALID; }
kpeter@781
   422
kpeter@781
   423
      /// \brief The ID of the node.
kpeter@781
   424
      ///
kpeter@781
   425
      /// Returns the ID of the given node.
alpar@209
   426
      int id(Node) const { return -1; }
deba@61
   427
kpeter@781
   428
      /// \brief The ID of the arc.
kpeter@781
   429
      ///
kpeter@781
   430
      /// Returns the ID of the given arc.
alpar@209
   431
      int id(Arc) const { return -1; }
deba@61
   432
kpeter@781
   433
      /// \brief The node with the given ID.
deba@61
   434
      ///
kpeter@781
   435
      /// Returns the node with the given ID.
kpeter@781
   436
      /// \pre The argument should be a valid node ID in the digraph.
alpar@209
   437
      Node nodeFromId(int) const { return INVALID; }
deba@61
   438
kpeter@781
   439
      /// \brief The arc with the given ID.
deba@61
   440
      ///
kpeter@781
   441
      /// Returns the arc with the given ID.
kpeter@781
   442
      /// \pre The argument should be a valid arc ID in the digraph.
alpar@209
   443
      Arc arcFromId(int) const { return INVALID; }
deba@61
   444
kpeter@781
   445
      /// \brief An upper bound on the node IDs.
kpeter@781
   446
      ///
kpeter@781
   447
      /// Returns an upper bound on the node IDs.
alpar@209
   448
      int maxNodeId() const { return -1; }
deba@61
   449
kpeter@781
   450
      /// \brief An upper bound on the arc IDs.
kpeter@781
   451
      ///
kpeter@781
   452
      /// Returns an upper bound on the arc IDs.
alpar@209
   453
      int maxArcId() const { return -1; }
deba@61
   454
deba@57
   455
      void first(Node&) const {}
deba@57
   456
      void next(Node&) const {}
deba@57
   457
deba@57
   458
      void first(Arc&) const {}
deba@57
   459
      void next(Arc&) const {}
deba@57
   460
deba@57
   461
deba@57
   462
      void firstIn(Arc&, const Node&) const {}
deba@57
   463
      void nextIn(Arc&) const {}
deba@57
   464
deba@57
   465
      void firstOut(Arc&, const Node&) const {}
deba@57
   466
      void nextOut(Arc&) const {}
deba@57
   467
deba@61
   468
      // The second parameter is dummy.
deba@61
   469
      Node fromId(int, Node) const { return INVALID; }
deba@61
   470
      // The second parameter is dummy.
deba@61
   471
      Arc fromId(int, Arc) const { return INVALID; }
deba@61
   472
deba@61
   473
      // Dummy parameter.
alpar@209
   474
      int maxId(Node) const { return -1; }
deba@61
   475
      // Dummy parameter.
alpar@209
   476
      int maxId(Arc) const { return -1; }
deba@61
   477
kpeter@781
   478
      /// \brief The opposite node on the arc.
kpeter@781
   479
      ///
kpeter@781
   480
      /// Returns the opposite node on the given arc.
kpeter@781
   481
      Node oppositeNode(Node, Arc) const { return INVALID; }
kpeter@781
   482
deba@57
   483
      /// \brief The base node of the iterator.
deba@57
   484
      ///
kpeter@781
   485
      /// Returns the base node of the given outgoing arc iterator
kpeter@781
   486
      /// (i.e. the source node of the corresponding arc).
kpeter@781
   487
      Node baseNode(OutArcIt) const { return INVALID; }
deba@57
   488
deba@57
   489
      /// \brief The running node of the iterator.
deba@57
   490
      ///
kpeter@781
   491
      /// Returns the running node of the given outgoing arc iterator
kpeter@781
   492
      /// (i.e. the target node of the corresponding arc).
kpeter@781
   493
      Node runningNode(OutArcIt) const { return INVALID; }
deba@57
   494
deba@57
   495
      /// \brief The base node of the iterator.
deba@57
   496
      ///
kpeter@1217
   497
      /// Returns the base node of the given incoming arc iterator
kpeter@781
   498
      /// (i.e. the target node of the corresponding arc).
kpeter@781
   499
      Node baseNode(InArcIt) const { return INVALID; }
deba@57
   500
deba@57
   501
      /// \brief The running node of the iterator.
deba@57
   502
      ///
kpeter@1217
   503
      /// Returns the running node of the given incoming arc iterator
kpeter@781
   504
      /// (i.e. the source node of the corresponding arc).
kpeter@781
   505
      Node runningNode(InArcIt) const { return INVALID; }
deba@57
   506
kpeter@781
   507
      /// \brief Standard graph map type for the nodes.
deba@57
   508
      ///
kpeter@781
   509
      /// Standard graph map type for the nodes.
kpeter@781
   510
      /// It conforms to the ReferenceMap concept.
alpar@209
   511
      template<class T>
kpeter@627
   512
      class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
deba@57
   513
      public:
deba@57
   514
kpeter@781
   515
        /// Constructor
kpeter@781
   516
        explicit NodeMap(const Digraph&) { }
kpeter@781
   517
        /// Constructor with given initial value
deba@57
   518
        NodeMap(const Digraph&, T) { }
deba@57
   519
kpeter@263
   520
      private:
deba@57
   521
        ///Copy constructor
alpar@956
   522
        NodeMap(const NodeMap& nm) :
kpeter@627
   523
          ReferenceMap<Node, T, T&, const T&>(nm) { }
deba@57
   524
        ///Assignment operator
deba@57
   525
        template <typename CMap>
alpar@209
   526
        NodeMap& operator=(const CMap&) {
deba@57
   527
          checkConcept<ReadMap<Node, T>, CMap>();
alpar@209
   528
          return *this;
deba@57
   529
        }
deba@57
   530
      };
deba@57
   531
kpeter@781
   532
      /// \brief Standard graph map type for the arcs.
deba@57
   533
      ///
kpeter@781
   534
      /// Standard graph map type for the arcs.
kpeter@781
   535
      /// It conforms to the ReferenceMap concept.
alpar@209
   536
      template<class T>
kpeter@627
   537
      class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
deba@57
   538
      public:
deba@57
   539
kpeter@781
   540
        /// Constructor
kpeter@781
   541
        explicit ArcMap(const Digraph&) { }
kpeter@781
   542
        /// Constructor with given initial value
deba@57
   543
        ArcMap(const Digraph&, T) { }
kpeter@781
   544
kpeter@263
   545
      private:
deba@57
   546
        ///Copy constructor
kpeter@627
   547
        ArcMap(const ArcMap& em) :
kpeter@627
   548
          ReferenceMap<Arc, T, T&, const T&>(em) { }
deba@57
   549
        ///Assignment operator
deba@57
   550
        template <typename CMap>
alpar@209
   551
        ArcMap& operator=(const CMap&) {
deba@57
   552
          checkConcept<ReadMap<Arc, T>, CMap>();
alpar@209
   553
          return *this;
deba@57
   554
        }
deba@57
   555
      };
deba@57
   556
deba@125
   557
      template <typename _Digraph>
deba@57
   558
      struct Constraints {
deba@57
   559
        void constraints() {
kpeter@627
   560
          checkConcept<BaseDigraphComponent, _Digraph>();
deba@125
   561
          checkConcept<IterableDigraphComponent<>, _Digraph>();
alpar@209
   562
          checkConcept<IDableDigraphComponent<>, _Digraph>();
deba@125
   563
          checkConcept<MappableDigraphComponent<>, _Digraph>();
deba@57
   564
        }
deba@57
   565
      };
deba@57
   566
deba@57
   567
    };
alpar@209
   568
alpar@209
   569
  } //namespace concepts
deba@57
   570
} //namespace lemon
deba@57
   571
deba@57
   572
deba@57
   573
deba@576
   574
#endif