lemon/concepts/graph.h
author Balazs Dezso <deba@inf.elte.hu>
Fri, 25 Jan 2008 15:23:28 +0100
changeset 62 4790635473ef
child 61 d718974f1290
permissions -rw-r--r--
Array range check warning workaround in random.h

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