lemon/concepts/graph.h
author Peter Kovacs <kpeter@inf.elte.hu>
Wed, 15 Apr 2009 12:01:14 +0200
changeset 590 b61354458b59
parent 559 c5fd2d996909
child 657 bf7928412136
permissions -rw-r--r--
Imporvements for the matching algorithms (#264)
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@440
     5
 * Copyright (C) 2003-2009
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@57
    19
///\ingroup graph_concepts
deba@57
    20
///\file
deba@57
    21
///\brief The concept of Undirected Graphs.
deba@57
    22
deba@529
    23
#ifndef LEMON_CONCEPTS_GRAPH_H
deba@529
    24
#define LEMON_CONCEPTS_GRAPH_H
deba@57
    25
deba@57
    26
#include <lemon/concepts/graph_components.h>
deba@220
    27
#include <lemon/core.h>
deba@57
    28
deba@57
    29
namespace lemon {
deba@57
    30
  namespace concepts {
deba@57
    31
deba@57
    32
    /// \ingroup graph_concepts
deba@57
    33
    ///
deba@57
    34
    /// \brief Class describing the concept of Undirected Graphs.
deba@57
    35
    ///
deba@57
    36
    /// This class describes the common interface of all Undirected
deba@57
    37
    /// Graphs.
deba@57
    38
    ///
deba@57
    39
    /// As all concept describing classes it provides only interface
deba@57
    40
    /// without any sensible implementation. So any algorithm for
deba@57
    41
    /// undirected graph should compile with this class, but it will not
deba@57
    42
    /// run properly, of course.
deba@57
    43
    ///
deba@57
    44
    /// The LEMON undirected graphs also fulfill the concept of
deba@57
    45
    /// directed graphs (\ref lemon::concepts::Digraph "Digraph
deba@57
    46
    /// Concept"). Each edges can be seen as two opposite
deba@57
    47
    /// directed arc and consequently the undirected graph can be
deba@57
    48
    /// seen as the direceted graph of these directed arcs. The
deba@57
    49
    /// Graph has the Edge inner class for the edges and
deba@57
    50
    /// the Arc type for the directed arcs. The Arc type is
deba@57
    51
    /// convertible to Edge or inherited from it so from a directed
deba@57
    52
    /// arc we can get the represented edge.
deba@57
    53
    ///
deba@57
    54
    /// In the sense of the LEMON each edge has a default
deba@57
    55
    /// direction (it should be in every computer implementation,
deba@57
    56
    /// because the order of edge's nodes defines an
deba@57
    57
    /// orientation). With the default orientation we can define that
deba@57
    58
    /// the directed arc is forward or backward directed. With the \c
deba@57
    59
    /// direction() and \c direct() function we can get the direction
deba@57
    60
    /// of the directed arc and we can direct an edge.
deba@57
    61
    ///
deba@57
    62
    /// The EdgeIt is an iterator for the edges. We can use
deba@57
    63
    /// the EdgeMap to map values for the edges. The InArcIt and
deba@57
    64
    /// OutArcIt iterates on the same edges but with opposite
deba@78
    65
    /// direction. The IncEdgeIt iterates also on the same edges
deba@57
    66
    /// as the OutArcIt and InArcIt but it is not convertible to Arc just
alpar@209
    67
    /// to Edge.
deba@57
    68
    class Graph {
deba@57
    69
    public:
deba@57
    70
      /// \brief The undirected graph should be tagged by the
deba@57
    71
      /// UndirectedTag.
deba@57
    72
      ///
deba@57
    73
      /// The undirected graph should be tagged by the UndirectedTag. This
alpar@209
    74
      /// tag helps the enable_if technics to make compile time
alpar@209
    75
      /// specializations for undirected graphs.
deba@57
    76
      typedef True UndirectedTag;
deba@57
    77
alpar@209
    78
      /// \brief The base type of node iterators,
deba@57
    79
      /// or in other words, the trivial node iterator.
deba@57
    80
      ///
deba@57
    81
      /// This is the base type of each node iterator,
deba@57
    82
      /// thus each kind of node iterator converts to this.
alpar@209
    83
      /// More precisely each kind of node iterator should be inherited
deba@57
    84
      /// from the trivial node iterator.
deba@57
    85
      class Node {
deba@57
    86
      public:
deba@57
    87
        /// Default constructor
deba@57
    88
deba@57
    89
        /// @warning The default constructor sets the iterator
deba@57
    90
        /// to an undefined value.
deba@57
    91
        Node() { }
deba@57
    92
        /// Copy constructor.
deba@57
    93
deba@57
    94
        /// Copy constructor.
deba@57
    95
        ///
deba@57
    96
        Node(const Node&) { }
deba@57
    97
deba@57
    98
        /// Invalid constructor \& conversion.
deba@57
    99
deba@57
   100
        /// This constructor initializes the iterator to be invalid.
deba@57
   101
        /// \sa Invalid for more details.
deba@57
   102
        Node(Invalid) { }
deba@57
   103
        /// Equality operator
deba@57
   104
deba@57
   105
        /// Two iterators are equal if and only if they point to the
deba@57
   106
        /// same object or both are invalid.
deba@57
   107
        bool operator==(Node) const { return true; }
deba@57
   108
deba@57
   109
        /// Inequality operator
alpar@209
   110
deba@57
   111
        /// \sa operator==(Node n)
deba@57
   112
        ///
deba@57
   113
        bool operator!=(Node) const { return true; }
deba@57
   114
alpar@209
   115
        /// Artificial ordering operator.
alpar@209
   116
alpar@209
   117
        /// To allow the use of graph descriptors as key type in std::map or
alpar@209
   118
        /// similar associative container we require this.
alpar@209
   119
        ///
alpar@209
   120
        /// \note This operator only have to define some strict ordering of
alpar@209
   121
        /// the items; this order has nothing to do with the iteration
alpar@209
   122
        /// ordering of the items.
alpar@209
   123
        bool operator<(Node) const { return false; }
deba@57
   124
deba@57
   125
      };
alpar@209
   126
deba@57
   127
      /// This iterator goes through each node.
deba@57
   128
deba@57
   129
      /// This iterator goes through each node.
deba@57
   130
      /// Its usage is quite simple, for example you can count the number
deba@57
   131
      /// of nodes in graph \c g of type \c Graph like this:
deba@57
   132
      ///\code
deba@57
   133
      /// int count=0;
deba@57
   134
      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
deba@57
   135
      ///\endcode
deba@57
   136
      class NodeIt : public Node {
deba@57
   137
      public:
deba@57
   138
        /// Default constructor
deba@57
   139
deba@57
   140
        /// @warning The default constructor sets the iterator
deba@57
   141
        /// to an undefined value.
deba@57
   142
        NodeIt() { }
deba@57
   143
        /// Copy constructor.
alpar@209
   144
deba@57
   145
        /// Copy constructor.
deba@57
   146
        ///
deba@57
   147
        NodeIt(const NodeIt& n) : Node(n) { }
deba@57
   148
        /// Invalid constructor \& conversion.
deba@57
   149
deba@57
   150
        /// Initialize the iterator to be invalid.
deba@57
   151
        /// \sa Invalid for more details.
deba@57
   152
        NodeIt(Invalid) { }
deba@57
   153
        /// Sets the iterator to the first node.
deba@57
   154
deba@57
   155
        /// Sets the iterator to the first node of \c g.
deba@57
   156
        ///
deba@57
   157
        NodeIt(const Graph&) { }
deba@57
   158
        /// Node -> NodeIt conversion.
deba@57
   159
alpar@209
   160
        /// Sets the iterator to the node of \c the graph pointed by
alpar@209
   161
        /// the trivial iterator.
alpar@209
   162
        /// This feature necessitates that each time we
deba@57
   163
        /// iterate the arc-set, the iteration order is the same.
deba@57
   164
        NodeIt(const Graph&, const Node&) { }
deba@57
   165
        /// Next node.
deba@57
   166
deba@57
   167
        /// Assign the iterator to the next node.
deba@57
   168
        ///
deba@57
   169
        NodeIt& operator++() { return *this; }
deba@57
   170
      };
alpar@209
   171
alpar@209
   172
deba@57
   173
      /// The base type of the edge iterators.
deba@57
   174
deba@57
   175
      /// The base type of the edge iterators.
deba@57
   176
      ///
deba@57
   177
      class Edge {
deba@57
   178
      public:
deba@57
   179
        /// Default constructor
deba@57
   180
deba@57
   181
        /// @warning The default constructor sets the iterator
deba@57
   182
        /// to an undefined value.
deba@57
   183
        Edge() { }
deba@57
   184
        /// Copy constructor.
deba@57
   185
deba@57
   186
        /// Copy constructor.
deba@57
   187
        ///
deba@57
   188
        Edge(const Edge&) { }
deba@57
   189
        /// Initialize the iterator to be invalid.
deba@57
   190
deba@57
   191
        /// Initialize the iterator to be invalid.
deba@57
   192
        ///
deba@57
   193
        Edge(Invalid) { }
deba@57
   194
        /// Equality operator
deba@57
   195
deba@57
   196
        /// Two iterators are equal if and only if they point to the
deba@57
   197
        /// same object or both are invalid.
deba@57
   198
        bool operator==(Edge) const { return true; }
deba@57
   199
        /// Inequality operator
deba@57
   200
deba@57
   201
        /// \sa operator==(Edge n)
deba@57
   202
        ///
deba@57
   203
        bool operator!=(Edge) const { return true; }
deba@57
   204
alpar@209
   205
        /// Artificial ordering operator.
alpar@209
   206
alpar@209
   207
        /// To allow the use of graph descriptors as key type in std::map or
alpar@209
   208
        /// similar associative container we require this.
alpar@209
   209
        ///
alpar@209
   210
        /// \note This operator only have to define some strict ordering of
alpar@209
   211
        /// the items; this order has nothing to do with the iteration
alpar@209
   212
        /// ordering of the items.
alpar@209
   213
        bool operator<(Edge) const { return false; }
deba@57
   214
      };
deba@57
   215
deba@57
   216
      /// This iterator goes through each edge.
deba@57
   217
deba@57
   218
      /// This iterator goes through each edge of a graph.
deba@57
   219
      /// Its usage is quite simple, for example you can count the number
deba@57
   220
      /// of edges in a graph \c g of type \c Graph as follows:
deba@57
   221
      ///\code
deba@57
   222
      /// int count=0;
deba@57
   223
      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
deba@57
   224
      ///\endcode
deba@57
   225
      class EdgeIt : public Edge {
deba@57
   226
      public:
deba@57
   227
        /// Default constructor
deba@57
   228
deba@57
   229
        /// @warning The default constructor sets the iterator
deba@57
   230
        /// to an undefined value.
deba@57
   231
        EdgeIt() { }
deba@57
   232
        /// Copy constructor.
deba@57
   233
deba@57
   234
        /// Copy constructor.
deba@57
   235
        ///
deba@57
   236
        EdgeIt(const EdgeIt& e) : Edge(e) { }
deba@57
   237
        /// Initialize the iterator to be invalid.
deba@57
   238
deba@57
   239
        /// Initialize the iterator to be invalid.
deba@57
   240
        ///
deba@57
   241
        EdgeIt(Invalid) { }
deba@57
   242
        /// This constructor sets the iterator to the first edge.
alpar@209
   243
deba@57
   244
        /// This constructor sets the iterator to the first edge.
deba@57
   245
        EdgeIt(const Graph&) { }
deba@57
   246
        /// Edge -> EdgeIt conversion
deba@57
   247
deba@57
   248
        /// Sets the iterator to the value of the trivial iterator.
deba@57
   249
        /// This feature necessitates that each time we
alpar@209
   250
        /// iterate the edge-set, the iteration order is the
alpar@209
   251
        /// same.
alpar@209
   252
        EdgeIt(const Graph&, const Edge&) { }
deba@57
   253
        /// Next edge
alpar@209
   254
deba@57
   255
        /// Assign the iterator to the next edge.
deba@57
   256
        EdgeIt& operator++() { return *this; }
deba@57
   257
      };
deba@57
   258
alpar@209
   259
      /// \brief This iterator goes trough the incident undirected
deba@57
   260
      /// arcs of a node.
deba@57
   261
      ///
deba@57
   262
      /// This iterator goes trough the incident edges
alpar@209
   263
      /// of a certain node of a graph. You should assume that the
deba@57
   264
      /// loop arcs will be iterated twice.
alpar@209
   265
      ///
deba@57
   266
      /// Its usage is quite simple, for example you can compute the
deba@57
   267
      /// degree (i.e. count the number of incident arcs of a node \c n
alpar@209
   268
      /// in graph \c g of type \c Graph as follows.
deba@57
   269
      ///
deba@57
   270
      ///\code
deba@57
   271
      /// int count=0;
deba@78
   272
      /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@57
   273
      ///\endcode
deba@78
   274
      class IncEdgeIt : public Edge {
deba@57
   275
      public:
deba@57
   276
        /// Default constructor
deba@57
   277
deba@57
   278
        /// @warning The default constructor sets the iterator
deba@57
   279
        /// to an undefined value.
deba@78
   280
        IncEdgeIt() { }
deba@57
   281
        /// Copy constructor.
deba@57
   282
deba@57
   283
        /// Copy constructor.
deba@57
   284
        ///
deba@78
   285
        IncEdgeIt(const IncEdgeIt& e) : Edge(e) { }
deba@57
   286
        /// Initialize the iterator to be invalid.
deba@57
   287
deba@57
   288
        /// Initialize the iterator to be invalid.
deba@57
   289
        ///
deba@78
   290
        IncEdgeIt(Invalid) { }
deba@57
   291
        /// This constructor sets the iterator to first incident arc.
alpar@209
   292
deba@57
   293
        /// This constructor set the iterator to the first incident arc of
deba@57
   294
        /// the node.
deba@78
   295
        IncEdgeIt(const Graph&, const Node&) { }
deba@78
   296
        /// Edge -> IncEdgeIt conversion
deba@57
   297
deba@57
   298
        /// Sets the iterator to the value of the trivial iterator \c e.
alpar@209
   299
        /// This feature necessitates that each time we
deba@57
   300
        /// iterate the arc-set, the iteration order is the same.
deba@78
   301
        IncEdgeIt(const Graph&, const Edge&) { }
deba@57
   302
        /// Next incident arc
deba@57
   303
deba@57
   304
        /// Assign the iterator to the next incident arc
alpar@209
   305
        /// of the corresponding node.
deba@78
   306
        IncEdgeIt& operator++() { return *this; }
deba@57
   307
      };
deba@57
   308
deba@57
   309
      /// The directed arc type.
deba@57
   310
deba@57
   311
      /// The directed arc type. It can be converted to the
deba@57
   312
      /// edge or it should be inherited from the undirected
deba@57
   313
      /// arc.
deba@57
   314
      class Arc : public Edge {
deba@57
   315
      public:
deba@57
   316
        /// Default constructor
deba@57
   317
deba@57
   318
        /// @warning The default constructor sets the iterator
deba@57
   319
        /// to an undefined value.
deba@57
   320
        Arc() { }
deba@57
   321
        /// Copy constructor.
deba@57
   322
deba@57
   323
        /// Copy constructor.
deba@57
   324
        ///
deba@57
   325
        Arc(const Arc& e) : Edge(e) { }
deba@57
   326
        /// Initialize the iterator to be invalid.
deba@57
   327
deba@57
   328
        /// Initialize the iterator to be invalid.
deba@57
   329
        ///
deba@57
   330
        Arc(Invalid) { }
deba@57
   331
        /// Equality operator
deba@57
   332
deba@57
   333
        /// Two iterators are equal if and only if they point to the
deba@57
   334
        /// same object or both are invalid.
deba@57
   335
        bool operator==(Arc) const { return true; }
deba@57
   336
        /// Inequality operator
deba@57
   337
deba@57
   338
        /// \sa operator==(Arc n)
deba@57
   339
        ///
deba@57
   340
        bool operator!=(Arc) const { return true; }
deba@57
   341
alpar@209
   342
        /// Artificial ordering operator.
alpar@209
   343
alpar@209
   344
        /// To allow the use of graph descriptors as key type in std::map or
alpar@209
   345
        /// similar associative container we require this.
alpar@209
   346
        ///
alpar@209
   347
        /// \note This operator only have to define some strict ordering of
alpar@209
   348
        /// the items; this order has nothing to do with the iteration
alpar@209
   349
        /// ordering of the items.
alpar@209
   350
        bool operator<(Arc) const { return false; }
alpar@209
   351
alpar@209
   352
      };
deba@57
   353
      /// This iterator goes through each directed arc.
deba@57
   354
deba@57
   355
      /// This iterator goes through each arc of a graph.
deba@57
   356
      /// Its usage is quite simple, for example you can count the number
deba@57
   357
      /// of arcs in a graph \c g of type \c Graph as follows:
deba@57
   358
      ///\code
deba@57
   359
      /// int count=0;
deba@57
   360
      /// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count;
deba@57
   361
      ///\endcode
deba@57
   362
      class ArcIt : public Arc {
deba@57
   363
      public:
deba@57
   364
        /// Default constructor
deba@57
   365
deba@57
   366
        /// @warning The default constructor sets the iterator
deba@57
   367
        /// to an undefined value.
deba@57
   368
        ArcIt() { }
deba@57
   369
        /// Copy constructor.
deba@57
   370
deba@57
   371
        /// Copy constructor.
deba@57
   372
        ///
deba@57
   373
        ArcIt(const ArcIt& e) : Arc(e) { }
deba@57
   374
        /// Initialize the iterator to be invalid.
deba@57
   375
deba@57
   376
        /// Initialize the iterator to be invalid.
deba@57
   377
        ///
deba@57
   378
        ArcIt(Invalid) { }
deba@57
   379
        /// This constructor sets the iterator to the first arc.
alpar@209
   380
deba@57
   381
        /// This constructor sets the iterator to the first arc of \c g.
deba@57
   382
        ///@param g the graph
deba@57
   383
        ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
deba@57
   384
        /// Arc -> ArcIt conversion
deba@57
   385
deba@57
   386
        /// Sets the iterator to the value of the trivial iterator \c e.
alpar@209
   387
        /// This feature necessitates that each time we
deba@57
   388
        /// iterate the arc-set, the iteration order is the same.
alpar@209
   389
        ArcIt(const Graph&, const Arc&) { }
deba@57
   390
        ///Next arc
alpar@209
   391
deba@57
   392
        /// Assign the iterator to the next arc.
deba@57
   393
        ArcIt& operator++() { return *this; }
deba@57
   394
      };
alpar@209
   395
deba@57
   396
      /// This iterator goes trough the outgoing directed arcs of a node.
deba@57
   397
deba@57
   398
      /// This iterator goes trough the \e outgoing arcs of a certain node
deba@57
   399
      /// of a graph.
deba@57
   400
      /// Its usage is quite simple, for example you can count the number
deba@57
   401
      /// of outgoing arcs of a node \c n
deba@57
   402
      /// in graph \c g of type \c Graph as follows.
deba@57
   403
      ///\code
deba@57
   404
      /// int count=0;
deba@57
   405
      /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
deba@57
   406
      ///\endcode
alpar@209
   407
deba@57
   408
      class OutArcIt : public Arc {
deba@57
   409
      public:
deba@57
   410
        /// Default constructor
deba@57
   411
deba@57
   412
        /// @warning The default constructor sets the iterator
deba@57
   413
        /// to an undefined value.
deba@57
   414
        OutArcIt() { }
deba@57
   415
        /// Copy constructor.
deba@57
   416
deba@57
   417
        /// Copy constructor.
deba@57
   418
        ///
deba@57
   419
        OutArcIt(const OutArcIt& e) : Arc(e) { }
deba@57
   420
        /// Initialize the iterator to be invalid.
deba@57
   421
deba@57
   422
        /// Initialize the iterator to be invalid.
deba@57
   423
        ///
deba@57
   424
        OutArcIt(Invalid) { }
deba@57
   425
        /// This constructor sets the iterator to the first outgoing arc.
alpar@209
   426
deba@57
   427
        /// This constructor sets the iterator to the first outgoing arc of
deba@57
   428
        /// the node.
deba@57
   429
        ///@param n the node
deba@57
   430
        ///@param g the graph
deba@57
   431
        OutArcIt(const Graph& n, const Node& g) {
alpar@209
   432
          ignore_unused_variable_warning(n);
alpar@209
   433
          ignore_unused_variable_warning(g);
alpar@209
   434
        }
deba@57
   435
        /// Arc -> OutArcIt conversion
deba@57
   436
deba@57
   437
        /// Sets the iterator to the value of the trivial iterator.
alpar@209
   438
        /// This feature necessitates that each time we
deba@57
   439
        /// iterate the arc-set, the iteration order is the same.
deba@57
   440
        OutArcIt(const Graph&, const Arc&) { }
deba@57
   441
        ///Next outgoing arc
alpar@209
   442
alpar@209
   443
        /// Assign the iterator to the next
deba@57
   444
        /// outgoing arc of the corresponding node.
deba@57
   445
        OutArcIt& operator++() { return *this; }
deba@57
   446
      };
deba@57
   447
deba@57
   448
      /// This iterator goes trough the incoming directed arcs of a node.
deba@57
   449
deba@57
   450
      /// This iterator goes trough the \e incoming arcs of a certain node
deba@57
   451
      /// of a graph.
deba@57
   452
      /// Its usage is quite simple, for example you can count the number
deba@57
   453
      /// of outgoing arcs of a node \c n
deba@57
   454
      /// in graph \c g of type \c Graph as follows.
deba@57
   455
      ///\code
deba@57
   456
      /// int count=0;
deba@57
   457
      /// for(Graph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
deba@57
   458
      ///\endcode
deba@57
   459
deba@57
   460
      class InArcIt : public Arc {
deba@57
   461
      public:
deba@57
   462
        /// Default constructor
deba@57
   463
deba@57
   464
        /// @warning The default constructor sets the iterator
deba@57
   465
        /// to an undefined value.
deba@57
   466
        InArcIt() { }
deba@57
   467
        /// Copy constructor.
deba@57
   468
deba@57
   469
        /// Copy constructor.
deba@57
   470
        ///
deba@57
   471
        InArcIt(const InArcIt& e) : Arc(e) { }
deba@57
   472
        /// Initialize the iterator to be invalid.
deba@57
   473
deba@57
   474
        /// Initialize the iterator to be invalid.
deba@57
   475
        ///
deba@57
   476
        InArcIt(Invalid) { }
deba@57
   477
        /// This constructor sets the iterator to first incoming arc.
alpar@209
   478
deba@57
   479
        /// This constructor set the iterator to the first incoming arc of
deba@57
   480
        /// the node.
deba@57
   481
        ///@param n the node
deba@57
   482
        ///@param g the graph
alpar@209
   483
        InArcIt(const Graph& g, const Node& n) {
alpar@209
   484
          ignore_unused_variable_warning(n);
alpar@209
   485
          ignore_unused_variable_warning(g);
alpar@209
   486
        }
deba@57
   487
        /// Arc -> InArcIt conversion
deba@57
   488
deba@57
   489
        /// Sets the iterator to the value of the trivial iterator \c e.
alpar@209
   490
        /// This feature necessitates that each time we
deba@57
   491
        /// iterate the arc-set, the iteration order is the same.
deba@57
   492
        InArcIt(const Graph&, const Arc&) { }
deba@57
   493
        /// Next incoming arc
deba@57
   494
deba@57
   495
        /// Assign the iterator to the next inarc of the corresponding node.
deba@57
   496
        ///
deba@57
   497
        InArcIt& operator++() { return *this; }
deba@57
   498
      };
deba@57
   499
kpeter@580
   500
      /// \brief Reference map of the nodes to type \c T.
alpar@209
   501
      ///
kpeter@580
   502
      /// Reference map of the nodes to type \c T.
alpar@209
   503
      template<class T>
kpeter@580
   504
      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
deba@57
   505
      {
deba@57
   506
      public:
deba@57
   507
deba@57
   508
        ///\e
deba@57
   509
        NodeMap(const Graph&) { }
deba@57
   510
        ///\e
deba@57
   511
        NodeMap(const Graph&, T) { }
deba@57
   512
kpeter@263
   513
      private:
deba@57
   514
        ///Copy constructor
kpeter@580
   515
        NodeMap(const NodeMap& nm) :
kpeter@580
   516
          ReferenceMap<Node, T, T&, const T&>(nm) { }
deba@57
   517
        ///Assignment operator
deba@57
   518
        template <typename CMap>
alpar@209
   519
        NodeMap& operator=(const CMap&) {
deba@57
   520
          checkConcept<ReadMap<Node, T>, CMap>();
alpar@209
   521
          return *this;
deba@57
   522
        }
deba@57
   523
      };
deba@57
   524
kpeter@580
   525
      /// \brief Reference map of the arcs to type \c T.
deba@57
   526
      ///
kpeter@580
   527
      /// Reference map of the arcs to type \c T.
alpar@209
   528
      template<class T>
kpeter@580
   529
      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
deba@57
   530
      {
deba@57
   531
      public:
deba@57
   532
deba@57
   533
        ///\e
deba@57
   534
        ArcMap(const Graph&) { }
deba@57
   535
        ///\e
deba@57
   536
        ArcMap(const Graph&, T) { }
kpeter@263
   537
      private:
deba@57
   538
        ///Copy constructor
kpeter@580
   539
        ArcMap(const ArcMap& em) :
kpeter@580
   540
          ReferenceMap<Arc, T, T&, const T&>(em) { }
deba@57
   541
        ///Assignment operator
deba@57
   542
        template <typename CMap>
alpar@209
   543
        ArcMap& operator=(const CMap&) {
deba@57
   544
          checkConcept<ReadMap<Arc, T>, CMap>();
alpar@209
   545
          return *this;
deba@57
   546
        }
deba@57
   547
      };
deba@57
   548
kpeter@580
   549
      /// Reference map of the edges to type \c T.
deba@57
   550
kpeter@580
   551
      /// Reference map of the edges to type \c T.
alpar@209
   552
      template<class T>
kpeter@580
   553
      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
deba@57
   554
      {
deba@57
   555
      public:
deba@57
   556
deba@57
   557
        ///\e
deba@57
   558
        EdgeMap(const Graph&) { }
deba@57
   559
        ///\e
deba@57
   560
        EdgeMap(const Graph&, T) { }
kpeter@263
   561
      private:
deba@57
   562
        ///Copy constructor
kpeter@580
   563
        EdgeMap(const EdgeMap& em) :
kpeter@580
   564
          ReferenceMap<Edge, T, T&, const T&>(em) {}
deba@57
   565
        ///Assignment operator
deba@57
   566
        template <typename CMap>
alpar@209
   567
        EdgeMap& operator=(const CMap&) {
deba@57
   568
          checkConcept<ReadMap<Edge, T>, CMap>();
alpar@209
   569
          return *this;
deba@57
   570
        }
deba@57
   571
      };
deba@57
   572
deba@57
   573
      /// \brief Direct the given edge.
deba@57
   574
      ///
deba@57
   575
      /// Direct the given edge. The returned arc source
deba@57
   576
      /// will be the given node.
deba@57
   577
      Arc direct(const Edge&, const Node&) const {
alpar@209
   578
        return INVALID;
deba@57
   579
      }
deba@57
   580
deba@57
   581
      /// \brief Direct the given edge.
deba@57
   582
      ///
deba@57
   583
      /// Direct the given edge. The returned arc
deba@57
   584
      /// represents the given edge and the direction comes
deba@57
   585
      /// from the bool parameter. The source of the edge and
deba@57
   586
      /// the directed arc is the same when the given bool is true.
deba@57
   587
      Arc direct(const Edge&, bool) const {
alpar@209
   588
        return INVALID;
deba@57
   589
      }
deba@57
   590
deba@57
   591
      /// \brief Returns true if the arc has default orientation.
deba@57
   592
      ///
deba@57
   593
      /// Returns whether the given directed arc is same orientation as
deba@57
   594
      /// the corresponding edge's default orientation.
deba@57
   595
      bool direction(Arc) const { return true; }
deba@57
   596
deba@57
   597
      /// \brief Returns the opposite directed arc.
deba@57
   598
      ///
deba@57
   599
      /// Returns the opposite directed arc.
deba@57
   600
      Arc oppositeArc(Arc) const { return INVALID; }
deba@57
   601
deba@57
   602
      /// \brief Opposite node on an arc
deba@57
   603
      ///
kpeter@559
   604
      /// \return The opposite of the given node on the given edge.
deba@57
   605
      Node oppositeNode(Node, Edge) const { return INVALID; }
deba@57
   606
deba@57
   607
      /// \brief First node of the edge.
deba@57
   608
      ///
kpeter@559
   609
      /// \return The first node of the given edge.
deba@57
   610
      ///
deba@57
   611
      /// Naturally edges don't have direction and thus
kpeter@559
   612
      /// don't have source and target node. However we use \c u() and \c v()
kpeter@559
   613
      /// methods to query the two nodes of the arc. The direction of the
kpeter@559
   614
      /// arc which arises this way is called the inherent direction of the
deba@57
   615
      /// edge, and is used to define the "default" direction
deba@57
   616
      /// of the directed versions of the arcs.
kpeter@559
   617
      /// \sa v()
kpeter@559
   618
      /// \sa direction()
deba@57
   619
      Node u(Edge) const { return INVALID; }
deba@57
   620
deba@57
   621
      /// \brief Second node of the edge.
kpeter@559
   622
      ///
kpeter@559
   623
      /// \return The second node of the given edge.
kpeter@559
   624
      ///
kpeter@559
   625
      /// Naturally edges don't have direction and thus
kpeter@559
   626
      /// don't have source and target node. However we use \c u() and \c v()
kpeter@559
   627
      /// methods to query the two nodes of the arc. The direction of the
kpeter@559
   628
      /// arc which arises this way is called the inherent direction of the
kpeter@559
   629
      /// edge, and is used to define the "default" direction
kpeter@559
   630
      /// of the directed versions of the arcs.
kpeter@559
   631
      /// \sa u()
kpeter@559
   632
      /// \sa direction()
deba@57
   633
      Node v(Edge) const { return INVALID; }
deba@57
   634
deba@57
   635
      /// \brief Source node of the directed arc.
deba@57
   636
      Node source(Arc) const { return INVALID; }
deba@57
   637
deba@57
   638
      /// \brief Target node of the directed arc.
deba@57
   639
      Node target(Arc) const { return INVALID; }
deba@57
   640
deba@61
   641
      /// \brief Returns the id of the node.
alpar@209
   642
      int id(Node) const { return -1; }
deba@61
   643
deba@61
   644
      /// \brief Returns the id of the edge.
alpar@209
   645
      int id(Edge) const { return -1; }
deba@61
   646
deba@61
   647
      /// \brief Returns the id of the arc.
alpar@209
   648
      int id(Arc) const { return -1; }
deba@61
   649
deba@61
   650
      /// \brief Returns the node with the given id.
deba@61
   651
      ///
deba@61
   652
      /// \pre The argument should be a valid node id in the graph.
alpar@209
   653
      Node nodeFromId(int) const { return INVALID; }
deba@61
   654
deba@61
   655
      /// \brief Returns the edge with the given id.
deba@61
   656
      ///
deba@61
   657
      /// \pre The argument should be a valid edge id in the graph.
alpar@209
   658
      Edge edgeFromId(int) const { return INVALID; }
deba@61
   659
deba@61
   660
      /// \brief Returns the arc with the given id.
deba@61
   661
      ///
deba@61
   662
      /// \pre The argument should be a valid arc id in the graph.
alpar@209
   663
      Arc arcFromId(int) const { return INVALID; }
deba@61
   664
deba@61
   665
      /// \brief Returns an upper bound on the node IDs.
alpar@209
   666
      int maxNodeId() const { return -1; }
deba@61
   667
deba@61
   668
      /// \brief Returns an upper bound on the edge IDs.
alpar@209
   669
      int maxEdgeId() const { return -1; }
deba@61
   670
deba@61
   671
      /// \brief Returns an upper bound on the arc IDs.
alpar@209
   672
      int maxArcId() const { return -1; }
deba@61
   673
deba@57
   674
      void first(Node&) const {}
deba@57
   675
      void next(Node&) const {}
deba@57
   676
deba@57
   677
      void first(Edge&) const {}
deba@57
   678
      void next(Edge&) const {}
deba@57
   679
deba@57
   680
      void first(Arc&) const {}
deba@57
   681
      void next(Arc&) const {}
deba@57
   682
deba@57
   683
      void firstOut(Arc&, Node) const {}
deba@57
   684
      void nextOut(Arc&) const {}
deba@57
   685
deba@57
   686
      void firstIn(Arc&, Node) const {}
deba@57
   687
      void nextIn(Arc&) const {}
deba@57
   688
deba@57
   689
      void firstInc(Edge &, bool &, const Node &) const {}
deba@57
   690
      void nextInc(Edge &, bool &) const {}
deba@57
   691
deba@61
   692
      // The second parameter is dummy.
deba@61
   693
      Node fromId(int, Node) const { return INVALID; }
deba@61
   694
      // The second parameter is dummy.
deba@61
   695
      Edge fromId(int, Edge) const { return INVALID; }
deba@61
   696
      // The second parameter is dummy.
deba@61
   697
      Arc fromId(int, Arc) const { return INVALID; }
deba@61
   698
deba@61
   699
      // Dummy parameter.
alpar@209
   700
      int maxId(Node) const { return -1; }
deba@61
   701
      // Dummy parameter.
alpar@209
   702
      int maxId(Edge) const { return -1; }
deba@61
   703
      // Dummy parameter.
alpar@209
   704
      int maxId(Arc) const { return -1; }
deba@61
   705
deba@57
   706
      /// \brief Base node of the iterator
deba@57
   707
      ///
deba@57
   708
      /// Returns the base node (the source in this case) of the iterator
deba@57
   709
      Node baseNode(OutArcIt e) const {
alpar@209
   710
        return source(e);
deba@57
   711
      }
deba@57
   712
      /// \brief Running node of the iterator
deba@57
   713
      ///
deba@57
   714
      /// Returns the running node (the target in this case) of the
deba@57
   715
      /// iterator
deba@57
   716
      Node runningNode(OutArcIt e) const {
alpar@209
   717
        return target(e);
deba@57
   718
      }
deba@57
   719
deba@57
   720
      /// \brief Base node of the iterator
deba@57
   721
      ///
deba@57
   722
      /// Returns the base node (the target in this case) of the iterator
deba@57
   723
      Node baseNode(InArcIt e) const {
alpar@209
   724
        return target(e);
deba@57
   725
      }
deba@57
   726
      /// \brief Running node of the iterator
deba@57
   727
      ///
deba@57
   728
      /// Returns the running node (the source in this case) of the
deba@57
   729
      /// iterator
deba@57
   730
      Node runningNode(InArcIt e) const {
alpar@209
   731
        return source(e);
deba@57
   732
      }
deba@57
   733
deba@57
   734
      /// \brief Base node of the iterator
deba@57
   735
      ///
deba@57
   736
      /// Returns the base node of the iterator
deba@78
   737
      Node baseNode(IncEdgeIt) const {
alpar@209
   738
        return INVALID;
deba@57
   739
      }
alpar@209
   740
deba@57
   741
      /// \brief Running node of the iterator
deba@57
   742
      ///
deba@57
   743
      /// Returns the running node of the iterator
deba@78
   744
      Node runningNode(IncEdgeIt) const {
alpar@209
   745
        return INVALID;
deba@57
   746
      }
deba@57
   747
deba@125
   748
      template <typename _Graph>
deba@57
   749
      struct Constraints {
alpar@209
   750
        void constraints() {
kpeter@580
   751
          checkConcept<BaseGraphComponent, _Graph>();
alpar@209
   752
          checkConcept<IterableGraphComponent<>, _Graph>();
alpar@209
   753
          checkConcept<IDableGraphComponent<>, _Graph>();
alpar@209
   754
          checkConcept<MappableGraphComponent<>, _Graph>();
alpar@209
   755
        }
deba@57
   756
      };
deba@57
   757
deba@57
   758
    };
deba@57
   759
deba@57
   760
  }
deba@57
   761
deba@57
   762
}
deba@57
   763
deba@57
   764
#endif