lemon/concepts/graph.h
author Alpar Juttner <alpar@cs.elte.hu>
Mon, 23 Feb 2009 15:03:55 +0000
changeset 520 6643fc6dafc1
parent 440 88ed40ad0d4f
child 550 c5fd2d996909
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@514
    23
#ifndef LEMON_CONCEPTS_GRAPH_H
deba@514
    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
deba@57
   500
      /// \brief Read write map of the nodes to type \c T.
alpar@209
   501
      ///
deba@57
   502
      /// ReadWrite map of the nodes to type \c T.
deba@57
   503
      /// \sa Reference
alpar@209
   504
      template<class T>
deba@57
   505
      class NodeMap : public ReadWriteMap< Node, T >
deba@57
   506
      {
deba@57
   507
      public:
deba@57
   508
deba@57
   509
        ///\e
deba@57
   510
        NodeMap(const Graph&) { }
deba@57
   511
        ///\e
deba@57
   512
        NodeMap(const Graph&, T) { }
deba@57
   513
kpeter@263
   514
      private:
deba@57
   515
        ///Copy constructor
deba@57
   516
        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, 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
deba@57
   525
      /// \brief Read write map of the directed arcs to type \c T.
deba@57
   526
      ///
deba@57
   527
      /// Reference map of the directed arcs to type \c T.
deba@57
   528
      /// \sa Reference
alpar@209
   529
      template<class T>
deba@57
   530
      class ArcMap : public ReadWriteMap<Arc,T>
deba@57
   531
      {
deba@57
   532
      public:
deba@57
   533
deba@57
   534
        ///\e
deba@57
   535
        ArcMap(const Graph&) { }
deba@57
   536
        ///\e
deba@57
   537
        ArcMap(const Graph&, T) { }
kpeter@263
   538
      private:
deba@57
   539
        ///Copy constructor
deba@57
   540
        ArcMap(const ArcMap& em) : ReadWriteMap<Arc,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
deba@57
   549
      /// Read write map of the edges to type \c T.
deba@57
   550
deba@57
   551
      /// Reference map of the arcs to type \c T.
deba@57
   552
      /// \sa Reference
alpar@209
   553
      template<class T>
deba@57
   554
      class EdgeMap : public ReadWriteMap<Edge,T>
deba@57
   555
      {
deba@57
   556
      public:
deba@57
   557
deba@57
   558
        ///\e
deba@57
   559
        EdgeMap(const Graph&) { }
deba@57
   560
        ///\e
deba@57
   561
        EdgeMap(const Graph&, T) { }
kpeter@263
   562
      private:
deba@57
   563
        ///Copy constructor
deba@57
   564
        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,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
      ///
deba@57
   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
      ///
deba@57
   609
      /// \return the first node of the given Edge.
deba@57
   610
      ///
deba@57
   611
      /// Naturally edges don't have direction and thus
deba@57
   612
      /// don't have source and target node. But we use these two methods
deba@57
   613
      /// to query the two nodes of the arc. The direction of the arc
deba@57
   614
      /// 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.
deba@57
   617
      /// \sa direction
deba@57
   618
      Node u(Edge) const { return INVALID; }
deba@57
   619
deba@57
   620
      /// \brief Second node of the edge.
deba@57
   621
      Node v(Edge) const { return INVALID; }
deba@57
   622
deba@57
   623
      /// \brief Source node of the directed arc.
deba@57
   624
      Node source(Arc) const { return INVALID; }
deba@57
   625
deba@57
   626
      /// \brief Target node of the directed arc.
deba@57
   627
      Node target(Arc) const { return INVALID; }
deba@57
   628
deba@61
   629
      /// \brief Returns the id of the node.
alpar@209
   630
      int id(Node) const { return -1; }
deba@61
   631
deba@61
   632
      /// \brief Returns the id of the edge.
alpar@209
   633
      int id(Edge) const { return -1; }
deba@61
   634
deba@61
   635
      /// \brief Returns the id of the arc.
alpar@209
   636
      int id(Arc) const { return -1; }
deba@61
   637
deba@61
   638
      /// \brief Returns the node with the given id.
deba@61
   639
      ///
deba@61
   640
      /// \pre The argument should be a valid node id in the graph.
alpar@209
   641
      Node nodeFromId(int) const { return INVALID; }
deba@61
   642
deba@61
   643
      /// \brief Returns the edge with the given id.
deba@61
   644
      ///
deba@61
   645
      /// \pre The argument should be a valid edge id in the graph.
alpar@209
   646
      Edge edgeFromId(int) const { return INVALID; }
deba@61
   647
deba@61
   648
      /// \brief Returns the arc with the given id.
deba@61
   649
      ///
deba@61
   650
      /// \pre The argument should be a valid arc id in the graph.
alpar@209
   651
      Arc arcFromId(int) const { return INVALID; }
deba@61
   652
deba@61
   653
      /// \brief Returns an upper bound on the node IDs.
alpar@209
   654
      int maxNodeId() const { return -1; }
deba@61
   655
deba@61
   656
      /// \brief Returns an upper bound on the edge IDs.
alpar@209
   657
      int maxEdgeId() const { return -1; }
deba@61
   658
deba@61
   659
      /// \brief Returns an upper bound on the arc IDs.
alpar@209
   660
      int maxArcId() const { return -1; }
deba@61
   661
deba@57
   662
      void first(Node&) const {}
deba@57
   663
      void next(Node&) const {}
deba@57
   664
deba@57
   665
      void first(Edge&) const {}
deba@57
   666
      void next(Edge&) const {}
deba@57
   667
deba@57
   668
      void first(Arc&) const {}
deba@57
   669
      void next(Arc&) const {}
deba@57
   670
deba@57
   671
      void firstOut(Arc&, Node) const {}
deba@57
   672
      void nextOut(Arc&) const {}
deba@57
   673
deba@57
   674
      void firstIn(Arc&, Node) const {}
deba@57
   675
      void nextIn(Arc&) const {}
deba@57
   676
deba@57
   677
      void firstInc(Edge &, bool &, const Node &) const {}
deba@57
   678
      void nextInc(Edge &, bool &) const {}
deba@57
   679
deba@61
   680
      // The second parameter is dummy.
deba@61
   681
      Node fromId(int, Node) const { return INVALID; }
deba@61
   682
      // The second parameter is dummy.
deba@61
   683
      Edge fromId(int, Edge) const { return INVALID; }
deba@61
   684
      // The second parameter is dummy.
deba@61
   685
      Arc fromId(int, Arc) const { return INVALID; }
deba@61
   686
deba@61
   687
      // Dummy parameter.
alpar@209
   688
      int maxId(Node) const { return -1; }
deba@61
   689
      // Dummy parameter.
alpar@209
   690
      int maxId(Edge) const { return -1; }
deba@61
   691
      // Dummy parameter.
alpar@209
   692
      int maxId(Arc) const { return -1; }
deba@61
   693
deba@57
   694
      /// \brief Base node of the iterator
deba@57
   695
      ///
deba@57
   696
      /// Returns the base node (the source in this case) of the iterator
deba@57
   697
      Node baseNode(OutArcIt e) const {
alpar@209
   698
        return source(e);
deba@57
   699
      }
deba@57
   700
      /// \brief Running node of the iterator
deba@57
   701
      ///
deba@57
   702
      /// Returns the running node (the target in this case) of the
deba@57
   703
      /// iterator
deba@57
   704
      Node runningNode(OutArcIt e) const {
alpar@209
   705
        return target(e);
deba@57
   706
      }
deba@57
   707
deba@57
   708
      /// \brief Base node of the iterator
deba@57
   709
      ///
deba@57
   710
      /// Returns the base node (the target in this case) of the iterator
deba@57
   711
      Node baseNode(InArcIt e) const {
alpar@209
   712
        return target(e);
deba@57
   713
      }
deba@57
   714
      /// \brief Running node of the iterator
deba@57
   715
      ///
deba@57
   716
      /// Returns the running node (the source in this case) of the
deba@57
   717
      /// iterator
deba@57
   718
      Node runningNode(InArcIt e) const {
alpar@209
   719
        return source(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 of the iterator
deba@78
   725
      Node baseNode(IncEdgeIt) const {
alpar@209
   726
        return INVALID;
deba@57
   727
      }
alpar@209
   728
deba@57
   729
      /// \brief Running node of the iterator
deba@57
   730
      ///
deba@57
   731
      /// Returns the running node of the iterator
deba@78
   732
      Node runningNode(IncEdgeIt) const {
alpar@209
   733
        return INVALID;
deba@57
   734
      }
deba@57
   735
deba@125
   736
      template <typename _Graph>
deba@57
   737
      struct Constraints {
alpar@209
   738
        void constraints() {
alpar@209
   739
          checkConcept<IterableGraphComponent<>, _Graph>();
alpar@209
   740
          checkConcept<IDableGraphComponent<>, _Graph>();
alpar@209
   741
          checkConcept<MappableGraphComponent<>, _Graph>();
alpar@209
   742
        }
deba@57
   743
      };
deba@57
   744
deba@57
   745
    };
deba@57
   746
deba@57
   747
  }
deba@57
   748
deba@57
   749
}
deba@57
   750
deba@57
   751
#endif