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