lemon/concepts/graph.h
author Alpar Juttner <alpar@cs.elte.hu>
Mon, 31 Aug 2009 08:32:25 +0200
changeset 700 6f7c1052d260
parent 580 2313edd0db0b
child 734 bd72f8d20f33
child 1083 3e711ee55d31
permissions -rw-r--r--
Merge
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
kpeter@657
   313
      /// edge.
kpeter@657
   314
      class Arc {
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
        ///
kpeter@657
   325
        Arc(const Arc&) { }
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
kpeter@657
   352
        /// Converison to Edge
kpeter@657
   353
        operator Edge() const { return Edge(); }
alpar@209
   354
      };
deba@57
   355
      /// This iterator goes through each directed arc.
deba@57
   356
deba@57
   357
      /// This iterator goes through each arc of a graph.
deba@57
   358
      /// Its usage is quite simple, for example you can count the number
deba@57
   359
      /// of arcs in a graph \c g of type \c Graph as follows:
deba@57
   360
      ///\code
deba@57
   361
      /// int count=0;
deba@57
   362
      /// for(Graph::ArcIt e(g); e!=INVALID; ++e) ++count;
deba@57
   363
      ///\endcode
deba@57
   364
      class ArcIt : public Arc {
deba@57
   365
      public:
deba@57
   366
        /// Default constructor
deba@57
   367
deba@57
   368
        /// @warning The default constructor sets the iterator
deba@57
   369
        /// to an undefined value.
deba@57
   370
        ArcIt() { }
deba@57
   371
        /// Copy constructor.
deba@57
   372
deba@57
   373
        /// Copy constructor.
deba@57
   374
        ///
deba@57
   375
        ArcIt(const ArcIt& e) : Arc(e) { }
deba@57
   376
        /// Initialize the iterator to be invalid.
deba@57
   377
deba@57
   378
        /// Initialize the iterator to be invalid.
deba@57
   379
        ///
deba@57
   380
        ArcIt(Invalid) { }
deba@57
   381
        /// This constructor sets the iterator to the first arc.
alpar@209
   382
deba@57
   383
        /// This constructor sets the iterator to the first arc of \c g.
deba@57
   384
        ///@param g the graph
deba@57
   385
        ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
deba@57
   386
        /// Arc -> ArcIt conversion
deba@57
   387
deba@57
   388
        /// Sets the iterator to the value of the trivial iterator \c e.
alpar@209
   389
        /// This feature necessitates that each time we
deba@57
   390
        /// iterate the arc-set, the iteration order is the same.
alpar@209
   391
        ArcIt(const Graph&, const Arc&) { }
deba@57
   392
        ///Next arc
alpar@209
   393
deba@57
   394
        /// Assign the iterator to the next arc.
deba@57
   395
        ArcIt& operator++() { return *this; }
deba@57
   396
      };
alpar@209
   397
deba@57
   398
      /// This iterator goes trough the outgoing directed arcs of a node.
deba@57
   399
deba@57
   400
      /// This iterator goes trough the \e outgoing arcs of a certain node
deba@57
   401
      /// of a graph.
deba@57
   402
      /// Its usage is quite simple, for example you can count the number
deba@57
   403
      /// of outgoing arcs of a node \c n
deba@57
   404
      /// in graph \c g of type \c Graph as follows.
deba@57
   405
      ///\code
deba@57
   406
      /// int count=0;
deba@57
   407
      /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
deba@57
   408
      ///\endcode
alpar@209
   409
deba@57
   410
      class OutArcIt : public Arc {
deba@57
   411
      public:
deba@57
   412
        /// Default constructor
deba@57
   413
deba@57
   414
        /// @warning The default constructor sets the iterator
deba@57
   415
        /// to an undefined value.
deba@57
   416
        OutArcIt() { }
deba@57
   417
        /// Copy constructor.
deba@57
   418
deba@57
   419
        /// Copy constructor.
deba@57
   420
        ///
deba@57
   421
        OutArcIt(const OutArcIt& e) : Arc(e) { }
deba@57
   422
        /// Initialize the iterator to be invalid.
deba@57
   423
deba@57
   424
        /// Initialize the iterator to be invalid.
deba@57
   425
        ///
deba@57
   426
        OutArcIt(Invalid) { }
deba@57
   427
        /// This constructor sets the iterator to the first outgoing arc.
alpar@209
   428
deba@57
   429
        /// This constructor sets the iterator to the first outgoing arc of
deba@57
   430
        /// the node.
deba@57
   431
        ///@param n the node
deba@57
   432
        ///@param g the graph
deba@57
   433
        OutArcIt(const Graph& n, const Node& g) {
alpar@209
   434
          ignore_unused_variable_warning(n);
alpar@209
   435
          ignore_unused_variable_warning(g);
alpar@209
   436
        }
deba@57
   437
        /// Arc -> OutArcIt conversion
deba@57
   438
deba@57
   439
        /// Sets the iterator to the value of the trivial iterator.
alpar@209
   440
        /// This feature necessitates that each time we
deba@57
   441
        /// iterate the arc-set, the iteration order is the same.
deba@57
   442
        OutArcIt(const Graph&, const Arc&) { }
deba@57
   443
        ///Next outgoing arc
alpar@209
   444
alpar@209
   445
        /// Assign the iterator to the next
deba@57
   446
        /// outgoing arc of the corresponding node.
deba@57
   447
        OutArcIt& operator++() { return *this; }
deba@57
   448
      };
deba@57
   449
deba@57
   450
      /// This iterator goes trough the incoming directed arcs of a node.
deba@57
   451
deba@57
   452
      /// This iterator goes trough the \e incoming arcs of a certain node
deba@57
   453
      /// of a graph.
deba@57
   454
      /// Its usage is quite simple, for example you can count the number
deba@57
   455
      /// of outgoing arcs of a node \c n
deba@57
   456
      /// in graph \c g of type \c Graph as follows.
deba@57
   457
      ///\code
deba@57
   458
      /// int count=0;
deba@57
   459
      /// for(Graph::InArcIt e(g, n); e!=INVALID; ++e) ++count;
deba@57
   460
      ///\endcode
deba@57
   461
deba@57
   462
      class InArcIt : public Arc {
deba@57
   463
      public:
deba@57
   464
        /// Default constructor
deba@57
   465
deba@57
   466
        /// @warning The default constructor sets the iterator
deba@57
   467
        /// to an undefined value.
deba@57
   468
        InArcIt() { }
deba@57
   469
        /// Copy constructor.
deba@57
   470
deba@57
   471
        /// Copy constructor.
deba@57
   472
        ///
deba@57
   473
        InArcIt(const InArcIt& e) : Arc(e) { }
deba@57
   474
        /// Initialize the iterator to be invalid.
deba@57
   475
deba@57
   476
        /// Initialize the iterator to be invalid.
deba@57
   477
        ///
deba@57
   478
        InArcIt(Invalid) { }
deba@57
   479
        /// This constructor sets the iterator to first incoming arc.
alpar@209
   480
deba@57
   481
        /// This constructor set the iterator to the first incoming arc of
deba@57
   482
        /// the node.
deba@57
   483
        ///@param n the node
deba@57
   484
        ///@param g the graph
alpar@209
   485
        InArcIt(const Graph& g, const Node& n) {
alpar@209
   486
          ignore_unused_variable_warning(n);
alpar@209
   487
          ignore_unused_variable_warning(g);
alpar@209
   488
        }
deba@57
   489
        /// Arc -> InArcIt conversion
deba@57
   490
deba@57
   491
        /// Sets the iterator to the value of the trivial iterator \c e.
alpar@209
   492
        /// This feature necessitates that each time we
deba@57
   493
        /// iterate the arc-set, the iteration order is the same.
deba@57
   494
        InArcIt(const Graph&, const Arc&) { }
deba@57
   495
        /// Next incoming arc
deba@57
   496
deba@57
   497
        /// Assign the iterator to the next inarc of the corresponding node.
deba@57
   498
        ///
deba@57
   499
        InArcIt& operator++() { return *this; }
deba@57
   500
      };
deba@57
   501
kpeter@580
   502
      /// \brief Reference map of the nodes to type \c T.
alpar@209
   503
      ///
kpeter@580
   504
      /// Reference map of the nodes to type \c T.
alpar@209
   505
      template<class T>
kpeter@580
   506
      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
deba@57
   507
      {
deba@57
   508
      public:
deba@57
   509
deba@57
   510
        ///\e
deba@57
   511
        NodeMap(const Graph&) { }
deba@57
   512
        ///\e
deba@57
   513
        NodeMap(const Graph&, T) { }
deba@57
   514
kpeter@263
   515
      private:
deba@57
   516
        ///Copy constructor
kpeter@580
   517
        NodeMap(const NodeMap& nm) :
kpeter@580
   518
          ReferenceMap<Node, T, T&, const T&>(nm) { }
deba@57
   519
        ///Assignment operator
deba@57
   520
        template <typename CMap>
alpar@209
   521
        NodeMap& operator=(const CMap&) {
deba@57
   522
          checkConcept<ReadMap<Node, T>, CMap>();
alpar@209
   523
          return *this;
deba@57
   524
        }
deba@57
   525
      };
deba@57
   526
kpeter@580
   527
      /// \brief Reference map of the arcs to type \c T.
deba@57
   528
      ///
kpeter@580
   529
      /// Reference map of the arcs to type \c T.
alpar@209
   530
      template<class T>
kpeter@580
   531
      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
deba@57
   532
      {
deba@57
   533
      public:
deba@57
   534
deba@57
   535
        ///\e
deba@57
   536
        ArcMap(const Graph&) { }
deba@57
   537
        ///\e
deba@57
   538
        ArcMap(const Graph&, T) { }
kpeter@263
   539
      private:
deba@57
   540
        ///Copy constructor
kpeter@580
   541
        ArcMap(const ArcMap& em) :
kpeter@580
   542
          ReferenceMap<Arc, T, T&, const T&>(em) { }
deba@57
   543
        ///Assignment operator
deba@57
   544
        template <typename CMap>
alpar@209
   545
        ArcMap& operator=(const CMap&) {
deba@57
   546
          checkConcept<ReadMap<Arc, T>, CMap>();
alpar@209
   547
          return *this;
deba@57
   548
        }
deba@57
   549
      };
deba@57
   550
kpeter@580
   551
      /// Reference map of the edges to type \c T.
deba@57
   552
kpeter@580
   553
      /// Reference map of the edges to type \c T.
alpar@209
   554
      template<class T>
kpeter@580
   555
      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
deba@57
   556
      {
deba@57
   557
      public:
deba@57
   558
deba@57
   559
        ///\e
deba@57
   560
        EdgeMap(const Graph&) { }
deba@57
   561
        ///\e
deba@57
   562
        EdgeMap(const Graph&, T) { }
kpeter@263
   563
      private:
deba@57
   564
        ///Copy constructor
kpeter@580
   565
        EdgeMap(const EdgeMap& em) :
kpeter@580
   566
          ReferenceMap<Edge, T, T&, const T&>(em) {}
deba@57
   567
        ///Assignment operator
deba@57
   568
        template <typename CMap>
alpar@209
   569
        EdgeMap& operator=(const CMap&) {
deba@57
   570
          checkConcept<ReadMap<Edge, T>, CMap>();
alpar@209
   571
          return *this;
deba@57
   572
        }
deba@57
   573
      };
deba@57
   574
deba@57
   575
      /// \brief Direct the given edge.
deba@57
   576
      ///
deba@57
   577
      /// Direct the given edge. The returned arc source
deba@57
   578
      /// will be the given node.
deba@57
   579
      Arc direct(const Edge&, const Node&) const {
alpar@209
   580
        return INVALID;
deba@57
   581
      }
deba@57
   582
deba@57
   583
      /// \brief Direct the given edge.
deba@57
   584
      ///
deba@57
   585
      /// Direct the given edge. The returned arc
deba@57
   586
      /// represents the given edge and the direction comes
deba@57
   587
      /// from the bool parameter. The source of the edge and
deba@57
   588
      /// the directed arc is the same when the given bool is true.
deba@57
   589
      Arc direct(const Edge&, bool) const {
alpar@209
   590
        return INVALID;
deba@57
   591
      }
deba@57
   592
deba@57
   593
      /// \brief Returns true if the arc has default orientation.
deba@57
   594
      ///
deba@57
   595
      /// Returns whether the given directed arc is same orientation as
deba@57
   596
      /// the corresponding edge's default orientation.
deba@57
   597
      bool direction(Arc) const { return true; }
deba@57
   598
deba@57
   599
      /// \brief Returns the opposite directed arc.
deba@57
   600
      ///
deba@57
   601
      /// Returns the opposite directed arc.
deba@57
   602
      Arc oppositeArc(Arc) const { return INVALID; }
deba@57
   603
deba@57
   604
      /// \brief Opposite node on an arc
deba@57
   605
      ///
kpeter@559
   606
      /// \return The opposite of the given node on the given edge.
deba@57
   607
      Node oppositeNode(Node, Edge) const { return INVALID; }
deba@57
   608
deba@57
   609
      /// \brief First node of the edge.
deba@57
   610
      ///
kpeter@559
   611
      /// \return The first node of the given edge.
deba@57
   612
      ///
deba@57
   613
      /// Naturally edges don't have direction and thus
kpeter@559
   614
      /// don't have source and target node. However we use \c u() and \c v()
kpeter@559
   615
      /// methods to query the two nodes of the arc. The direction of the
kpeter@559
   616
      /// arc which arises this way is called the inherent direction of the
deba@57
   617
      /// edge, and is used to define the "default" direction
deba@57
   618
      /// of the directed versions of the arcs.
kpeter@559
   619
      /// \sa v()
kpeter@559
   620
      /// \sa direction()
deba@57
   621
      Node u(Edge) const { return INVALID; }
deba@57
   622
deba@57
   623
      /// \brief Second node of the edge.
kpeter@559
   624
      ///
kpeter@559
   625
      /// \return The second node of the given edge.
kpeter@559
   626
      ///
kpeter@559
   627
      /// Naturally edges don't have direction and thus
kpeter@559
   628
      /// don't have source and target node. However we use \c u() and \c v()
kpeter@559
   629
      /// methods to query the two nodes of the arc. The direction of the
kpeter@559
   630
      /// arc which arises this way is called the inherent direction of the
kpeter@559
   631
      /// edge, and is used to define the "default" direction
kpeter@559
   632
      /// of the directed versions of the arcs.
kpeter@559
   633
      /// \sa u()
kpeter@559
   634
      /// \sa direction()
deba@57
   635
      Node v(Edge) const { return INVALID; }
deba@57
   636
deba@57
   637
      /// \brief Source node of the directed arc.
deba@57
   638
      Node source(Arc) const { return INVALID; }
deba@57
   639
deba@57
   640
      /// \brief Target node of the directed arc.
deba@57
   641
      Node target(Arc) const { return INVALID; }
deba@57
   642
deba@61
   643
      /// \brief Returns the id of the node.
alpar@209
   644
      int id(Node) const { return -1; }
deba@61
   645
deba@61
   646
      /// \brief Returns the id of the edge.
alpar@209
   647
      int id(Edge) const { return -1; }
deba@61
   648
deba@61
   649
      /// \brief Returns the id of the arc.
alpar@209
   650
      int id(Arc) const { return -1; }
deba@61
   651
deba@61
   652
      /// \brief Returns the node with the given id.
deba@61
   653
      ///
deba@61
   654
      /// \pre The argument should be a valid node id in the graph.
alpar@209
   655
      Node nodeFromId(int) const { return INVALID; }
deba@61
   656
deba@61
   657
      /// \brief Returns the edge with the given id.
deba@61
   658
      ///
deba@61
   659
      /// \pre The argument should be a valid edge id in the graph.
alpar@209
   660
      Edge edgeFromId(int) const { return INVALID; }
deba@61
   661
deba@61
   662
      /// \brief Returns the arc with the given id.
deba@61
   663
      ///
deba@61
   664
      /// \pre The argument should be a valid arc id in the graph.
alpar@209
   665
      Arc arcFromId(int) const { return INVALID; }
deba@61
   666
deba@61
   667
      /// \brief Returns an upper bound on the node IDs.
alpar@209
   668
      int maxNodeId() const { return -1; }
deba@61
   669
deba@61
   670
      /// \brief Returns an upper bound on the edge IDs.
alpar@209
   671
      int maxEdgeId() const { return -1; }
deba@61
   672
deba@61
   673
      /// \brief Returns an upper bound on the arc IDs.
alpar@209
   674
      int maxArcId() const { return -1; }
deba@61
   675
deba@57
   676
      void first(Node&) const {}
deba@57
   677
      void next(Node&) const {}
deba@57
   678
deba@57
   679
      void first(Edge&) const {}
deba@57
   680
      void next(Edge&) const {}
deba@57
   681
deba@57
   682
      void first(Arc&) const {}
deba@57
   683
      void next(Arc&) const {}
deba@57
   684
deba@57
   685
      void firstOut(Arc&, Node) const {}
deba@57
   686
      void nextOut(Arc&) const {}
deba@57
   687
deba@57
   688
      void firstIn(Arc&, Node) const {}
deba@57
   689
      void nextIn(Arc&) const {}
deba@57
   690
deba@57
   691
      void firstInc(Edge &, bool &, const Node &) const {}
deba@57
   692
      void nextInc(Edge &, bool &) const {}
deba@57
   693
deba@61
   694
      // The second parameter is dummy.
deba@61
   695
      Node fromId(int, Node) const { return INVALID; }
deba@61
   696
      // The second parameter is dummy.
deba@61
   697
      Edge fromId(int, Edge) const { return INVALID; }
deba@61
   698
      // The second parameter is dummy.
deba@61
   699
      Arc fromId(int, Arc) const { return INVALID; }
deba@61
   700
deba@61
   701
      // Dummy parameter.
alpar@209
   702
      int maxId(Node) const { return -1; }
deba@61
   703
      // Dummy parameter.
alpar@209
   704
      int maxId(Edge) const { return -1; }
deba@61
   705
      // Dummy parameter.
alpar@209
   706
      int maxId(Arc) const { return -1; }
deba@61
   707
deba@57
   708
      /// \brief Base node of the iterator
deba@57
   709
      ///
deba@57
   710
      /// Returns the base node (the source in this case) of the iterator
deba@57
   711
      Node baseNode(OutArcIt e) const {
alpar@209
   712
        return source(e);
deba@57
   713
      }
deba@57
   714
      /// \brief Running node of the iterator
deba@57
   715
      ///
deba@57
   716
      /// Returns the running node (the target in this case) of the
deba@57
   717
      /// iterator
deba@57
   718
      Node runningNode(OutArcIt e) const {
alpar@209
   719
        return target(e);
deba@57
   720
      }
deba@57
   721
deba@57
   722
      /// \brief Base node of the iterator
deba@57
   723
      ///
deba@57
   724
      /// Returns the base node (the target in this case) of the iterator
deba@57
   725
      Node baseNode(InArcIt e) const {
alpar@209
   726
        return target(e);
deba@57
   727
      }
deba@57
   728
      /// \brief Running node of the iterator
deba@57
   729
      ///
deba@57
   730
      /// Returns the running node (the source in this case) of the
deba@57
   731
      /// iterator
deba@57
   732
      Node runningNode(InArcIt e) const {
alpar@209
   733
        return source(e);
deba@57
   734
      }
deba@57
   735
deba@57
   736
      /// \brief Base node of the iterator
deba@57
   737
      ///
deba@57
   738
      /// Returns the base node of the iterator
deba@78
   739
      Node baseNode(IncEdgeIt) const {
alpar@209
   740
        return INVALID;
deba@57
   741
      }
alpar@209
   742
deba@57
   743
      /// \brief Running node of the iterator
deba@57
   744
      ///
deba@57
   745
      /// Returns the running node of the iterator
deba@78
   746
      Node runningNode(IncEdgeIt) const {
alpar@209
   747
        return INVALID;
deba@57
   748
      }
deba@57
   749
deba@125
   750
      template <typename _Graph>
deba@57
   751
      struct Constraints {
alpar@209
   752
        void constraints() {
kpeter@580
   753
          checkConcept<BaseGraphComponent, _Graph>();
alpar@209
   754
          checkConcept<IterableGraphComponent<>, _Graph>();
alpar@209
   755
          checkConcept<IDableGraphComponent<>, _Graph>();
alpar@209
   756
          checkConcept<MappableGraphComponent<>, _Graph>();
alpar@209
   757
        }
deba@57
   758
      };
deba@57
   759
deba@57
   760
    };
deba@57
   761
deba@57
   762
  }
deba@57
   763
deba@57
   764
}
deba@57
   765
deba@57
   766
#endif