lemon/concept/graph_components.h
author alpar
Tue, 18 Jul 2006 15:14:56 +0000
changeset 2152 ba87d27667cd
parent 2126 2c8adbee9fa6
child 2181 b2c38f4f72ff
permissions -rw-r--r--
Bugfix
deba@2126
     1
/* -*- C++ -*-
deba@2126
     2
 *
deba@2126
     3
 * This file is a part of LEMON, a generic C++ optimization library
deba@2126
     4
 *
deba@2126
     5
 * Copyright (C) 2003-2006
deba@2126
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@2126
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@2126
     8
 *
deba@2126
     9
 * Permission to use, modify and distribute this software is granted
deba@2126
    10
 * provided that this copyright notice appears in all copies. For
deba@2126
    11
 * precise terms see the accompanying LICENSE file.
deba@2126
    12
 *
deba@2126
    13
 * This software is provided "AS IS" with no warranty of any kind,
deba@2126
    14
 * express or implied, and with no claim as to its suitability for any
deba@2126
    15
 * purpose.
deba@2126
    16
 *
deba@2126
    17
 */
deba@2126
    18
deba@2126
    19
///\ingroup graph_concepts
deba@2126
    20
///\file
deba@2126
    21
///\brief The concept of the graph components.
deba@2126
    22
deba@2126
    23
deba@2126
    24
#ifndef LEMON_CONCEPT_GRAPH_COMPONENTS_H
deba@2126
    25
#define LEMON_CONCEPT_GRAPH_COMPONENTS_H
deba@2126
    26
deba@2126
    27
#include <lemon/bits/invalid.h>
deba@2126
    28
#include <lemon/concept/maps.h>
deba@2126
    29
deba@2126
    30
#include <lemon/bits/alteration_notifier.h>
deba@2126
    31
deba@2126
    32
namespace lemon {
deba@2126
    33
  namespace concept {
deba@2126
    34
deba@2126
    35
    /// \brief Skeleton class for graph Node and Edge types
deba@2126
    36
    ///
deba@2126
    37
    /// This class describes the interface of Node and Edge (and UEdge
deba@2126
    38
    /// in undirected graphs) subtypes of graph types.
deba@2126
    39
    ///
deba@2126
    40
    /// \note This class is a template class so that we can use it to
deba@2126
    41
    /// create graph skeleton classes. The reason for this is than Node
deba@2126
    42
    /// and Edge types should \em not derive from the same base class.
deba@2126
    43
    /// For Node you should instantiate it with character 'n' and for Edge
deba@2126
    44
    /// with 'e'.
deba@2126
    45
deba@2126
    46
#ifndef DOXYGEN
deba@2126
    47
    template <char _selector = '0'>
deba@2126
    48
#endif
deba@2126
    49
    class GraphItem {
deba@2126
    50
    public:
deba@2126
    51
      /// \brief Default constructor.
deba@2126
    52
      ///      
deba@2126
    53
      /// \warning The default constructor is not required to set
deba@2126
    54
      /// the item to some well-defined value. So you should consider it
deba@2126
    55
      /// as uninitialized.
deba@2126
    56
      GraphItem() {}
deba@2126
    57
      /// \brief Copy constructor.
deba@2126
    58
      ///
deba@2126
    59
      /// Copy constructor.
deba@2126
    60
      ///
deba@2126
    61
      GraphItem(const GraphItem &) {}
deba@2126
    62
      /// \brief Invalid constructor \& conversion.
deba@2126
    63
      ///
deba@2126
    64
      /// This constructor initializes the item to be invalid.
deba@2126
    65
      /// \sa Invalid for more details.
deba@2126
    66
      GraphItem(Invalid) {}
deba@2126
    67
      /// \brief Assign operator for nodes.
deba@2126
    68
      ///
deba@2126
    69
      /// The nodes are assignable. 
deba@2126
    70
      ///
deba@2126
    71
      GraphItem& operator=(GraphItem const&) { return *this; }
deba@2126
    72
      /// \brief Equality operator.
deba@2126
    73
      ///
deba@2126
    74
      /// Two iterators are equal if and only if they represents the
deba@2126
    75
      /// same node in the graph or both are invalid.
deba@2126
    76
      bool operator==(GraphItem) const { return false; }
deba@2126
    77
      /// \brief Inequality operator.
deba@2126
    78
      ///
deba@2126
    79
      /// \sa operator==(const Node& n)
deba@2126
    80
      ///
deba@2126
    81
      bool operator!=(GraphItem) const { return false; }
deba@2126
    82
deba@2126
    83
      /// \brief Artificial ordering operator.
deba@2126
    84
      ///
deba@2126
    85
      /// To allow the use of graph descriptors as key type in std::map or
deba@2126
    86
      /// similar associative container we require this.
deba@2126
    87
      ///
deba@2126
    88
      /// \note This operator only have to define some strict ordering of
deba@2126
    89
      /// the items; this order has nothing to do with the iteration
deba@2126
    90
      /// ordering of the items.
deba@2126
    91
      bool operator<(GraphItem) const { return false; }
deba@2126
    92
deba@2126
    93
      template<typename _GraphItem>
deba@2126
    94
      struct Constraints {
deba@2126
    95
	void constraints() {
deba@2126
    96
	  _GraphItem i1;
deba@2126
    97
	  _GraphItem i2 = i1;
deba@2126
    98
	  _GraphItem i3 = INVALID;
deba@2126
    99
	  
deba@2126
   100
	  i1 = i2 = i3;
deba@2126
   101
deba@2126
   102
	  bool b;
deba@2126
   103
	  //	  b = (ia == ib) && (ia != ib) && (ia < ib);
deba@2126
   104
	  b = (ia == ib) && (ia != ib);
deba@2126
   105
	  b = (ia == INVALID) && (ib != INVALID);
deba@2126
   106
          b = (ia < ib);
deba@2126
   107
	}
deba@2126
   108
deba@2126
   109
	const _GraphItem &ia;
deba@2126
   110
	const _GraphItem &ib;
deba@2126
   111
      };
deba@2126
   112
    };
deba@2126
   113
deba@2126
   114
    /// \brief An empty base graph class.
deba@2126
   115
    ///  
deba@2126
   116
    /// This class provides the minimal set of features needed for a graph
deba@2126
   117
    /// structure. All graph concepts have to be conform to this base
deba@2126
   118
    /// graph. It just provides types for nodes and edges and functions to
deba@2126
   119
    /// get the source and the target of the edges.
deba@2126
   120
    class BaseGraphComponent {
deba@2126
   121
    public:
deba@2126
   122
deba@2126
   123
      typedef BaseGraphComponent Graph;
deba@2126
   124
      
deba@2126
   125
      /// \brief Node class of the graph.
deba@2126
   126
      ///
deba@2126
   127
      /// This class represents the Nodes of the graph. 
deba@2126
   128
      ///
deba@2126
   129
      typedef GraphItem<'n'> Node;
deba@2126
   130
deba@2126
   131
      /// \brief Edge class of the graph.
deba@2126
   132
      ///
deba@2126
   133
      /// This class represents the Edges of the graph. 
deba@2126
   134
      ///
deba@2126
   135
      typedef GraphItem<'e'> Edge;
deba@2126
   136
deba@2126
   137
      /// \brief Gives back the target node of an edge.
deba@2126
   138
      ///
deba@2126
   139
      /// Gives back the target node of an edge.
deba@2126
   140
      ///
deba@2126
   141
      Node target(const Edge&) const { return INVALID;}
deba@2126
   142
deba@2126
   143
      /// \brief Gives back the source node of an edge.
deba@2126
   144
      ///
deba@2126
   145
      /// Gives back the source node of an edge.
deba@2126
   146
      ///
deba@2126
   147
      Node source(const Edge&) const { return INVALID;}
deba@2126
   148
deba@2126
   149
      /// \brief Gives back the opposite node on the given edge.
deba@2126
   150
      ///
deba@2126
   151
      /// Gives back the opposite node on the given edge.
deba@2126
   152
      Node oppositeNode(const Node&, const Edge&) const {
deba@2126
   153
        return INVALID;
deba@2126
   154
      }
deba@2126
   155
deba@2126
   156
      template <typename _Graph>
deba@2126
   157
      struct Constraints {
deba@2126
   158
	typedef typename _Graph::Node Node;
deba@2126
   159
	typedef typename _Graph::Edge Edge;
deba@2126
   160
      
deba@2126
   161
	void constraints() {
deba@2126
   162
	  checkConcept<GraphItem<'n'>, Node>();
deba@2126
   163
	  checkConcept<GraphItem<'e'>, Edge>();
deba@2126
   164
	  {
deba@2126
   165
	    Node n;
deba@2126
   166
	    Edge e(INVALID);
deba@2126
   167
	    n = graph.source(e);
deba@2126
   168
	    n = graph.target(e);
deba@2126
   169
            n = graph.oppositeNode(n, e);
deba@2126
   170
	  }      
deba@2126
   171
	}
deba@2126
   172
      
deba@2126
   173
	const _Graph& graph;
deba@2126
   174
      };
deba@2126
   175
    };
deba@2126
   176
deba@2126
   177
    /// \brief An empty base undirected graph class.
deba@2126
   178
    ///  
deba@2126
   179
    /// This class provides the minimal set of features needed for an
deba@2126
   180
    /// undirected graph structure. All undirected graph concepts have
deba@2126
   181
    /// to be conform to this base graph. It just provides types for
deba@2126
   182
    /// nodes, edges and undirected edges and functions to get the
deba@2126
   183
    /// source and the target of the edges and undirected edges,
deba@2126
   184
    /// conversion from edges to undirected edges and function to get
deba@2126
   185
    /// both direction of the undirected edges.
deba@2126
   186
    class BaseUGraphComponent : public BaseGraphComponent {
deba@2126
   187
    public:
deba@2126
   188
      typedef BaseGraphComponent::Node Node;
deba@2126
   189
      typedef BaseGraphComponent::Edge Edge;
deba@2126
   190
      /// \brief Undirected edge class of the graph.
deba@2126
   191
      ///
deba@2126
   192
      /// This class represents the undirected edges of the graph.
deba@2126
   193
      /// The undirected graphs can be used as a directed graph which
deba@2126
   194
      /// for each edge contains the opposite edge too so the graph is
deba@2126
   195
      /// bidirected. The undirected edge represents two opposite
deba@2126
   196
      /// directed edges.
deba@2126
   197
      class UEdge : public GraphItem<'u'> {
deba@2126
   198
      public:
deba@2126
   199
        typedef GraphItem<'u'> Parent;
deba@2126
   200
        /// \brief Default constructor.
deba@2126
   201
        ///      
deba@2126
   202
        /// \warning The default constructor is not required to set
deba@2126
   203
        /// the item to some well-defined value. So you should consider it
deba@2126
   204
        /// as uninitialized.
deba@2126
   205
        UEdge() {}
deba@2126
   206
        /// \brief Copy constructor.
deba@2126
   207
        ///
deba@2126
   208
        /// Copy constructor.
deba@2126
   209
        ///
deba@2126
   210
        UEdge(const UEdge &) : Parent() {}
deba@2126
   211
        /// \brief Invalid constructor \& conversion.
deba@2126
   212
        ///
deba@2126
   213
        /// This constructor initializes the item to be invalid.
deba@2126
   214
        /// \sa Invalid for more details.
deba@2126
   215
        UEdge(Invalid) {}
deba@2126
   216
        /// \brief Converter from edge to undirected edge.
deba@2126
   217
        ///
deba@2126
   218
        /// Besides the core graph item functionality each edge should
deba@2126
   219
        /// be convertible to the represented undirected edge. 
deba@2126
   220
        UEdge(const Edge&) {}
deba@2126
   221
      };
deba@2126
   222
deba@2126
   223
      /// \brief Returns the direction of the edge.
deba@2126
   224
      ///
deba@2126
   225
      /// Returns the direction of the edge. Each edge represents an
deba@2126
   226
      /// undirected edge with a direction. It gives back the
deba@2126
   227
      /// direction.
deba@2126
   228
      bool direction(const Edge&) const { return true; }
deba@2126
   229
deba@2126
   230
      /// \brief Returns the directed edge.
deba@2126
   231
      ///
deba@2126
   232
      /// Returns the directed edge from its direction and the
deba@2126
   233
      /// represented undirected edge.
deba@2126
   234
      Edge direct(const UEdge&, bool) const { return INVALID;} 
deba@2126
   235
deba@2126
   236
      /// \brief Returns the directed edge.
deba@2126
   237
      ///
deba@2126
   238
      /// Returns the directed edge from its source and the
deba@2126
   239
      /// represented undirected edge.
deba@2126
   240
      Edge direct(const UEdge&, const Node&) const { return INVALID;} 
deba@2126
   241
deba@2126
   242
      /// \brief Returns the opposite edge.
deba@2126
   243
      ///
deba@2126
   244
      /// Returns the opposite edge. It is the edge representing the
deba@2126
   245
      /// same undirected edge and has opposite direction.
deba@2126
   246
      Edge oppositeEdge(const Edge&) const { return INVALID;}
deba@2126
   247
deba@2126
   248
      /// \brief Gives back the target node of an undirected edge.
deba@2126
   249
      ///
deba@2126
   250
      /// Gives back the target node of an undirected edge. The name
deba@2126
   251
      /// target is a little confusing because the undirected edge
deba@2126
   252
      /// does not have target but it just means that one of the end 
deba@2126
   253
      /// node.
deba@2126
   254
      Node target(const UEdge&) const { return INVALID;}
deba@2126
   255
deba@2126
   256
      /// \brief Gives back the source node of an undirected edge.
deba@2126
   257
      ///
deba@2126
   258
      /// Gives back the source node of an undirected edge. The name
deba@2126
   259
      /// source is a little confusing because the undirected edge
deba@2126
   260
      /// does not have source but it just means that one of the end 
deba@2126
   261
      /// node.
deba@2126
   262
      Node source(const UEdge&) const { return INVALID;}
deba@2126
   263
      
deba@2126
   264
      template <typename _Graph>
deba@2126
   265
      struct Constraints {
deba@2126
   266
	typedef typename _Graph::Node Node;
deba@2126
   267
	typedef typename _Graph::Edge Edge;
deba@2126
   268
	typedef typename _Graph::UEdge UEdge;
deba@2126
   269
      
deba@2126
   270
	void constraints() {
deba@2126
   271
          checkConcept<BaseGraphComponent, _Graph>();
deba@2126
   272
	  checkConcept<GraphItem<'u'>, UEdge>();
deba@2126
   273
	  {
deba@2126
   274
	    Node n;
deba@2126
   275
	    UEdge ue(INVALID);
deba@2126
   276
            Edge e;
deba@2126
   277
	    n = graph.source(ue);
deba@2126
   278
	    n = graph.target(ue);
deba@2126
   279
            e = graph.direct(ue, true);
deba@2126
   280
            e = graph.direct(ue, n);
deba@2126
   281
            e = graph.oppositeEdge(e);
deba@2126
   282
            ue = e;
deba@2126
   283
            bool d = graph.direction(e);
deba@2126
   284
            ignore_unused_variable_warning(d);
deba@2126
   285
	  }      
deba@2126
   286
	}
deba@2126
   287
      
deba@2126
   288
	const _Graph& graph;
deba@2126
   289
      };
deba@2126
   290
deba@2126
   291
    };
deba@2126
   292
deba@2126
   293
    /// \brief An empty iterable base graph class.
deba@2126
   294
    ///  
deba@2126
   295
    /// This class provides beside the core graph features
deba@2126
   296
    /// core iterable interface for the graph structure.
deba@2126
   297
    /// Most of the base graphs should be conform to this concept.
deba@2126
   298
    template <typename _Base = BaseGraphComponent>
deba@2126
   299
    class BaseIterableGraphComponent : public _Base {
deba@2126
   300
    public:
deba@2126
   301
deba@2126
   302
      typedef _Base Base; 
deba@2126
   303
      typedef typename Base::Node Node;
deba@2126
   304
      typedef typename Base::Edge Edge;
deba@2126
   305
deba@2126
   306
      /// \brief Gives back the first node in the iterating order.
deba@2126
   307
      ///      
deba@2126
   308
      /// Gives back the first node in the iterating order.
deba@2126
   309
      ///     
deba@2126
   310
      void first(Node&) const {}
deba@2126
   311
deba@2126
   312
      /// \brief Gives back the next node in the iterating order.
deba@2126
   313
      ///
deba@2126
   314
      /// Gives back the next node in the iterating order.
deba@2126
   315
      ///     
deba@2126
   316
      void next(Node&) const {}
deba@2126
   317
deba@2126
   318
      /// \brief Gives back the first edge in the iterating order.
deba@2126
   319
      ///
deba@2126
   320
      /// Gives back the first edge in the iterating order.
deba@2126
   321
      ///     
deba@2126
   322
      void first(Edge&) const {}
deba@2126
   323
deba@2126
   324
      /// \brief Gives back the next edge in the iterating order.
deba@2126
   325
      ///
deba@2126
   326
      /// Gives back the next edge in the iterating order.
deba@2126
   327
      ///     
deba@2126
   328
      void next(Edge&) const {}
deba@2126
   329
deba@2126
   330
deba@2126
   331
      /// \brief Gives back the first of the edges point to the given
deba@2126
   332
      /// node.
deba@2126
   333
      ///
deba@2126
   334
      /// Gives back the first of the edges point to the given node.
deba@2126
   335
      ///     
deba@2126
   336
      void firstIn(Edge&, const Node&) const {}
deba@2126
   337
deba@2126
   338
      /// \brief Gives back the next of the edges points to the given
deba@2126
   339
      /// node.
deba@2126
   340
      ///
deba@2126
   341
      /// Gives back the next of the edges points to the given node.
deba@2126
   342
      ///
deba@2126
   343
      void nextIn(Edge&) const {}
deba@2126
   344
deba@2126
   345
      /// \brief Gives back the first of the edges start from the
deba@2126
   346
      /// given node.
deba@2126
   347
      ///      
deba@2126
   348
      /// Gives back the first of the edges start from the given node.
deba@2126
   349
      ///     
deba@2126
   350
      void firstOut(Edge&, const Node&) const {}
deba@2126
   351
deba@2126
   352
      /// \brief Gives back the next of the edges start from the given
deba@2126
   353
      /// node.
deba@2126
   354
      ///
deba@2126
   355
      /// Gives back the next of the edges start from the given node.
deba@2126
   356
      ///     
deba@2126
   357
      void nextOut(Edge&) const {}
deba@2126
   358
deba@2126
   359
deba@2126
   360
      template <typename _Graph>
deba@2126
   361
      struct Constraints {
deba@2126
   362
      
deba@2126
   363
	void constraints() {
deba@2126
   364
	  checkConcept< BaseGraphComponent, _Graph >();
deba@2129
   365
	  typename _Graph::Node node(INVALID);      
deba@2129
   366
	  typename _Graph::Edge edge(INVALID);
deba@2126
   367
	  {
deba@2126
   368
	    graph.first(node);
deba@2126
   369
	    graph.next(node);
deba@2126
   370
	  }
deba@2126
   371
	  {
deba@2126
   372
	    graph.first(edge);
deba@2126
   373
	    graph.next(edge);
deba@2126
   374
	  }
deba@2126
   375
	  {
deba@2126
   376
	    graph.firstIn(edge, node);
deba@2126
   377
	    graph.nextIn(edge);
deba@2126
   378
	  }
deba@2126
   379
	  {
deba@2126
   380
	    graph.firstOut(edge, node);
deba@2126
   381
	    graph.nextOut(edge);
deba@2126
   382
	  }
deba@2126
   383
	}
deba@2126
   384
deba@2126
   385
	const _Graph& graph;
deba@2126
   386
      };
deba@2126
   387
    };
deba@2126
   388
deba@2126
   389
    /// \brief An empty iterable base undirected graph class.
deba@2126
   390
    ///  
deba@2126
   391
    /// This class provides beside the core undirceted graph features
deba@2126
   392
    /// core iterable interface for the undirected graph structure.
deba@2126
   393
    /// Most of the base undirected graphs should be conform to this
deba@2126
   394
    /// concept.
deba@2126
   395
    template <typename _Base = BaseUGraphComponent>
deba@2126
   396
    class BaseIterableUGraphComponent 
deba@2126
   397
      : public BaseIterableGraphComponent<_Base> {
deba@2126
   398
    public:
deba@2126
   399
deba@2126
   400
      typedef _Base Base; 
deba@2126
   401
      typedef typename Base::UEdge UEdge;
deba@2126
   402
      typedef typename Base::Node Node;
deba@2126
   403
deba@2126
   404
      using BaseIterableGraphComponent<_Base>::first;
deba@2126
   405
      using BaseIterableGraphComponent<_Base>::next;
deba@2126
   406
deba@2126
   407
      /// \brief Gives back the first undirected edge in the iterating
deba@2126
   408
      /// order.
deba@2126
   409
      ///
deba@2126
   410
      /// Gives back the first undirected edge in the iterating order.
deba@2126
   411
      ///     
deba@2126
   412
      void first(UEdge&) const {}
deba@2126
   413
deba@2126
   414
      /// \brief Gives back the next undirected edge in the iterating
deba@2126
   415
      /// order.
deba@2126
   416
      ///
deba@2126
   417
      /// Gives back the next undirected edge in the iterating order.
deba@2126
   418
      ///     
deba@2126
   419
      void next(UEdge&) const {}
deba@2126
   420
deba@2126
   421
deba@2126
   422
      /// \brief Gives back the first of the undirected edges from the
deba@2126
   423
      /// given node.
deba@2126
   424
      ///
deba@2126
   425
      /// Gives back the first of the undirected edges from the given
deba@2126
   426
      /// node. The bool parameter gives back that direction which
deba@2126
   427
      /// gives a good direction of the uedge so the source of the
deba@2126
   428
      /// directed edge is the given node.
deba@2126
   429
      void firstInc(UEdge&, bool&, const Node&) const {}
deba@2126
   430
deba@2126
   431
      /// \brief Gives back the next of the undirected edges from the
deba@2126
   432
      /// given node.
deba@2126
   433
      ///
deba@2126
   434
      /// Gives back the next of the undirected edges from the given
deba@2126
   435
      /// node. The bool parameter should be used as the \c firstInc()
deba@2126
   436
      /// use it.
deba@2126
   437
      void nextInc(UEdge&, bool&) const {}
deba@2126
   438
deba@2126
   439
      template <typename _Graph>
deba@2126
   440
      struct Constraints {
deba@2126
   441
      
deba@2126
   442
	void constraints() {
deba@2126
   443
	  checkConcept<Base, _Graph >();
deba@2126
   444
	  checkConcept<BaseIterableGraphComponent<Base>, _Graph>();
deba@2129
   445
	  typename _Graph::Node node(INVALID);
deba@2129
   446
	  typename _Graph::UEdge uedge(INVALID);
deba@2126
   447
          bool dir;
deba@2126
   448
	  {
deba@2126
   449
	    graph.first(uedge);
deba@2126
   450
	    graph.next(uedge);
deba@2126
   451
	  }
deba@2126
   452
	  {
deba@2126
   453
	    graph.firstInc(uedge, dir, node);
deba@2126
   454
	    graph.nextInc(uedge, dir);
deba@2126
   455
	  }
deba@2126
   456
	}
deba@2126
   457
deba@2126
   458
	const _Graph& graph;
deba@2126
   459
      };
deba@2126
   460
    };
deba@2126
   461
deba@2126
   462
    /// \brief An empty idable base graph class.
deba@2126
   463
    ///  
deba@2126
   464
    /// This class provides beside the core graph features
deba@2126
   465
    /// core id functions for the graph structure.
deba@2126
   466
    /// The most of the base graphs should be conform to this concept.
deba@2126
   467
    /// The id's are unique and immutable.
deba@2126
   468
    template <typename _Base = BaseGraphComponent>
deba@2126
   469
    class IDableGraphComponent : public _Base {
deba@2126
   470
    public:
deba@2126
   471
deba@2126
   472
      typedef _Base Base;
deba@2126
   473
      typedef typename Base::Node Node;
deba@2126
   474
      typedef typename Base::Edge Edge;
deba@2126
   475
deba@2126
   476
      /// \brief Gives back an unique integer id for the Node. 
deba@2126
   477
      ///
deba@2126
   478
      /// Gives back an unique integer id for the Node. 
deba@2126
   479
      ///
deba@2126
   480
      int id(const Node&) const { return -1;}
deba@2126
   481
deba@2126
   482
      /// \brief Gives back the node by the unique id.
deba@2126
   483
      ///
deba@2126
   484
      /// Gives back the node by the unique id.
deba@2126
   485
      /// If the graph does not contain node with the given id
deba@2126
   486
      /// then the result of the function is undetermined. 
deba@2126
   487
      Node nodeFromId(int) const { return INVALID;}
deba@2126
   488
deba@2126
   489
      /// \brief Gives back an unique integer id for the Edge. 
deba@2126
   490
      ///
deba@2126
   491
      /// Gives back an unique integer id for the Edge. 
deba@2126
   492
      ///
deba@2126
   493
      int id(const Edge&) const { return -1;}
deba@2126
   494
deba@2126
   495
      /// \brief Gives back the edge by the unique id.
deba@2126
   496
      ///
deba@2126
   497
      /// Gives back the edge by the unique id.
deba@2126
   498
      /// If the graph does not contain edge with the given id
deba@2126
   499
      /// then the result of the function is undetermined. 
deba@2126
   500
      Edge edgeFromId(int) const { return INVALID;}
deba@2126
   501
deba@2126
   502
      /// \brief Gives back an integer greater or equal to the maximum
deba@2126
   503
      /// Node id.
deba@2126
   504
      ///
deba@2126
   505
      /// Gives back an integer greater or equal to the maximum Node
deba@2126
   506
      /// id.
deba@2126
   507
      int maxNodeId() const { return -1;}
deba@2126
   508
deba@2126
   509
      /// \brief Gives back an integer greater or equal to the maximum
deba@2126
   510
      /// Edge id.
deba@2126
   511
      ///
deba@2126
   512
      /// Gives back an integer greater or equal to the maximum Edge
deba@2126
   513
      /// id.
deba@2126
   514
      int maxEdgeId() const { return -1;}
deba@2126
   515
deba@2126
   516
      template <typename _Graph>
deba@2126
   517
      struct Constraints {
deba@2126
   518
deba@2126
   519
	void constraints() {
deba@2126
   520
	  checkConcept< BaseGraphComponent, _Graph >();
deba@2126
   521
	  typename _Graph::Node node;
deba@2126
   522
	  int nid = graph.id(node);
deba@2126
   523
	  nid = graph.id(node);
deba@2126
   524
	  node = graph.nodeFromId(nid);
deba@2126
   525
	  typename _Graph::Edge edge;
deba@2126
   526
	  int eid = graph.id(edge);
deba@2126
   527
	  eid = graph.id(edge);
deba@2126
   528
	  edge = graph.edgeFromId(eid);
deba@2126
   529
deba@2126
   530
	  nid = graph.maxNodeId();
deba@2126
   531
	  ignore_unused_variable_warning(nid);
deba@2126
   532
	  eid = graph.maxEdgeId();
deba@2126
   533
	  ignore_unused_variable_warning(eid);
deba@2126
   534
	}
deba@2126
   535
deba@2126
   536
	const _Graph& graph;
deba@2126
   537
      };
deba@2126
   538
    };
deba@2126
   539
deba@2126
   540
    /// \brief An empty idable base undirected graph class.
deba@2126
   541
    ///  
deba@2126
   542
    /// This class provides beside the core undirected graph features
deba@2126
   543
    /// core id functions for the undirected graph structure.  The
deba@2126
   544
    /// most of the base undirected graphs should be conform to this
deba@2126
   545
    /// concept.  The id's are unique and immutable.
deba@2126
   546
    template <typename _Base = BaseUGraphComponent>
deba@2126
   547
    class IDableUGraphComponent : public IDableGraphComponent<_Base> {
deba@2126
   548
    public:
deba@2126
   549
deba@2126
   550
      typedef _Base Base;
deba@2126
   551
      typedef typename Base::UEdge UEdge;
deba@2126
   552
deba@2126
   553
      using IDableGraphComponent<_Base>::id;
deba@2126
   554
deba@2126
   555
      /// \brief Gives back an unique integer id for the UEdge. 
deba@2126
   556
      ///
deba@2126
   557
      /// Gives back an unique integer id for the UEdge. 
deba@2126
   558
      ///
deba@2126
   559
      int id(const UEdge&) const { return -1;}
deba@2126
   560
deba@2126
   561
      /// \brief Gives back the undirected edge by the unique id.
deba@2126
   562
      ///
deba@2126
   563
      /// Gives back the undirected edge by the unique id.  If the
deba@2126
   564
      /// graph does not contain edge with the given id then the
deba@2126
   565
      /// result of the function is undetermined.
deba@2126
   566
      UEdge uEdgeFromId(int) const { return INVALID;}
deba@2126
   567
deba@2126
   568
      /// \brief Gives back an integer greater or equal to the maximum
deba@2126
   569
      /// UEdge id.
deba@2126
   570
      ///
deba@2126
   571
      /// Gives back an integer greater or equal to the maximum UEdge
deba@2126
   572
      /// id.
deba@2126
   573
      int maxUEdgeId() const { return -1;}
deba@2126
   574
deba@2126
   575
      template <typename _Graph>
deba@2126
   576
      struct Constraints {
deba@2126
   577
deba@2126
   578
	void constraints() {
deba@2126
   579
	  checkConcept<Base, _Graph >();
deba@2126
   580
	  checkConcept<IDableGraphComponent<Base>, _Graph >();
deba@2126
   581
	  typename _Graph::UEdge uedge;
deba@2126
   582
	  int ueid = graph.id(uedge);
deba@2126
   583
	  ueid = graph.id(uedge);
deba@2126
   584
	  uedge = graph.uEdgeFromId(ueid);
deba@2126
   585
	  ueid = graph.maxUEdgeId();
deba@2126
   586
	  ignore_unused_variable_warning(ueid);
deba@2126
   587
	}
deba@2126
   588
deba@2126
   589
	const _Graph& graph;
deba@2126
   590
      };
deba@2126
   591
    };
deba@2126
   592
deba@2126
   593
    /// \brief An empty extendable base graph class.
deba@2126
   594
    ///
deba@2126
   595
    /// This class provides beside the core graph features
deba@2126
   596
    /// core graph extend interface for the graph structure.
deba@2126
   597
    /// The most of the base graphs should be conform to this concept.
deba@2126
   598
    template <typename _Base = BaseGraphComponent>
deba@2126
   599
    class BaseExtendableGraphComponent : public _Base {
deba@2126
   600
    public:
deba@2126
   601
deba@2126
   602
      typedef typename _Base::Node Node;
deba@2126
   603
      typedef typename _Base::Edge Edge;
deba@2126
   604
deba@2126
   605
      /// \brief Adds a new node to the graph.
deba@2126
   606
      ///
deba@2126
   607
      /// Adds a new node to the graph.
deba@2126
   608
      ///
deba@2126
   609
      Node addNode() {
deba@2126
   610
	return INVALID;
deba@2126
   611
      }
deba@2126
   612
    
deba@2126
   613
      /// \brief Adds a new edge connects the given two nodes.
deba@2126
   614
      ///
deba@2126
   615
      /// Adds a new edge connects the the given two nodes.
deba@2126
   616
      Edge addEdge(const Node&, const Node&) {
deba@2126
   617
	return INVALID;
deba@2126
   618
      }
deba@2126
   619
deba@2126
   620
      template <typename _Graph>
deba@2126
   621
      struct Constraints {
deba@2126
   622
	void constraints() {
deba@2126
   623
	  typename _Graph::Node node_a, node_b;
deba@2126
   624
	  node_a = graph.addNode();
deba@2126
   625
	  node_b = graph.addNode();
deba@2126
   626
	  typename _Graph::Edge edge;
deba@2126
   627
	  edge = graph.addEdge(node_a, node_b);
deba@2126
   628
	}
deba@2126
   629
deba@2126
   630
	_Graph& graph;
deba@2126
   631
      };
deba@2126
   632
    };
deba@2126
   633
deba@2126
   634
    /// \brief An empty extendable base undirected graph class.
deba@2126
   635
    ///
deba@2126
   636
    /// This class provides beside the core undirected graph features
deba@2126
   637
    /// core undircted graph extend interface for the graph structure.
deba@2126
   638
    /// The most of the base graphs should be conform to this concept.
deba@2126
   639
    template <typename _Base = BaseUGraphComponent>
deba@2126
   640
    class BaseExtendableUGraphComponent : public _Base {
deba@2126
   641
    public:
deba@2126
   642
deba@2126
   643
      typedef typename _Base::Node Node;
deba@2126
   644
      typedef typename _Base::UEdge UEdge;
deba@2126
   645
deba@2126
   646
      /// \brief Adds a new node to the graph.
deba@2126
   647
      ///
deba@2126
   648
      /// Adds a new node to the graph.
deba@2126
   649
      ///
deba@2126
   650
      Node addNode() {
deba@2126
   651
	return INVALID;
deba@2126
   652
      }
deba@2126
   653
    
deba@2126
   654
      /// \brief Adds a new edge connects the given two nodes.
deba@2126
   655
      ///
deba@2126
   656
      /// Adds a new edge connects the the given two nodes.
deba@2126
   657
      UEdge addEdge(const Node&, const Node&) {
deba@2126
   658
	return INVALID;
deba@2126
   659
      }
deba@2126
   660
deba@2126
   661
      template <typename _Graph>
deba@2126
   662
      struct Constraints {
deba@2126
   663
	void constraints() {
deba@2126
   664
	  typename _Graph::Node node_a, node_b;
deba@2126
   665
	  node_a = graph.addNode();
deba@2126
   666
	  node_b = graph.addNode();
deba@2126
   667
	  typename _Graph::UEdge uedge;
deba@2126
   668
	  uedge = graph.addUEdge(node_a, node_b);
deba@2126
   669
	}
deba@2126
   670
deba@2126
   671
	_Graph& graph;
deba@2126
   672
      };
deba@2126
   673
    };
deba@2126
   674
deba@2126
   675
    /// \brief An empty erasable base graph class.
deba@2126
   676
    ///  
deba@2126
   677
    /// This class provides beside the core graph features
deba@2126
   678
    /// core erase functions for the graph structure.
deba@2126
   679
    /// The most of the base graphs should be conform to this concept.
deba@2126
   680
    template <typename _Base = BaseGraphComponent>
deba@2126
   681
    class BaseErasableGraphComponent : public _Base {
deba@2126
   682
    public:
deba@2126
   683
deba@2126
   684
      typedef _Base Base;
deba@2126
   685
      typedef typename Base::Node Node;
deba@2126
   686
      typedef typename Base::Edge Edge;
deba@2126
   687
deba@2126
   688
      /// \brief Erase a node from the graph.
deba@2126
   689
      ///
deba@2126
   690
      /// Erase a node from the graph. This function should not
deba@2126
   691
      /// erase edges connecting to the Node.
deba@2126
   692
      void erase(const Node&) {}    
deba@2126
   693
deba@2126
   694
      /// \brief Erase an edge from the graph.
deba@2126
   695
      ///
deba@2126
   696
      /// Erase an edge from the graph.
deba@2126
   697
      ///
deba@2126
   698
      void erase(const Edge&) {}
deba@2126
   699
deba@2126
   700
      template <typename _Graph>
deba@2126
   701
      struct Constraints {
deba@2126
   702
	void constraints() {
deba@2126
   703
	  typename _Graph::Node node;
deba@2126
   704
	  graph.erase(node);
deba@2126
   705
	  typename _Graph::Edge edge;
deba@2126
   706
	  graph.erase(edge);
deba@2126
   707
	}
deba@2126
   708
deba@2126
   709
	_Graph& graph;
deba@2126
   710
      };
deba@2126
   711
    };
deba@2126
   712
deba@2126
   713
    /// \brief An empty erasable base undirected graph class.
deba@2126
   714
    ///  
deba@2126
   715
    /// This class provides beside the core undirected graph features
deba@2126
   716
    /// core erase functions for the undirceted graph structure.
deba@2126
   717
    template <typename _Base = BaseUGraphComponent>
deba@2126
   718
    class BaseErasableUGraphComponent : public _Base {
deba@2126
   719
    public:
deba@2126
   720
deba@2126
   721
      typedef _Base Base;
deba@2126
   722
      typedef typename Base::Node Node;
deba@2126
   723
      typedef typename Base::UEdge UEdge;
deba@2126
   724
deba@2126
   725
      /// \brief Erase a node from the graph.
deba@2126
   726
      ///
deba@2126
   727
      /// Erase a node from the graph. This function should not
deba@2126
   728
      /// erase edges connecting to the Node.
deba@2126
   729
      void erase(const Node&) {}    
deba@2126
   730
deba@2126
   731
      /// \brief Erase an edge from the graph.
deba@2126
   732
      ///
deba@2126
   733
      /// Erase an edge from the graph.
deba@2126
   734
      ///
deba@2126
   735
      void erase(const UEdge&) {}
deba@2126
   736
deba@2126
   737
      template <typename _Graph>
deba@2126
   738
      struct Constraints {
deba@2126
   739
	void constraints() {
deba@2126
   740
	  typename _Graph::Node node;
deba@2126
   741
	  graph.erase(node);
deba@2126
   742
	  typename _Graph::Edge edge;
deba@2126
   743
	  graph.erase(edge);
deba@2126
   744
	}
deba@2126
   745
deba@2126
   746
	_Graph& graph;
deba@2126
   747
      };
deba@2126
   748
    };
deba@2126
   749
deba@2126
   750
    /// \brief An empty clearable base graph class.
deba@2126
   751
    ///
deba@2126
   752
    /// This class provides beside the core graph features
deba@2126
   753
    /// core clear functions for the graph structure.
deba@2126
   754
    /// The most of the base graphs should be conform to this concept.
deba@2126
   755
    template <typename _Base = BaseGraphComponent>
deba@2126
   756
    class BaseClearableGraphComponent : public _Base {
deba@2126
   757
    public:
deba@2126
   758
deba@2126
   759
      /// \brief Erase all the nodes and edges from the graph.
deba@2126
   760
      ///
deba@2126
   761
      /// Erase all the nodes and edges from the graph.
deba@2126
   762
      ///
deba@2126
   763
      void clear() {}    
deba@2126
   764
deba@2126
   765
      template <typename _Graph>
deba@2126
   766
      struct Constraints {
deba@2126
   767
	void constraints() {
deba@2126
   768
	  graph.clear();
deba@2126
   769
	}
deba@2126
   770
deba@2126
   771
	_Graph graph;
deba@2126
   772
      };
deba@2126
   773
    };
deba@2126
   774
deba@2126
   775
    /// \brief An empty clearable base undirected graph class.
deba@2126
   776
    ///
deba@2126
   777
    /// This class provides beside the core undirected graph features
deba@2126
   778
    /// core clear functions for the undirected graph structure.
deba@2126
   779
    /// The most of the base graphs should be conform to this concept.
deba@2126
   780
    template <typename _Base = BaseUGraphComponent>
deba@2126
   781
    class BaseClearableUGraphComponent : public _Base {
deba@2126
   782
    public:
deba@2126
   783
deba@2126
   784
      /// \brief Erase all the nodes and undirected edges from the graph.
deba@2126
   785
      ///
deba@2126
   786
      /// Erase all the nodes and undirected edges from the graph.
deba@2126
   787
      ///
deba@2126
   788
      void clear() {}    
deba@2126
   789
deba@2126
   790
      template <typename _Graph>
deba@2126
   791
      struct Constraints {
deba@2126
   792
	void constraints() {
deba@2126
   793
	  graph.clear();
deba@2126
   794
	}
deba@2126
   795
deba@2126
   796
	_Graph graph;
deba@2126
   797
      };
deba@2126
   798
    };
deba@2126
   799
deba@2126
   800
deba@2126
   801
    /// \brief Skeleton class for graph NodeIt and EdgeIt
deba@2126
   802
    ///
deba@2126
   803
    /// Skeleton class for graph NodeIt and EdgeIt.
deba@2126
   804
    ///
deba@2126
   805
    template <typename _Graph, typename _Item>
deba@2126
   806
    class GraphItemIt : public _Item {
deba@2126
   807
    public:
deba@2126
   808
      /// \brief Default constructor.
deba@2126
   809
      ///
deba@2126
   810
      /// @warning The default constructor sets the iterator
deba@2126
   811
      /// to an undefined value.
deba@2126
   812
      GraphItemIt() {}
deba@2126
   813
      /// \brief Copy constructor.
deba@2126
   814
      ///
deba@2126
   815
      /// Copy constructor.
deba@2126
   816
      ///
deba@2126
   817
      GraphItemIt(const GraphItemIt& ) {}
deba@2126
   818
      /// \brief Sets the iterator to the first item.
deba@2126
   819
      ///
deba@2126
   820
      /// Sets the iterator to the first item of \c the graph.
deba@2126
   821
      ///
deba@2126
   822
      explicit GraphItemIt(const _Graph&) {}
deba@2126
   823
      /// \brief Invalid constructor \& conversion.
deba@2126
   824
      ///
deba@2126
   825
      /// This constructor initializes the item to be invalid.
deba@2126
   826
      /// \sa Invalid for more details.
deba@2126
   827
      GraphItemIt(Invalid) {}
deba@2126
   828
      /// \brief Assign operator for items.
deba@2126
   829
      ///
deba@2126
   830
      /// The items are assignable. 
deba@2126
   831
      ///
deba@2126
   832
      GraphItemIt& operator=(const GraphItemIt&) { return *this; }      
deba@2126
   833
      /// \brief Next item.
deba@2126
   834
      /// 
deba@2126
   835
      /// Assign the iterator to the next item.
deba@2126
   836
      ///
deba@2126
   837
      GraphItemIt& operator++() { return *this; }
deba@2126
   838
      /// \brief Equality operator
deba@2126
   839
      /// 
deba@2126
   840
      /// Two iterators are equal if and only if they point to the
deba@2126
   841
      /// same object or both are invalid.
deba@2126
   842
      bool operator==(const GraphItemIt&) const { return true;}
deba@2126
   843
      /// \brief Inequality operator
deba@2126
   844
      ///	
deba@2126
   845
      /// \sa operator==(Node n)
deba@2126
   846
      ///
deba@2126
   847
      bool operator!=(const GraphItemIt&) const { return true;}
deba@2126
   848
      
deba@2126
   849
      template<typename _GraphItemIt>
deba@2126
   850
      struct Constraints {
deba@2126
   851
	void constraints() {
deba@2126
   852
	  _GraphItemIt it1(g);	
deba@2126
   853
	  _GraphItemIt it2;
deba@2126
   854
deba@2126
   855
	  it2 = ++it1;
deba@2126
   856
	  ++it2 = it1;
deba@2126
   857
	  ++(++it1);
deba@2126
   858
deba@2126
   859
	  _Item bi = it1;
deba@2126
   860
	  bi = it2;
deba@2126
   861
	}
deba@2126
   862
	_Graph& g;
deba@2126
   863
      };
deba@2126
   864
    };
deba@2126
   865
deba@2126
   866
    /// \brief Skeleton class for graph InEdgeIt and OutEdgeIt
deba@2126
   867
    ///
deba@2126
   868
    /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
deba@2126
   869
    /// base class, the _selector is a additional template parameter. For 
deba@2126
   870
    /// InEdgeIt you should instantiate it with character 'i' and for 
deba@2126
   871
    /// OutEdgeIt with 'o'.
deba@2126
   872
    template <typename _Graph,
deba@2126
   873
	      typename _Item = typename _Graph::Edge,
deba@2126
   874
              typename _Base = typename _Graph::Node, 
deba@2126
   875
	      char _selector = '0'>
deba@2126
   876
    class GraphIncIt : public _Item {
deba@2126
   877
    public:
deba@2126
   878
      /// \brief Default constructor.
deba@2126
   879
      ///
deba@2126
   880
      /// @warning The default constructor sets the iterator
deba@2126
   881
      /// to an undefined value.
deba@2126
   882
      GraphIncIt() {}
deba@2126
   883
      /// \brief Copy constructor.
deba@2126
   884
      ///
deba@2126
   885
      /// Copy constructor.
deba@2126
   886
      ///
deba@2126
   887
      GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
deba@2126
   888
      /// \brief Sets the iterator to the first edge incoming into or outgoing 
deba@2126
   889
      /// from the node.
deba@2126
   890
      ///
deba@2126
   891
      /// Sets the iterator to the first edge incoming into or outgoing 
deba@2126
   892
      /// from the node.
deba@2126
   893
      ///
deba@2126
   894
      explicit GraphIncIt(const _Graph&, const _Base&) {}
deba@2126
   895
      /// \brief Invalid constructor \& conversion.
deba@2126
   896
      ///
deba@2126
   897
      /// This constructor initializes the item to be invalid.
deba@2126
   898
      /// \sa Invalid for more details.
deba@2126
   899
      GraphIncIt(Invalid) {}
deba@2126
   900
      /// \brief Assign operator for iterators.
deba@2126
   901
      ///
deba@2126
   902
      /// The iterators are assignable. 
deba@2126
   903
      ///
deba@2126
   904
      GraphIncIt& operator=(GraphIncIt const&) { return *this; }      
deba@2126
   905
      /// \brief Next item.
deba@2126
   906
      ///
deba@2126
   907
      /// Assign the iterator to the next item.
deba@2126
   908
      ///
deba@2126
   909
      GraphIncIt& operator++() { return *this; }
deba@2126
   910
deba@2126
   911
      /// \brief Equality operator
deba@2126
   912
      ///
deba@2126
   913
      /// Two iterators are equal if and only if they point to the
deba@2126
   914
      /// same object or both are invalid.
deba@2126
   915
      bool operator==(const GraphIncIt&) const { return true;}
deba@2126
   916
deba@2126
   917
      /// \brief Inequality operator
deba@2126
   918
      ///
deba@2126
   919
      /// \sa operator==(Node n)
deba@2126
   920
      ///
deba@2126
   921
      bool operator!=(const GraphIncIt&) const { return true;}
deba@2126
   922
deba@2126
   923
      template <typename _GraphIncIt>
deba@2126
   924
      struct Constraints {
deba@2126
   925
	void constraints() {
deba@2126
   926
	  checkConcept<GraphItem<_selector>, _GraphIncIt>();
deba@2126
   927
	  _GraphIncIt it1(graph, node);
deba@2126
   928
	  _GraphIncIt it2;
deba@2126
   929
deba@2126
   930
	  it2 = ++it1;
deba@2126
   931
	  ++it2 = it1;
deba@2126
   932
	  ++(++it1);
deba@2126
   933
	  _Item e = it1;
deba@2126
   934
	  e = it2;
deba@2126
   935
deba@2126
   936
	}
deba@2126
   937
deba@2126
   938
	_Item edge;
deba@2126
   939
	_Base node;
deba@2126
   940
	_Graph graph;
deba@2126
   941
	_GraphIncIt it;
deba@2126
   942
      };
deba@2126
   943
    };
deba@2126
   944
deba@2126
   945
deba@2126
   946
    /// \brief An empty iterable graph class.
deba@2126
   947
    ///
deba@2126
   948
    /// This class provides beside the core graph features
deba@2126
   949
    /// iterator based iterable interface for the graph structure.
deba@2126
   950
    /// This concept is part of the GraphConcept.
deba@2126
   951
    template <typename _Base = BaseGraphComponent>
deba@2126
   952
    class IterableGraphComponent : public _Base {
deba@2126
   953
deba@2126
   954
    public:
deba@2126
   955
    
deba@2126
   956
      typedef _Base Base;
deba@2126
   957
      typedef typename Base::Node Node;
deba@2126
   958
      typedef typename Base::Edge Edge;
deba@2126
   959
deba@2126
   960
      typedef IterableGraphComponent Graph;
deba@2126
   961
deba@2126
   962
deba@2126
   963
      /// \brief This iterator goes through each node.
deba@2126
   964
      ///
deba@2126
   965
      /// This iterator goes through each node.
deba@2126
   966
      ///
deba@2126
   967
      typedef GraphItemIt<Graph, Node> NodeIt;
deba@2126
   968
deba@2126
   969
      /// \brief This iterator goes through each node.
deba@2126
   970
      ///
deba@2126
   971
      /// This iterator goes through each node.
deba@2126
   972
      ///
deba@2126
   973
      typedef GraphItemIt<Graph, Edge> EdgeIt;
deba@2126
   974
deba@2126
   975
      /// \brief This iterator goes trough the incoming edges of a node.
deba@2126
   976
      ///
deba@2126
   977
      /// This iterator goes trough the \e inccoming edges of a certain node
deba@2126
   978
      /// of a graph.
deba@2126
   979
      typedef GraphIncIt<Graph, Edge, Node, 'i'> InEdgeIt;
deba@2126
   980
deba@2126
   981
      /// \brief This iterator goes trough the outgoing edges of a node.
deba@2126
   982
      ///
deba@2126
   983
      /// This iterator goes trough the \e outgoing edges of a certain node
deba@2126
   984
      /// of a graph.
deba@2126
   985
      typedef GraphIncIt<Graph, Edge, Node, 'o'> OutEdgeIt;
deba@2126
   986
deba@2126
   987
      /// \brief The base node of the iterator.
deba@2126
   988
      ///
deba@2126
   989
      /// Gives back the base node of the iterator.
deba@2126
   990
      /// It is always the target of the pointed edge.
deba@2126
   991
      Node baseNode(const InEdgeIt&) const { return INVALID; }
deba@2126
   992
deba@2126
   993
      /// \brief The running node of the iterator.
deba@2126
   994
      ///
deba@2126
   995
      /// Gives back the running node of the iterator.
deba@2126
   996
      /// It is always the source of the pointed edge.
deba@2126
   997
      Node runningNode(const InEdgeIt&) const { return INVALID; }
deba@2126
   998
deba@2126
   999
      /// \brief The base node of the iterator.
deba@2126
  1000
      ///
deba@2126
  1001
      /// Gives back the base node of the iterator.
deba@2126
  1002
      /// It is always the source of the pointed edge.
deba@2126
  1003
      Node baseNode(const OutEdgeIt&) const { return INVALID; }
deba@2126
  1004
deba@2126
  1005
      /// \brief The running node of the iterator.
deba@2126
  1006
      ///
deba@2126
  1007
      /// Gives back the running node of the iterator.
deba@2126
  1008
      /// It is always the target of the pointed edge.
deba@2126
  1009
      Node runningNode(const OutEdgeIt&) const { return INVALID; }
deba@2126
  1010
deba@2126
  1011
      /// \brief The opposite node on the given edge.
deba@2126
  1012
      ///
deba@2126
  1013
      /// Gives back the opposite on the given edge.
deba@2126
  1014
      /// \todo It should not be here.
deba@2126
  1015
      Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
deba@2126
  1016
deba@2126
  1017
    
deba@2126
  1018
      template <typename _Graph> 
deba@2126
  1019
      struct Constraints {
deba@2126
  1020
	void constraints() {
deba@2126
  1021
	  checkConcept<Base, _Graph>();
deba@2126
  1022
	  
deba@2126
  1023
	  checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
deba@2126
  1024
	    typename _Graph::EdgeIt >();
deba@2126
  1025
	  checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
deba@2126
  1026
	    typename _Graph::NodeIt >();
deba@2126
  1027
	  checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
deba@2126
  1028
            typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
deba@2126
  1029
	  checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
deba@2126
  1030
            typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
deba@2126
  1031
deba@2126
  1032
          typename _Graph::Node n;
deba@2126
  1033
          typename _Graph::InEdgeIt ieit(INVALID);
deba@2126
  1034
          typename _Graph::OutEdgeIt oeit(INVALID);
deba@2126
  1035
          n = graph.baseNode(ieit);
deba@2126
  1036
          n = graph.runningNode(ieit);
deba@2126
  1037
          n = graph.baseNode(oeit);
deba@2126
  1038
          n = graph.runningNode(oeit);
deba@2126
  1039
          ignore_unused_variable_warning(n);
deba@2126
  1040
        }
deba@2126
  1041
	
deba@2126
  1042
	const _Graph& graph;
deba@2126
  1043
	
deba@2126
  1044
      };
deba@2126
  1045
    };
deba@2126
  1046
deba@2126
  1047
    /// \brief An empty iterable undirected graph class.
deba@2126
  1048
    ///
deba@2126
  1049
    /// This class provides beside the core graph features iterator
deba@2126
  1050
    /// based iterable interface for the undirected graph structure.
deba@2126
  1051
    /// This concept is part of the GraphConcept.
deba@2126
  1052
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1053
    class IterableUGraphComponent : public IterableGraphComponent<_Base> {
deba@2126
  1054
    public:
deba@2126
  1055
deba@2126
  1056
      typedef _Base Base;
deba@2126
  1057
      typedef typename Base::Node Node;
deba@2126
  1058
      typedef typename Base::Edge Edge;
deba@2126
  1059
      typedef typename Base::UEdge UEdge;
deba@2126
  1060
deba@2126
  1061
    
deba@2126
  1062
      typedef IterableUGraphComponent Graph;
deba@2126
  1063
      using IterableGraphComponent<_Base>::baseNode;
deba@2126
  1064
      using IterableGraphComponent<_Base>::runningNode;
deba@2126
  1065
deba@2126
  1066
deba@2126
  1067
      /// \brief This iterator goes through each node.
deba@2126
  1068
      ///
deba@2126
  1069
      /// This iterator goes through each node.
deba@2126
  1070
      typedef GraphItemIt<Graph, UEdge> UEdgeIt;
deba@2126
  1071
      /// \brief This iterator goes trough the incident edges of a
deba@2126
  1072
      /// node.
deba@2126
  1073
      ///
deba@2126
  1074
      /// This iterator goes trough the incident edges of a certain
deba@2126
  1075
      /// node of a graph.
deba@2126
  1076
      typedef GraphIncIt<Graph, UEdge, Node, 'u'> IncEdgeIt;
deba@2126
  1077
      /// \brief The base node of the iterator.
deba@2126
  1078
      ///
deba@2126
  1079
      /// Gives back the base node of the iterator.
deba@2126
  1080
      Node baseNode(const IncEdgeIt&) const { return INVALID; }
deba@2126
  1081
deba@2126
  1082
      /// \brief The running node of the iterator.
deba@2126
  1083
      ///
deba@2126
  1084
      /// Gives back the running node of the iterator.
deba@2126
  1085
      Node runningNode(const IncEdgeIt&) const { return INVALID; }
deba@2126
  1086
deba@2126
  1087
      template <typename _Graph> 
deba@2126
  1088
      struct Constraints {
deba@2126
  1089
	void constraints() {
deba@2126
  1090
	  checkConcept<Base, _Graph>();
deba@2126
  1091
	  checkConcept<IterableGraphComponent<Base>, _Graph>();
deba@2126
  1092
	  
deba@2126
  1093
	  checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
deba@2126
  1094
	    typename _Graph::UEdgeIt >();
deba@2126
  1095
	  checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge, 
deba@2126
  1096
            typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
deba@2126
  1097
deba@2126
  1098
          typename _Graph::Node n;
deba@2126
  1099
          typename _Graph::IncEdgeIt ueit(INVALID);
deba@2126
  1100
          n = graph.baseNode(ueit);
deba@2126
  1101
          n = graph.runningNode(ueit);
deba@2126
  1102
	}
deba@2126
  1103
	
deba@2126
  1104
	const _Graph& graph;
deba@2126
  1105
	
deba@2126
  1106
      };
deba@2126
  1107
    };
deba@2126
  1108
deba@2126
  1109
    /// \brief An empty alteration notifier graph class.
deba@2126
  1110
    ///  
deba@2126
  1111
    /// This class provides beside the core graph features alteration
deba@2126
  1112
    /// notifier interface for the graph structure.  This implements
deba@2126
  1113
    /// an observer-notifier pattern for each graph item. More
deba@2126
  1114
    /// obsevers can be registered into the notifier and whenever an
deba@2126
  1115
    /// alteration occured in the graph all the observers will
deba@2126
  1116
    /// notified about it.
deba@2126
  1117
    template <typename _Base = BaseGraphComponent>
deba@2126
  1118
    class AlterableGraphComponent : public _Base {
deba@2126
  1119
    public:
deba@2126
  1120
deba@2126
  1121
      typedef _Base Base;
deba@2126
  1122
      typedef typename Base::Node Node;
deba@2126
  1123
      typedef typename Base::Edge Edge;
deba@2126
  1124
deba@2126
  1125
deba@2126
  1126
      /// The node observer registry.
deba@2126
  1127
      typedef AlterationNotifier<AlterableGraphComponent, Node> 
deba@2126
  1128
      NodeNotifier;
deba@2126
  1129
      /// The edge observer registry.
deba@2126
  1130
      typedef AlterationNotifier<AlterableGraphComponent, Edge> 
deba@2126
  1131
      EdgeNotifier;
deba@2126
  1132
      
deba@2126
  1133
      /// \brief Gives back the node alteration notifier.
deba@2126
  1134
      ///
deba@2126
  1135
      /// Gives back the node alteration notifier.
deba@2126
  1136
      NodeNotifier& getNotifier(Node) const {
deba@2126
  1137
	return NodeNotifier();
deba@2126
  1138
      }
deba@2126
  1139
      
deba@2126
  1140
      /// \brief Gives back the edge alteration notifier.
deba@2126
  1141
      ///
deba@2126
  1142
      /// Gives back the edge alteration notifier.
deba@2126
  1143
      EdgeNotifier& getNotifier(Edge) const {
deba@2126
  1144
	return EdgeNotifier();
deba@2126
  1145
      }
deba@2126
  1146
deba@2126
  1147
      template <typename _Graph> 
deba@2126
  1148
      struct Constraints {
deba@2126
  1149
	void constraints() {
deba@2126
  1150
	  checkConcept<Base, _Graph>();
deba@2126
  1151
          typename _Graph::NodeNotifier& nn 
deba@2126
  1152
            = graph.getNotifier(typename _Graph::Node());
deba@2126
  1153
deba@2126
  1154
          typename _Graph::EdgeNotifier& en 
deba@2126
  1155
            = graph.getNotifier(typename _Graph::Edge());
deba@2126
  1156
          
deba@2126
  1157
          ignore_unused_variable_warning(nn);
deba@2126
  1158
          ignore_unused_variable_warning(en);
deba@2126
  1159
	}
deba@2126
  1160
	
deba@2126
  1161
	const _Graph& graph;
deba@2126
  1162
	
deba@2126
  1163
      };
deba@2126
  1164
      
deba@2126
  1165
    };
deba@2126
  1166
deba@2126
  1167
    /// \brief An empty alteration notifier undirected graph class.
deba@2126
  1168
    ///  
deba@2126
  1169
    /// This class provides beside the core graph features alteration
deba@2126
  1170
    /// notifier interface for the graph structure.  This implements
deba@2126
  1171
    /// an observer-notifier pattern for each graph item. More
deba@2126
  1172
    /// obsevers can be registered into the notifier and whenever an
deba@2126
  1173
    /// alteration occured in the graph all the observers will
deba@2126
  1174
    /// notified about it.
deba@2126
  1175
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1176
    class AlterableUGraphComponent : public AlterableGraphComponent<_Base> {
deba@2126
  1177
    public:
deba@2126
  1178
deba@2126
  1179
      typedef _Base Base;
deba@2126
  1180
      typedef typename Base::UEdge UEdge;
deba@2126
  1181
deba@2126
  1182
deba@2126
  1183
      /// The edge observer registry.
deba@2126
  1184
      typedef AlterationNotifier<AlterableUGraphComponent, UEdge> 
deba@2126
  1185
      UEdgeNotifier;
deba@2126
  1186
      
deba@2126
  1187
      /// \brief Gives back the edge alteration notifier.
deba@2126
  1188
      ///
deba@2126
  1189
      /// Gives back the edge alteration notifier.
deba@2126
  1190
      UEdgeNotifier& getNotifier(UEdge) const {
deba@2126
  1191
	return UEdgeNotifier();
deba@2126
  1192
      }
deba@2126
  1193
deba@2126
  1194
      template <typename _Graph> 
deba@2126
  1195
      struct Constraints {
deba@2126
  1196
	void constraints() {
deba@2126
  1197
	  checkConcept<Base, _Graph>();
deba@2126
  1198
          checkConcept<AlterableGraphComponent, _Graph>();
deba@2126
  1199
          typename _Graph::UEdgeNotifier& uen 
deba@2126
  1200
            = graph.getNotifier(typename _Graph::UEdge());
deba@2126
  1201
          ignore_unused_variable_warning(uen);
deba@2126
  1202
	}
deba@2126
  1203
	
deba@2126
  1204
	const _Graph& graph;
deba@2126
  1205
	
deba@2126
  1206
      };
deba@2126
  1207
      
deba@2126
  1208
    };
deba@2126
  1209
deba@2126
  1210
deba@2126
  1211
    /// \brief Class describing the concept of graph maps
deba@2126
  1212
    /// 
deba@2126
  1213
    /// This class describes the common interface of the graph maps
deba@2126
  1214
    /// (NodeMap, EdgeMap), that is \ref maps-page "maps" which can be used to
deba@2126
  1215
    /// associate data to graph descriptors (nodes or edges).
deba@2126
  1216
    template <typename _Graph, typename _Item, typename _Value>
deba@2126
  1217
    class GraphMap : public ReadWriteMap<_Item, _Value> {
deba@2126
  1218
    public:
deba@2126
  1219
deba@2126
  1220
      typedef ReadWriteMap<_Item, _Value> Parent;
deba@2126
  1221
deba@2126
  1222
      /// The graph type of the map.
deba@2126
  1223
      typedef _Graph Graph;
deba@2126
  1224
      /// The key type of the map.
deba@2126
  1225
      typedef _Item Key;
deba@2126
  1226
      /// The value type of the map.
deba@2126
  1227
      typedef _Value Value;
deba@2126
  1228
deba@2126
  1229
      /// \brief Construct a new map.
deba@2126
  1230
      ///
deba@2126
  1231
      /// Construct a new map for the graph.
deba@2126
  1232
      explicit GraphMap(const Graph&) {}
deba@2126
  1233
      /// \brief Construct a new map with default value.
deba@2126
  1234
      ///
deba@2126
  1235
      /// Construct a new map for the graph and initalise the values.
deba@2126
  1236
      GraphMap(const Graph&, const Value&) {}
deba@2126
  1237
      /// \brief Copy constructor.
deba@2126
  1238
      ///
deba@2126
  1239
      /// Copy Constructor.
deba@2126
  1240
      GraphMap(const GraphMap&) : Parent() {}
deba@2126
  1241
      
deba@2126
  1242
      /// \brief Assign operator.
deba@2126
  1243
      ///
deba@2126
  1244
      /// Assign operator. It does not mofify the underlying graph,
deba@2126
  1245
      /// it just iterates on the current item set and set the  map
deba@2126
  1246
      /// with the value returned by the assigned map. 
deba@2126
  1247
      template <typename CMap>
deba@2126
  1248
      GraphMap& operator=(const CMap&) { 
deba@2126
  1249
        checkConcept<ReadMap<Key, Value>, CMap>();
deba@2126
  1250
        return *this;
deba@2126
  1251
      }
deba@2126
  1252
deba@2126
  1253
      template<typename _Map>
deba@2126
  1254
      struct Constraints {
deba@2126
  1255
	void constraints() {
deba@2126
  1256
	  checkConcept<ReadWriteMap<Key, Value>, _Map >();
deba@2126
  1257
	  // Construction with a graph parameter
deba@2126
  1258
	  _Map a(g);
deba@2126
  1259
	  // Constructor with a graph and a default value parameter
deba@2126
  1260
	  _Map a2(g,t);
deba@2126
  1261
	  // Copy constructor.
deba@2126
  1262
	  _Map b(c);
deba@2126
  1263
          
deba@2126
  1264
          ReadMap<Key, Value> cmap;
deba@2126
  1265
          b = cmap;
deba@2126
  1266
deba@2126
  1267
	  ignore_unused_variable_warning(a2);
deba@2126
  1268
	  ignore_unused_variable_warning(b);
deba@2126
  1269
	}
deba@2126
  1270
deba@2126
  1271
	const _Map &c;
deba@2126
  1272
	const Graph &g;
deba@2126
  1273
	const typename GraphMap::Value &t;
deba@2126
  1274
      };
deba@2126
  1275
deba@2126
  1276
    };
deba@2126
  1277
deba@2126
  1278
    /// \brief An empty mappable graph class.
deba@2126
  1279
    ///
deba@2126
  1280
    /// This class provides beside the core graph features
deba@2126
  1281
    /// map interface for the graph structure.
deba@2126
  1282
    /// This concept is part of the Graph concept.
deba@2126
  1283
    template <typename _Base = BaseGraphComponent>
deba@2126
  1284
    class MappableGraphComponent : public _Base  {
deba@2126
  1285
    public:
deba@2126
  1286
deba@2126
  1287
      typedef _Base Base;
deba@2126
  1288
      typedef typename Base::Node Node;
deba@2126
  1289
      typedef typename Base::Edge Edge;
deba@2126
  1290
deba@2126
  1291
      typedef MappableGraphComponent Graph;
deba@2126
  1292
deba@2126
  1293
      /// \brief ReadWrite map of the nodes.
deba@2126
  1294
      ///
deba@2126
  1295
      /// ReadWrite map of the nodes.
deba@2126
  1296
      ///
deba@2126
  1297
      template <typename Value>
deba@2126
  1298
      class NodeMap : public GraphMap<Graph, Node, Value> {
deba@2126
  1299
      private:
deba@2126
  1300
	NodeMap();
deba@2126
  1301
      public:
deba@2126
  1302
        typedef GraphMap<Graph, Node, Value> Parent;
deba@2126
  1303
deba@2126
  1304
	/// \brief Construct a new map.
deba@2126
  1305
	///
deba@2126
  1306
	/// Construct a new map for the graph.
deba@2126
  1307
	/// \todo call the right parent class constructor
deba@2126
  1308
	explicit NodeMap(const Graph& graph) : Parent(graph) {}
deba@2126
  1309
deba@2126
  1310
	/// \brief Construct a new map with default value.
deba@2126
  1311
	///
deba@2126
  1312
	/// Construct a new map for the graph and initalise the values.
deba@2126
  1313
	NodeMap(const Graph& graph, const Value& value)
deba@2126
  1314
          : Parent(graph, value) {}
deba@2126
  1315
deba@2126
  1316
	/// \brief Copy constructor.
deba@2126
  1317
	///
deba@2126
  1318
	/// Copy Constructor.
deba@2126
  1319
	NodeMap(const NodeMap& nm) : Parent(nm) {}
deba@2126
  1320
deba@2126
  1321
	/// \brief Assign operator.
deba@2126
  1322
	///
deba@2126
  1323
	/// Assign operator.
deba@2126
  1324
        template <typename CMap>
deba@2126
  1325
        NodeMap& operator=(const CMap&) { 
deba@2126
  1326
          checkConcept<ReadMap<Node, Value>, CMap>();
deba@2126
  1327
          return *this;
deba@2126
  1328
        }
deba@2126
  1329
deba@2126
  1330
      };
deba@2126
  1331
deba@2126
  1332
      /// \brief ReadWrite map of the edges.
deba@2126
  1333
      ///
deba@2126
  1334
      /// ReadWrite map of the edges.
deba@2126
  1335
      ///
deba@2126
  1336
      template <typename Value>
deba@2126
  1337
      class EdgeMap : public GraphMap<Graph, Edge, Value> {
deba@2126
  1338
      private:
deba@2126
  1339
	EdgeMap();
deba@2126
  1340
      public:
deba@2126
  1341
        typedef GraphMap<Graph, Edge, Value> Parent;
deba@2126
  1342
deba@2126
  1343
	/// \brief Construct a new map.
deba@2126
  1344
	///
deba@2126
  1345
	/// Construct a new map for the graph.
deba@2126
  1346
	/// \todo call the right parent class constructor
deba@2126
  1347
	explicit EdgeMap(const Graph& graph) : Parent(graph) {}
deba@2126
  1348
deba@2126
  1349
	/// \brief Construct a new map with default value.
deba@2126
  1350
	///
deba@2126
  1351
	/// Construct a new map for the graph and initalise the values.
deba@2126
  1352
	EdgeMap(const Graph& graph, const Value& value)
deba@2126
  1353
          : Parent(graph, value) {}
deba@2126
  1354
deba@2126
  1355
	/// \brief Copy constructor.
deba@2126
  1356
	///
deba@2126
  1357
	/// Copy Constructor.
deba@2126
  1358
	EdgeMap(const EdgeMap& nm) : Parent(nm) {}
deba@2126
  1359
deba@2126
  1360
	/// \brief Assign operator.
deba@2126
  1361
	///
deba@2126
  1362
	/// Assign operator.
deba@2126
  1363
        template <typename CMap>
deba@2126
  1364
        EdgeMap& operator=(const CMap&) { 
deba@2126
  1365
          checkConcept<ReadMap<Edge, Value>, CMap>();
deba@2126
  1366
          return *this;
deba@2126
  1367
        }
deba@2126
  1368
deba@2126
  1369
      };
deba@2126
  1370
deba@2126
  1371
deba@2126
  1372
      template <typename _Graph>
deba@2126
  1373
      struct Constraints {
deba@2126
  1374
deba@2126
  1375
	struct Dummy {
deba@2126
  1376
	  int value;
deba@2126
  1377
	  Dummy() : value(0) {}
deba@2126
  1378
	  Dummy(int _v) : value(_v) {}
deba@2126
  1379
	};
deba@2126
  1380
deba@2126
  1381
	void constraints() {
deba@2126
  1382
	  checkConcept<Base, _Graph>();
deba@2126
  1383
	  { // int map test
deba@2126
  1384
	    typedef typename _Graph::template NodeMap<int> IntNodeMap;
deba@2126
  1385
	    checkConcept<GraphMap<_Graph, typename _Graph::Node, int>, 
deba@2126
  1386
	      IntNodeMap >();
deba@2126
  1387
	  } { // bool map test
deba@2126
  1388
	    typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
deba@2126
  1389
	    checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>,
deba@2126
  1390
	      BoolNodeMap >();
deba@2126
  1391
	  } { // Dummy map test
deba@2126
  1392
	    typedef typename _Graph::template NodeMap<Dummy> DummyNodeMap;
deba@2126
  1393
	    checkConcept<GraphMap<_Graph, typename _Graph::Node, Dummy>,
deba@2126
  1394
	      DummyNodeMap >();
deba@2126
  1395
	  } 
deba@2126
  1396
deba@2126
  1397
	  { // int map test
deba@2126
  1398
	    typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
deba@2126
  1399
	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
deba@2126
  1400
	      IntEdgeMap >();
deba@2126
  1401
	  } { // bool map test
deba@2126
  1402
	    typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
deba@2126
  1403
	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
deba@2126
  1404
	      BoolEdgeMap >();
deba@2126
  1405
	  } { // Dummy map test
deba@2126
  1406
	    typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
deba@2126
  1407
	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>, 
deba@2126
  1408
	      DummyEdgeMap >();
deba@2126
  1409
	  } 
deba@2126
  1410
	}
deba@2126
  1411
deba@2126
  1412
	_Graph& graph;
deba@2126
  1413
      };
deba@2126
  1414
    };
deba@2126
  1415
deba@2126
  1416
    /// \brief An empty mappable base graph class.
deba@2126
  1417
    ///
deba@2126
  1418
    /// This class provides beside the core graph features
deba@2126
  1419
    /// map interface for the graph structure.
deba@2126
  1420
    /// This concept is part of the UGraph concept.
deba@2126
  1421
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1422
    class MappableUGraphComponent : public MappableGraphComponent<_Base>  {
deba@2126
  1423
    public:
deba@2126
  1424
deba@2126
  1425
      typedef _Base Base;
deba@2126
  1426
      typedef typename Base::UEdge UEdge;
deba@2126
  1427
deba@2126
  1428
      typedef MappableUGraphComponent Graph;
deba@2126
  1429
deba@2126
  1430
      /// \brief ReadWrite map of the uedges.
deba@2126
  1431
      ///
deba@2126
  1432
      /// ReadWrite map of the uedges.
deba@2126
  1433
      ///
deba@2126
  1434
      template <typename Value>
deba@2126
  1435
      class UEdgeMap : public GraphMap<Graph, UEdge, Value> {  
deba@2126
  1436
      public:
deba@2126
  1437
        typedef GraphMap<Graph, UEdge, Value> Parent;
deba@2126
  1438
deba@2126
  1439
	/// \brief Construct a new map.
deba@2126
  1440
	///
deba@2126
  1441
	/// Construct a new map for the graph.
deba@2126
  1442
	/// \todo call the right parent class constructor
deba@2126
  1443
	explicit UEdgeMap(const Graph& graph) : Parent(graph) {}
deba@2126
  1444
deba@2126
  1445
	/// \brief Construct a new map with default value.
deba@2126
  1446
	///
deba@2126
  1447
	/// Construct a new map for the graph and initalise the values.
deba@2126
  1448
	UEdgeMap(const Graph& graph, const Value& value)
deba@2126
  1449
          : Parent(graph, value) {}
deba@2126
  1450
deba@2126
  1451
	/// \brief Copy constructor.
deba@2126
  1452
	///
deba@2126
  1453
	/// Copy Constructor.
deba@2126
  1454
	UEdgeMap(const UEdgeMap& nm) : Parent(nm) {}
deba@2126
  1455
deba@2126
  1456
	/// \brief Assign operator.
deba@2126
  1457
	///
deba@2126
  1458
	/// Assign operator.
deba@2126
  1459
        template <typename CMap>
deba@2126
  1460
        UEdgeMap& operator=(const CMap&) { 
deba@2126
  1461
          checkConcept<ReadMap<UEdge, Value>, CMap>();
deba@2126
  1462
          return *this;
deba@2126
  1463
        }
deba@2126
  1464
deba@2126
  1465
      };
deba@2126
  1466
deba@2126
  1467
deba@2126
  1468
      template <typename _Graph>
deba@2126
  1469
      struct Constraints {
deba@2126
  1470
deba@2126
  1471
	struct Dummy {
deba@2126
  1472
	  int value;
deba@2126
  1473
	  Dummy() : value(0) {}
deba@2126
  1474
	  Dummy(int _v) : value(_v) {}
deba@2126
  1475
	};
deba@2126
  1476
deba@2126
  1477
	void constraints() {
deba@2126
  1478
	  checkConcept<Base, _Graph>();
deba@2126
  1479
	  checkConcept<MappableGraphComponent<Base>, _Graph>();
deba@2126
  1480
deba@2126
  1481
	  { // int map test
deba@2126
  1482
	    typedef typename _Graph::template UEdgeMap<int> IntUEdgeMap;
deba@2126
  1483
	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, int>,
deba@2126
  1484
	      IntUEdgeMap >();
deba@2126
  1485
	  } { // bool map test
deba@2126
  1486
	    typedef typename _Graph::template UEdgeMap<bool> BoolUEdgeMap;
deba@2126
  1487
	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, bool>,
deba@2126
  1488
	      BoolUEdgeMap >();
deba@2126
  1489
	  } { // Dummy map test
deba@2126
  1490
	    typedef typename _Graph::template UEdgeMap<Dummy> DummyUEdgeMap;
deba@2126
  1491
	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, Dummy>, 
deba@2126
  1492
	      DummyUEdgeMap >();
deba@2126
  1493
	  } 
deba@2126
  1494
	}
deba@2126
  1495
deba@2126
  1496
	_Graph& graph;
deba@2126
  1497
      };
deba@2126
  1498
    };
deba@2126
  1499
deba@2126
  1500
deba@2126
  1501
    /// \brief An empty extendable graph class.
deba@2126
  1502
    ///
deba@2126
  1503
    /// This class provides beside the core graph features graph
deba@2126
  1504
    /// extendable interface for the graph structure.  The main
deba@2126
  1505
    /// difference between the base and this interface is that the
deba@2126
  1506
    /// graph alterations should handled already on this level.
deba@2126
  1507
    template <typename _Base = BaseGraphComponent>
deba@2126
  1508
    class ExtendableGraphComponent : public _Base {
deba@2126
  1509
    public:
deba@2126
  1510
deba@2126
  1511
      typedef typename _Base::Node Node;
deba@2126
  1512
      typedef typename _Base::Edge Edge;
deba@2126
  1513
deba@2126
  1514
      /// \brief Adds a new node to the graph.
deba@2126
  1515
      ///
deba@2126
  1516
      /// Adds a new node to the graph.
deba@2126
  1517
      ///
deba@2126
  1518
      Node addNode() {
deba@2126
  1519
	return INVALID;
deba@2126
  1520
      }
deba@2126
  1521
    
deba@2126
  1522
      /// \brief Adds a new edge connects the given two nodes.
deba@2126
  1523
      ///
deba@2126
  1524
      /// Adds a new edge connects the the given two nodes.
deba@2126
  1525
      Edge addEdge(const Node&, const Node&) {
deba@2126
  1526
	return INVALID;
deba@2126
  1527
      }
deba@2126
  1528
deba@2126
  1529
      template <typename _Graph>
deba@2126
  1530
      struct Constraints {
deba@2126
  1531
	void constraints() {
deba@2126
  1532
	  typename _Graph::Node node_a, node_b;
deba@2126
  1533
	  node_a = graph.addNode();
deba@2126
  1534
	  node_b = graph.addNode();
deba@2126
  1535
	  typename _Graph::Edge edge;
deba@2126
  1536
	  edge = graph.addEdge(node_a, node_b);
deba@2126
  1537
	}
deba@2126
  1538
deba@2126
  1539
	_Graph& graph;
deba@2126
  1540
      };
deba@2126
  1541
    };
deba@2126
  1542
deba@2126
  1543
    /// \brief An empty extendable base undirected graph class.
deba@2126
  1544
    ///
deba@2126
  1545
    /// This class provides beside the core undirected graph features
deba@2126
  1546
    /// core undircted graph extend interface for the graph structure.
deba@2126
  1547
    /// The main difference between the base and this interface is
deba@2126
  1548
    /// that the graph alterations should handled already on this
deba@2126
  1549
    /// level.
deba@2126
  1550
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1551
    class ExtendableUGraphComponent : public _Base {
deba@2126
  1552
    public:
deba@2126
  1553
deba@2126
  1554
      typedef typename _Base::Node Node;
deba@2126
  1555
      typedef typename _Base::UEdge UEdge;
deba@2126
  1556
deba@2126
  1557
      /// \brief Adds a new node to the graph.
deba@2126
  1558
      ///
deba@2126
  1559
      /// Adds a new node to the graph.
deba@2126
  1560
      ///
deba@2126
  1561
      Node addNode() {
deba@2126
  1562
	return INVALID;
deba@2126
  1563
      }
deba@2126
  1564
    
deba@2126
  1565
      /// \brief Adds a new edge connects the given two nodes.
deba@2126
  1566
      ///
deba@2126
  1567
      /// Adds a new edge connects the the given two nodes.
deba@2126
  1568
      UEdge addEdge(const Node&, const Node&) {
deba@2126
  1569
	return INVALID;
deba@2126
  1570
      }
deba@2126
  1571
deba@2126
  1572
      template <typename _Graph>
deba@2126
  1573
      struct Constraints {
deba@2126
  1574
	void constraints() {
deba@2126
  1575
	  typename _Graph::Node node_a, node_b;
deba@2126
  1576
	  node_a = graph.addNode();
deba@2126
  1577
	  node_b = graph.addNode();
deba@2126
  1578
	  typename _Graph::UEdge uedge;
deba@2126
  1579
	  uedge = graph.addUEdge(node_a, node_b);
deba@2126
  1580
	}
deba@2126
  1581
deba@2126
  1582
	_Graph& graph;
deba@2126
  1583
      };
deba@2126
  1584
    };
deba@2126
  1585
deba@2126
  1586
    /// \brief An empty erasable graph class.
deba@2126
  1587
    ///  
deba@2126
  1588
    /// This class provides beside the core graph features core erase
deba@2126
  1589
    /// functions for the graph structure. The main difference between
deba@2126
  1590
    /// the base and this interface is that the graph alterations
deba@2126
  1591
    /// should handled already on this level.
deba@2126
  1592
    template <typename _Base = BaseGraphComponent>
deba@2126
  1593
    class ErasableGraphComponent : public _Base {
deba@2126
  1594
    public:
deba@2126
  1595
deba@2126
  1596
      typedef _Base Base;
deba@2126
  1597
      typedef typename Base::Node Node;
deba@2126
  1598
      typedef typename Base::Edge Edge;
deba@2126
  1599
deba@2126
  1600
      /// \brief Erase a node from the graph.
deba@2126
  1601
      ///
deba@2126
  1602
      /// Erase a node from the graph. This function should 
deba@2126
  1603
      /// erase all edges connecting to the node.
deba@2126
  1604
      void erase(const Node&) {}    
deba@2126
  1605
deba@2126
  1606
      /// \brief Erase an edge from the graph.
deba@2126
  1607
      ///
deba@2126
  1608
      /// Erase an edge from the graph.
deba@2126
  1609
      ///
deba@2126
  1610
      void erase(const Edge&) {}
deba@2126
  1611
deba@2126
  1612
      template <typename _Graph>
deba@2126
  1613
      struct Constraints {
deba@2126
  1614
	void constraints() {
deba@2126
  1615
	  typename _Graph::Node node;
deba@2126
  1616
	  graph.erase(node);
deba@2126
  1617
	  typename _Graph::Edge edge;
deba@2126
  1618
	  graph.erase(edge);
deba@2126
  1619
	}
deba@2126
  1620
deba@2126
  1621
	_Graph& graph;
deba@2126
  1622
      };
deba@2126
  1623
    };
deba@2126
  1624
deba@2126
  1625
    /// \brief An empty erasable base undirected graph class.
deba@2126
  1626
    ///  
deba@2126
  1627
    /// This class provides beside the core undirected graph features
deba@2126
  1628
    /// core erase functions for the undirceted graph structure. The
deba@2126
  1629
    /// main difference between the base and this interface is that
deba@2126
  1630
    /// the graph alterations should handled already on this level.
deba@2126
  1631
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1632
    class ErasableUGraphComponent : public _Base {
deba@2126
  1633
    public:
deba@2126
  1634
deba@2126
  1635
      typedef _Base Base;
deba@2126
  1636
      typedef typename Base::Node Node;
deba@2126
  1637
      typedef typename Base::UEdge UEdge;
deba@2126
  1638
deba@2126
  1639
      /// \brief Erase a node from the graph.
deba@2126
  1640
      ///
deba@2126
  1641
      /// Erase a node from the graph. This function should erase
deba@2126
  1642
      /// edges connecting to the node.
deba@2126
  1643
      void erase(const Node&) {}    
deba@2126
  1644
deba@2126
  1645
      /// \brief Erase an edge from the graph.
deba@2126
  1646
      ///
deba@2126
  1647
      /// Erase an edge from the graph.
deba@2126
  1648
      ///
deba@2126
  1649
      void erase(const UEdge&) {}
deba@2126
  1650
deba@2126
  1651
      template <typename _Graph>
deba@2126
  1652
      struct Constraints {
deba@2126
  1653
	void constraints() {
deba@2126
  1654
	  typename _Graph::Node node;
deba@2126
  1655
	  graph.erase(node);
deba@2126
  1656
	  typename _Graph::Edge edge;
deba@2126
  1657
	  graph.erase(edge);
deba@2126
  1658
	}
deba@2126
  1659
deba@2126
  1660
	_Graph& graph;
deba@2126
  1661
      };
deba@2126
  1662
    };
deba@2126
  1663
deba@2126
  1664
    /// \brief An empty clearable base graph class.
deba@2126
  1665
    ///
deba@2126
  1666
    /// This class provides beside the core graph features core clear
deba@2126
  1667
    /// functions for the graph structure. The main difference between
deba@2126
  1668
    /// the base and this interface is that the graph alterations
deba@2126
  1669
    /// should handled already on this level.
deba@2126
  1670
    template <typename _Base = BaseGraphComponent>
deba@2126
  1671
    class ClearableGraphComponent : public _Base {
deba@2126
  1672
    public:
deba@2126
  1673
deba@2126
  1674
      /// \brief Erase all nodes and edges from the graph.
deba@2126
  1675
      ///
deba@2126
  1676
      /// Erase all nodes and edges from the graph.
deba@2126
  1677
      ///
deba@2126
  1678
      void clear() {}    
deba@2126
  1679
deba@2126
  1680
      template <typename _Graph>
deba@2126
  1681
      struct Constraints {
deba@2126
  1682
	void constraints() {
deba@2126
  1683
	  graph.clear();
deba@2126
  1684
	}
deba@2126
  1685
deba@2126
  1686
	_Graph graph;
deba@2126
  1687
      };
deba@2126
  1688
    };
deba@2126
  1689
deba@2126
  1690
    /// \brief An empty clearable base undirected graph class.
deba@2126
  1691
    ///
deba@2126
  1692
    /// This class provides beside the core undirected graph features
deba@2126
  1693
    /// core clear functions for the undirected graph structure. The
deba@2126
  1694
    /// main difference between the base and this interface is that
deba@2126
  1695
    /// the graph alterations should handled already on this level.
deba@2126
  1696
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1697
    class ClearableUGraphComponent : public _Base {
deba@2126
  1698
    public:
deba@2126
  1699
deba@2126
  1700
      /// \brief Erase all nodes and undirected edges from the graph.
deba@2126
  1701
      ///
deba@2126
  1702
      /// Erase all nodes and undirected edges from the graph.
deba@2126
  1703
      ///
deba@2126
  1704
      void clear() {}    
deba@2126
  1705
deba@2126
  1706
      template <typename _Graph>
deba@2126
  1707
      struct Constraints {
deba@2126
  1708
	void constraints() {
deba@2126
  1709
	  graph.clear();
deba@2126
  1710
	}
deba@2126
  1711
deba@2126
  1712
	_Graph graph;
deba@2126
  1713
      };
deba@2126
  1714
    };
deba@2126
  1715
deba@2126
  1716
  }
deba@2126
  1717
deba@2126
  1718
}
deba@2126
  1719
deba@2126
  1720
#endif