lemon/concept/graph_components.h
author deba
Tue, 03 Oct 2006 11:46:39 +0000
changeset 2231 06faf3f06d67
parent 2181 b2c38f4f72ff
permissions -rw-r--r--
Some rearrangement of concepts and extenders
BpUGraph concepts and concept check test
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@2231
   221
        /// \brief Assign edge to undirected edge.
deba@2231
   222
        ///
deba@2231
   223
        /// Besides the core graph item functionality each edge should
deba@2231
   224
        /// be convertible to the represented undirected edge. 
deba@2231
   225
        UEdge& operator=(const Edge&) { return *this; }
deba@2126
   226
      };
deba@2126
   227
deba@2126
   228
      /// \brief Returns the direction of the edge.
deba@2126
   229
      ///
deba@2126
   230
      /// Returns the direction of the edge. Each edge represents an
deba@2126
   231
      /// undirected edge with a direction. It gives back the
deba@2126
   232
      /// direction.
deba@2126
   233
      bool direction(const Edge&) const { return true; }
deba@2126
   234
deba@2126
   235
      /// \brief Returns the directed edge.
deba@2126
   236
      ///
deba@2126
   237
      /// Returns the directed edge from its direction and the
deba@2126
   238
      /// represented undirected edge.
deba@2126
   239
      Edge direct(const UEdge&, bool) const { return INVALID;} 
deba@2126
   240
deba@2126
   241
      /// \brief Returns the directed edge.
deba@2126
   242
      ///
deba@2126
   243
      /// Returns the directed edge from its source and the
deba@2126
   244
      /// represented undirected edge.
deba@2126
   245
      Edge direct(const UEdge&, const Node&) const { return INVALID;} 
deba@2126
   246
deba@2126
   247
      /// \brief Returns the opposite edge.
deba@2126
   248
      ///
deba@2126
   249
      /// Returns the opposite edge. It is the edge representing the
deba@2126
   250
      /// same undirected edge and has opposite direction.
deba@2126
   251
      Edge oppositeEdge(const Edge&) const { return INVALID;}
deba@2126
   252
deba@2126
   253
      /// \brief Gives back the target node of an undirected edge.
deba@2126
   254
      ///
deba@2126
   255
      /// Gives back the target node of an undirected edge. The name
deba@2126
   256
      /// target is a little confusing because the undirected edge
deba@2126
   257
      /// does not have target but it just means that one of the end 
deba@2126
   258
      /// node.
deba@2126
   259
      Node target(const UEdge&) const { return INVALID;}
deba@2126
   260
deba@2126
   261
      /// \brief Gives back the source node of an undirected edge.
deba@2126
   262
      ///
deba@2126
   263
      /// Gives back the source node of an undirected edge. The name
deba@2126
   264
      /// source is a little confusing because the undirected edge
deba@2126
   265
      /// does not have source but it just means that one of the end 
deba@2126
   266
      /// node.
deba@2126
   267
      Node source(const UEdge&) const { return INVALID;}
deba@2126
   268
      
deba@2126
   269
      template <typename _Graph>
deba@2126
   270
      struct Constraints {
deba@2126
   271
	typedef typename _Graph::Node Node;
deba@2126
   272
	typedef typename _Graph::Edge Edge;
deba@2126
   273
	typedef typename _Graph::UEdge UEdge;
deba@2126
   274
      
deba@2126
   275
	void constraints() {
deba@2126
   276
          checkConcept<BaseGraphComponent, _Graph>();
deba@2126
   277
	  checkConcept<GraphItem<'u'>, UEdge>();
deba@2126
   278
	  {
deba@2126
   279
	    Node n;
deba@2126
   280
	    UEdge ue(INVALID);
deba@2126
   281
            Edge e;
deba@2126
   282
	    n = graph.source(ue);
deba@2126
   283
	    n = graph.target(ue);
deba@2126
   284
            e = graph.direct(ue, true);
deba@2126
   285
            e = graph.direct(ue, n);
deba@2126
   286
            e = graph.oppositeEdge(e);
deba@2126
   287
            ue = e;
deba@2126
   288
            bool d = graph.direction(e);
deba@2126
   289
            ignore_unused_variable_warning(d);
deba@2126
   290
	  }      
deba@2126
   291
	}
deba@2126
   292
      
deba@2126
   293
	const _Graph& graph;
deba@2126
   294
      };
deba@2126
   295
deba@2126
   296
    };
deba@2126
   297
deba@2231
   298
    /// \brief An empty base bipartite undirected graph class.
deba@2126
   299
    ///  
deba@2231
   300
    /// This class provides the minimal set of features needed for an
deba@2231
   301
    /// bipartite undirected graph structure. All bipartite undirected
deba@2231
   302
    /// graph concepts have to be conform to this base graph. It just
deba@2231
   303
    /// provides types for nodes, A-nodes, B-nodes, edges and
deba@2231
   304
    /// undirected edges and functions to get the source and the
deba@2231
   305
    /// target of the edges and undirected edges, conversion from
deba@2231
   306
    /// edges to undirected edges and function to get both direction
deba@2231
   307
    /// of the undirected edges.
deba@2231
   308
    class BaseBpUGraphComponent : public BaseUGraphComponent {
deba@2126
   309
    public:
deba@2231
   310
      typedef BaseUGraphComponent::Node Node;
deba@2231
   311
      typedef BaseUGraphComponent::Edge Edge;
deba@2231
   312
      typedef BaseUGraphComponent::UEdge UEdge;
deba@2126
   313
deba@2231
   314
      /// \brief Helper class for A-nodes.
deba@2231
   315
      ///
deba@2231
   316
      /// This class is just a helper class for A-nodes, it is not
deba@2231
   317
      /// suggested to use it directly. It can be converted easily to
deba@2231
   318
      /// node and vice versa. The usage of this class is limited
deba@2231
   319
      /// to use just as template parameters for special map types. 
deba@2231
   320
      class ANode : public Node {
deba@2231
   321
      public:
deba@2231
   322
        typedef Node Parent;
deba@2126
   323
deba@2231
   324
        /// \brief Default constructor.
deba@2231
   325
        ///      
deba@2231
   326
        /// \warning The default constructor is not required to set
deba@2231
   327
        /// the item to some well-defined value. So you should consider it
deba@2231
   328
        /// as uninitialized.
deba@2231
   329
        ANode() {}
deba@2231
   330
        /// \brief Copy constructor.
deba@2231
   331
        ///
deba@2231
   332
        /// Copy constructor.
deba@2231
   333
        ///
deba@2231
   334
        ANode(const ANode &) : Parent() {}
deba@2231
   335
        /// \brief Invalid constructor \& conversion.
deba@2231
   336
        ///
deba@2231
   337
        /// This constructor initializes the item to be invalid.
deba@2231
   338
        /// \sa Invalid for more details.
deba@2231
   339
        ANode(Invalid) {}
deba@2231
   340
        /// \brief Converter from node to A-node.
deba@2231
   341
        ///
deba@2231
   342
        /// Besides the core graph item functionality each node should
deba@2231
   343
        /// be convertible to the represented A-node if it is it possible. 
deba@2231
   344
        ANode(const Node&) {}
deba@2231
   345
        /// \brief Assign node to A-node.
deba@2231
   346
        ///
deba@2231
   347
        /// Besides the core graph item functionality each node should
deba@2231
   348
        /// be convertible to the represented A-node if it is it possible. 
deba@2231
   349
        ANode& operator=(const Node&) { return *this; }
deba@2231
   350
      };
deba@2126
   351
deba@2231
   352
      /// \brief Helper class for B-nodes.
deba@2126
   353
      ///
deba@2231
   354
      /// This class is just a helper class for B-nodes, it is not
deba@2231
   355
      /// suggested to use it directly. It can be converted easily to
deba@2231
   356
      /// node and vice versa. The usage of this class is limited
deba@2231
   357
      /// to use just as template parameters for special map types. 
deba@2231
   358
      class BNode : public Node {
deba@2231
   359
      public:
deba@2231
   360
        typedef Node Parent;
deba@2126
   361
deba@2231
   362
        /// \brief Default constructor.
deba@2231
   363
        ///      
deba@2231
   364
        /// \warning The default constructor is not required to set
deba@2231
   365
        /// the item to some well-defined value. So you should consider it
deba@2231
   366
        /// as uninitialized.
deba@2231
   367
        BNode() {}
deba@2231
   368
        /// \brief Copy constructor.
deba@2231
   369
        ///
deba@2231
   370
        /// Copy constructor.
deba@2231
   371
        ///
deba@2231
   372
        BNode(const BNode &) : Parent() {}
deba@2231
   373
        /// \brief Invalid constructor \& conversion.
deba@2231
   374
        ///
deba@2231
   375
        /// This constructor initializes the item to be invalid.
deba@2231
   376
        /// \sa Invalid for more details.
deba@2231
   377
        BNode(Invalid) {}
deba@2231
   378
        /// \brief Converter from node to B-node.
deba@2231
   379
        ///
deba@2231
   380
        /// Besides the core graph item functionality each node should
deba@2231
   381
        /// be convertible to the represented B-node if it is it possible. 
deba@2231
   382
        BNode(const Node&) {}
deba@2231
   383
        /// \brief Assign node to B-node.
deba@2231
   384
        ///
deba@2231
   385
        /// Besides the core graph item functionality each node should
deba@2231
   386
        /// be convertible to the represented B-node if it is it possible. 
deba@2231
   387
        BNode& operator=(const Node&) { return *this; }
deba@2231
   388
      };
deba@2231
   389
      
deba@2231
   390
      /// \brief Gives back %true when the node is A-node.
deba@2126
   391
      ///
deba@2231
   392
      /// Gives back %true when the node is A-node.
deba@2231
   393
      bool aNode(const Node&) const { return false; }
deba@2126
   394
deba@2231
   395
      /// \brief Gives back %true when the node is B-node.
deba@2126
   396
      ///
deba@2231
   397
      /// Gives back %true when the node is B-node.
deba@2231
   398
      bool bNode(const Node&) const { return false; }
deba@2126
   399
deba@2231
   400
      /// \brief Gives back the A-node of the undirected edge.
deba@2231
   401
      ///
deba@2231
   402
      /// Gives back the A-node of the undirected edge.
deba@2231
   403
      Node aNode(const UEdge&) const { return INVALID; }
deba@2126
   404
deba@2231
   405
      /// \brief Gives back the B-node of the undirected edge.
deba@2126
   406
      ///
deba@2231
   407
      /// Gives back the B-node of the undirected edge.
deba@2231
   408
      Node bNode(const UEdge&) const { return INVALID; }
deba@2231
   409
      
deba@2126
   410
      template <typename _Graph>
deba@2126
   411
      struct Constraints {
deba@2231
   412
	typedef typename _Graph::Node Node;
deba@2231
   413
	typedef typename _Graph::ANode ANode;
deba@2231
   414
	typedef typename _Graph::BNode BNode;
deba@2231
   415
	typedef typename _Graph::Edge Edge;
deba@2231
   416
	typedef typename _Graph::UEdge UEdge;
deba@2126
   417
      
deba@2126
   418
	void constraints() {
deba@2231
   419
          checkConcept<BaseUGraphComponent, _Graph>();
deba@2231
   420
	  checkConcept<GraphItem<'a'>, ANode>();
deba@2231
   421
	  checkConcept<GraphItem<'b'>, BNode>();
deba@2126
   422
	  {
deba@2231
   423
	    Node n;
deba@2231
   424
	    UEdge ue(INVALID);
deba@2231
   425
            bool b;
deba@2231
   426
	    n = graph.aNode(ue);
deba@2231
   427
	    n = graph.bNode(ue);
deba@2231
   428
            b = graph.aNode(n);
deba@2231
   429
            b = graph.bNode(n);
deba@2231
   430
            ANode an;
deba@2231
   431
            an = n; n = an;
deba@2231
   432
            BNode bn;
deba@2231
   433
            bn = n; n = bn;            
deba@2231
   434
            ignore_unused_variable_warning(b);
deba@2231
   435
	  }      
deba@2126
   436
	}
deba@2231
   437
      
deba@2126
   438
	const _Graph& graph;
deba@2126
   439
      };
deba@2126
   440
deba@2126
   441
    };
deba@2126
   442
deba@2126
   443
    /// \brief An empty idable base graph class.
deba@2126
   444
    ///  
deba@2126
   445
    /// This class provides beside the core graph features
deba@2126
   446
    /// core id functions for the graph structure.
deba@2126
   447
    /// The most of the base graphs should be conform to this concept.
deba@2126
   448
    /// The id's are unique and immutable.
deba@2126
   449
    template <typename _Base = BaseGraphComponent>
deba@2126
   450
    class IDableGraphComponent : public _Base {
deba@2126
   451
    public:
deba@2126
   452
deba@2126
   453
      typedef _Base Base;
deba@2126
   454
      typedef typename Base::Node Node;
deba@2126
   455
      typedef typename Base::Edge Edge;
deba@2126
   456
deba@2126
   457
      /// \brief Gives back an unique integer id for the Node. 
deba@2126
   458
      ///
deba@2126
   459
      /// Gives back an unique integer id for the Node. 
deba@2126
   460
      ///
deba@2126
   461
      int id(const Node&) const { return -1;}
deba@2126
   462
deba@2126
   463
      /// \brief Gives back the node by the unique id.
deba@2126
   464
      ///
deba@2126
   465
      /// Gives back the node by the unique id.
deba@2126
   466
      /// If the graph does not contain node with the given id
deba@2126
   467
      /// then the result of the function is undetermined. 
deba@2126
   468
      Node nodeFromId(int) const { return INVALID;}
deba@2126
   469
deba@2126
   470
      /// \brief Gives back an unique integer id for the Edge. 
deba@2126
   471
      ///
deba@2126
   472
      /// Gives back an unique integer id for the Edge. 
deba@2126
   473
      ///
deba@2126
   474
      int id(const Edge&) const { return -1;}
deba@2126
   475
deba@2126
   476
      /// \brief Gives back the edge by the unique id.
deba@2126
   477
      ///
deba@2126
   478
      /// Gives back the edge by the unique id.
deba@2126
   479
      /// If the graph does not contain edge with the given id
deba@2126
   480
      /// then the result of the function is undetermined. 
deba@2126
   481
      Edge edgeFromId(int) const { return INVALID;}
deba@2126
   482
deba@2126
   483
      /// \brief Gives back an integer greater or equal to the maximum
deba@2126
   484
      /// Node id.
deba@2126
   485
      ///
deba@2126
   486
      /// Gives back an integer greater or equal to the maximum Node
deba@2126
   487
      /// id.
deba@2126
   488
      int maxNodeId() const { return -1;}
deba@2126
   489
deba@2126
   490
      /// \brief Gives back an integer greater or equal to the maximum
deba@2126
   491
      /// Edge id.
deba@2126
   492
      ///
deba@2126
   493
      /// Gives back an integer greater or equal to the maximum Edge
deba@2126
   494
      /// id.
deba@2126
   495
      int maxEdgeId() const { return -1;}
deba@2126
   496
deba@2126
   497
      template <typename _Graph>
deba@2126
   498
      struct Constraints {
deba@2126
   499
deba@2126
   500
	void constraints() {
deba@2231
   501
	  checkConcept<Base, _Graph >();
deba@2126
   502
	  typename _Graph::Node node;
deba@2126
   503
	  int nid = graph.id(node);
deba@2126
   504
	  nid = graph.id(node);
deba@2126
   505
	  node = graph.nodeFromId(nid);
deba@2126
   506
	  typename _Graph::Edge edge;
deba@2126
   507
	  int eid = graph.id(edge);
deba@2126
   508
	  eid = graph.id(edge);
deba@2126
   509
	  edge = graph.edgeFromId(eid);
deba@2126
   510
deba@2126
   511
	  nid = graph.maxNodeId();
deba@2126
   512
	  ignore_unused_variable_warning(nid);
deba@2126
   513
	  eid = graph.maxEdgeId();
deba@2126
   514
	  ignore_unused_variable_warning(eid);
deba@2126
   515
	}
deba@2126
   516
deba@2126
   517
	const _Graph& graph;
deba@2126
   518
      };
deba@2126
   519
    };
deba@2126
   520
deba@2126
   521
    /// \brief An empty idable base undirected graph class.
deba@2126
   522
    ///  
deba@2126
   523
    /// This class provides beside the core undirected graph features
deba@2126
   524
    /// core id functions for the undirected graph structure.  The
deba@2126
   525
    /// most of the base undirected graphs should be conform to this
deba@2126
   526
    /// concept.  The id's are unique and immutable.
deba@2126
   527
    template <typename _Base = BaseUGraphComponent>
deba@2126
   528
    class IDableUGraphComponent : public IDableGraphComponent<_Base> {
deba@2126
   529
    public:
deba@2126
   530
deba@2126
   531
      typedef _Base Base;
deba@2126
   532
      typedef typename Base::UEdge UEdge;
deba@2126
   533
deba@2126
   534
      using IDableGraphComponent<_Base>::id;
deba@2126
   535
deba@2126
   536
      /// \brief Gives back an unique integer id for the UEdge. 
deba@2126
   537
      ///
deba@2126
   538
      /// Gives back an unique integer id for the UEdge. 
deba@2126
   539
      ///
deba@2126
   540
      int id(const UEdge&) const { return -1;}
deba@2126
   541
deba@2126
   542
      /// \brief Gives back the undirected edge by the unique id.
deba@2126
   543
      ///
deba@2126
   544
      /// Gives back the undirected edge by the unique id.  If the
deba@2126
   545
      /// graph does not contain edge with the given id then the
deba@2126
   546
      /// result of the function is undetermined.
deba@2126
   547
      UEdge uEdgeFromId(int) const { return INVALID;}
deba@2126
   548
deba@2126
   549
      /// \brief Gives back an integer greater or equal to the maximum
deba@2126
   550
      /// UEdge id.
deba@2126
   551
      ///
deba@2126
   552
      /// Gives back an integer greater or equal to the maximum UEdge
deba@2126
   553
      /// id.
deba@2126
   554
      int maxUEdgeId() const { return -1;}
deba@2126
   555
deba@2126
   556
      template <typename _Graph>
deba@2126
   557
      struct Constraints {
deba@2126
   558
deba@2126
   559
	void constraints() {
deba@2126
   560
	  checkConcept<Base, _Graph >();
deba@2126
   561
	  checkConcept<IDableGraphComponent<Base>, _Graph >();
deba@2126
   562
	  typename _Graph::UEdge uedge;
deba@2126
   563
	  int ueid = graph.id(uedge);
deba@2126
   564
	  ueid = graph.id(uedge);
deba@2126
   565
	  uedge = graph.uEdgeFromId(ueid);
deba@2126
   566
	  ueid = graph.maxUEdgeId();
deba@2126
   567
	  ignore_unused_variable_warning(ueid);
deba@2126
   568
	}
deba@2126
   569
deba@2126
   570
	const _Graph& graph;
deba@2126
   571
      };
deba@2126
   572
    };
deba@2126
   573
deba@2231
   574
    /// \brief An empty idable base bipartite undirected graph class.
deba@2126
   575
    ///  
deba@2231
   576
    /// This class provides beside the core bipartite undirected graph
deba@2231
   577
    /// features core id functions for the bipartite undirected graph
deba@2231
   578
    /// structure.  The most of the base undirected graphs should be
deba@2231
   579
    /// conform to this concept.
deba@2231
   580
    template <typename _Base = BaseBpUGraphComponent>
deba@2231
   581
    class IDableBpUGraphComponent : public IDableUGraphComponent<_Base> {
deba@2126
   582
    public:
deba@2126
   583
deba@2126
   584
      typedef _Base Base;
deba@2126
   585
      typedef typename Base::Node Node;
deba@2126
   586
deba@2231
   587
      using IDableUGraphComponent<_Base>::id;
deba@2231
   588
deba@2231
   589
      /// \brief Gives back an unique integer id for the ANode. 
deba@2126
   590
      ///
deba@2231
   591
      /// Gives back an unique integer id for the ANode. 
deba@2231
   592
      ///
deba@2231
   593
      int aNodeId(const Node&) const { return -1;}
deba@2126
   594
deba@2231
   595
      /// \brief Gives back the undirected edge by the unique id.
deba@2126
   596
      ///
deba@2231
   597
      /// Gives back the undirected edge by the unique id.  If the
deba@2231
   598
      /// graph does not contain edge with the given id then the
deba@2231
   599
      /// result of the function is undetermined.
deba@2231
   600
      Node nodeFromANodeId(int) const { return INVALID;}
deba@2231
   601
deba@2231
   602
      /// \brief Gives back an integer greater or equal to the maximum
deba@2231
   603
      /// ANode id.
deba@2126
   604
      ///
deba@2231
   605
      /// Gives back an integer greater or equal to the maximum ANode
deba@2231
   606
      /// id.
deba@2231
   607
      int maxANodeId() const { return -1;}
deba@2231
   608
deba@2231
   609
      /// \brief Gives back an unique integer id for the BNode. 
deba@2231
   610
      ///
deba@2231
   611
      /// Gives back an unique integer id for the BNode. 
deba@2231
   612
      ///
deba@2231
   613
      int bNodeId(const Node&) const { return -1;}
deba@2231
   614
deba@2231
   615
      /// \brief Gives back the undirected edge by the unique id.
deba@2231
   616
      ///
deba@2231
   617
      /// Gives back the undirected edge by the unique id.  If the
deba@2231
   618
      /// graph does not contain edge with the given id then the
deba@2231
   619
      /// result of the function is undetermined.
deba@2231
   620
      Node nodeFromBNodeId(int) const { return INVALID;}
deba@2231
   621
deba@2231
   622
      /// \brief Gives back an integer greater or equal to the maximum
deba@2231
   623
      /// BNode id.
deba@2231
   624
      ///
deba@2231
   625
      /// Gives back an integer greater or equal to the maximum BNode
deba@2231
   626
      /// id.
deba@2231
   627
      int maxBNodeId() const { return -1;}
deba@2126
   628
deba@2126
   629
      template <typename _Graph>
deba@2126
   630
      struct Constraints {
deba@2231
   631
deba@2126
   632
	void constraints() {
deba@2231
   633
	  checkConcept<Base, _Graph >();
deba@2231
   634
	  checkConcept<IDableGraphComponent<Base>, _Graph >();
deba@2231
   635
	  typename _Graph::Node node(INVALID);
deba@2231
   636
	  int id;
deba@2231
   637
          id = graph.aNodeId(node);
deba@2231
   638
          id = graph.bNodeId(node);
deba@2231
   639
          node = graph.nodeFromANodeId(id);
deba@2231
   640
          node = graph.nodeFromBNodeId(id);
deba@2231
   641
          id = graph.maxANodeId();
deba@2231
   642
          id = graph.maxBNodeId();
deba@2126
   643
	}
deba@2126
   644
deba@2231
   645
	const _Graph& graph;
deba@2126
   646
      };
deba@2126
   647
    };
deba@2126
   648
deba@2126
   649
    /// \brief Skeleton class for graph NodeIt and EdgeIt
deba@2126
   650
    ///
deba@2126
   651
    /// Skeleton class for graph NodeIt and EdgeIt.
deba@2126
   652
    ///
deba@2126
   653
    template <typename _Graph, typename _Item>
deba@2126
   654
    class GraphItemIt : public _Item {
deba@2126
   655
    public:
deba@2126
   656
      /// \brief Default constructor.
deba@2126
   657
      ///
deba@2126
   658
      /// @warning The default constructor sets the iterator
deba@2126
   659
      /// to an undefined value.
deba@2126
   660
      GraphItemIt() {}
deba@2126
   661
      /// \brief Copy constructor.
deba@2126
   662
      ///
deba@2126
   663
      /// Copy constructor.
deba@2126
   664
      ///
deba@2126
   665
      GraphItemIt(const GraphItemIt& ) {}
deba@2126
   666
      /// \brief Sets the iterator to the first item.
deba@2126
   667
      ///
deba@2126
   668
      /// Sets the iterator to the first item of \c the graph.
deba@2126
   669
      ///
deba@2126
   670
      explicit GraphItemIt(const _Graph&) {}
deba@2126
   671
      /// \brief Invalid constructor \& conversion.
deba@2126
   672
      ///
deba@2126
   673
      /// This constructor initializes the item to be invalid.
deba@2126
   674
      /// \sa Invalid for more details.
deba@2126
   675
      GraphItemIt(Invalid) {}
deba@2126
   676
      /// \brief Assign operator for items.
deba@2126
   677
      ///
deba@2126
   678
      /// The items are assignable. 
deba@2126
   679
      ///
deba@2126
   680
      GraphItemIt& operator=(const GraphItemIt&) { return *this; }      
deba@2126
   681
      /// \brief Next item.
deba@2126
   682
      /// 
deba@2126
   683
      /// Assign the iterator to the next item.
deba@2126
   684
      ///
deba@2126
   685
      GraphItemIt& operator++() { return *this; }
deba@2126
   686
      /// \brief Equality operator
deba@2126
   687
      /// 
deba@2126
   688
      /// Two iterators are equal if and only if they point to the
deba@2126
   689
      /// same object or both are invalid.
deba@2126
   690
      bool operator==(const GraphItemIt&) const { return true;}
deba@2126
   691
      /// \brief Inequality operator
deba@2126
   692
      ///	
deba@2126
   693
      /// \sa operator==(Node n)
deba@2126
   694
      ///
deba@2126
   695
      bool operator!=(const GraphItemIt&) const { return true;}
deba@2126
   696
      
deba@2126
   697
      template<typename _GraphItemIt>
deba@2126
   698
      struct Constraints {
deba@2126
   699
	void constraints() {
deba@2126
   700
	  _GraphItemIt it1(g);	
deba@2126
   701
	  _GraphItemIt it2;
deba@2126
   702
deba@2126
   703
	  it2 = ++it1;
deba@2126
   704
	  ++it2 = it1;
deba@2126
   705
	  ++(++it1);
deba@2126
   706
deba@2126
   707
	  _Item bi = it1;
deba@2126
   708
	  bi = it2;
deba@2126
   709
	}
deba@2126
   710
	_Graph& g;
deba@2126
   711
      };
deba@2126
   712
    };
deba@2126
   713
deba@2126
   714
    /// \brief Skeleton class for graph InEdgeIt and OutEdgeIt
deba@2126
   715
    ///
deba@2126
   716
    /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
deba@2126
   717
    /// base class, the _selector is a additional template parameter. For 
deba@2126
   718
    /// InEdgeIt you should instantiate it with character 'i' and for 
deba@2126
   719
    /// OutEdgeIt with 'o'.
deba@2126
   720
    template <typename _Graph,
deba@2126
   721
	      typename _Item = typename _Graph::Edge,
deba@2126
   722
              typename _Base = typename _Graph::Node, 
deba@2126
   723
	      char _selector = '0'>
deba@2126
   724
    class GraphIncIt : public _Item {
deba@2126
   725
    public:
deba@2126
   726
      /// \brief Default constructor.
deba@2126
   727
      ///
deba@2126
   728
      /// @warning The default constructor sets the iterator
deba@2126
   729
      /// to an undefined value.
deba@2126
   730
      GraphIncIt() {}
deba@2126
   731
      /// \brief Copy constructor.
deba@2126
   732
      ///
deba@2126
   733
      /// Copy constructor.
deba@2126
   734
      ///
deba@2126
   735
      GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
deba@2126
   736
      /// \brief Sets the iterator to the first edge incoming into or outgoing 
deba@2126
   737
      /// from the node.
deba@2126
   738
      ///
deba@2126
   739
      /// Sets the iterator to the first edge incoming into or outgoing 
deba@2126
   740
      /// from the node.
deba@2126
   741
      ///
deba@2126
   742
      explicit GraphIncIt(const _Graph&, const _Base&) {}
deba@2126
   743
      /// \brief Invalid constructor \& conversion.
deba@2126
   744
      ///
deba@2126
   745
      /// This constructor initializes the item to be invalid.
deba@2126
   746
      /// \sa Invalid for more details.
deba@2126
   747
      GraphIncIt(Invalid) {}
deba@2126
   748
      /// \brief Assign operator for iterators.
deba@2126
   749
      ///
deba@2126
   750
      /// The iterators are assignable. 
deba@2126
   751
      ///
deba@2126
   752
      GraphIncIt& operator=(GraphIncIt const&) { return *this; }      
deba@2126
   753
      /// \brief Next item.
deba@2126
   754
      ///
deba@2126
   755
      /// Assign the iterator to the next item.
deba@2126
   756
      ///
deba@2126
   757
      GraphIncIt& operator++() { return *this; }
deba@2126
   758
deba@2126
   759
      /// \brief Equality operator
deba@2126
   760
      ///
deba@2126
   761
      /// Two iterators are equal if and only if they point to the
deba@2126
   762
      /// same object or both are invalid.
deba@2126
   763
      bool operator==(const GraphIncIt&) const { return true;}
deba@2126
   764
deba@2126
   765
      /// \brief Inequality operator
deba@2126
   766
      ///
deba@2126
   767
      /// \sa operator==(Node n)
deba@2126
   768
      ///
deba@2126
   769
      bool operator!=(const GraphIncIt&) const { return true;}
deba@2126
   770
deba@2126
   771
      template <typename _GraphIncIt>
deba@2126
   772
      struct Constraints {
deba@2126
   773
	void constraints() {
deba@2126
   774
	  checkConcept<GraphItem<_selector>, _GraphIncIt>();
deba@2126
   775
	  _GraphIncIt it1(graph, node);
deba@2126
   776
	  _GraphIncIt it2;
deba@2126
   777
deba@2126
   778
	  it2 = ++it1;
deba@2126
   779
	  ++it2 = it1;
deba@2126
   780
	  ++(++it1);
deba@2126
   781
	  _Item e = it1;
deba@2126
   782
	  e = it2;
deba@2126
   783
deba@2126
   784
	}
deba@2126
   785
deba@2126
   786
	_Item edge;
deba@2126
   787
	_Base node;
deba@2126
   788
	_Graph graph;
deba@2126
   789
	_GraphIncIt it;
deba@2126
   790
      };
deba@2126
   791
    };
deba@2126
   792
deba@2126
   793
deba@2126
   794
    /// \brief An empty iterable graph class.
deba@2126
   795
    ///
deba@2126
   796
    /// This class provides beside the core graph features
deba@2126
   797
    /// iterator based iterable interface for the graph structure.
deba@2231
   798
    /// This concept is part of the Graph concept.
deba@2126
   799
    template <typename _Base = BaseGraphComponent>
deba@2126
   800
    class IterableGraphComponent : public _Base {
deba@2126
   801
deba@2126
   802
    public:
deba@2126
   803
    
deba@2126
   804
      typedef _Base Base;
deba@2126
   805
      typedef typename Base::Node Node;
deba@2126
   806
      typedef typename Base::Edge Edge;
deba@2126
   807
deba@2126
   808
      typedef IterableGraphComponent Graph;
deba@2126
   809
deba@2231
   810
      /// \name Base iteration
deba@2231
   811
      /// 
deba@2231
   812
      /// This interface provides functions for iteration on graph items
deba@2231
   813
      ///
deba@2231
   814
      /// @{  
deba@2231
   815
deba@2231
   816
      /// \brief Gives back the first node in the iterating order.
deba@2231
   817
      ///      
deba@2231
   818
      /// Gives back the first node in the iterating order.
deba@2231
   819
      ///     
deba@2231
   820
      void first(Node&) const {}
deba@2231
   821
deba@2231
   822
      /// \brief Gives back the next node in the iterating order.
deba@2231
   823
      ///
deba@2231
   824
      /// Gives back the next node in the iterating order.
deba@2231
   825
      ///     
deba@2231
   826
      void next(Node&) const {}
deba@2231
   827
deba@2231
   828
      /// \brief Gives back the first edge in the iterating order.
deba@2231
   829
      ///
deba@2231
   830
      /// Gives back the first edge in the iterating order.
deba@2231
   831
      ///     
deba@2231
   832
      void first(Edge&) const {}
deba@2231
   833
deba@2231
   834
      /// \brief Gives back the next edge in the iterating order.
deba@2231
   835
      ///
deba@2231
   836
      /// Gives back the next edge in the iterating order.
deba@2231
   837
      ///     
deba@2231
   838
      void next(Edge&) const {}
deba@2231
   839
deba@2231
   840
deba@2231
   841
      /// \brief Gives back the first of the edges point to the given
deba@2231
   842
      /// node.
deba@2231
   843
      ///
deba@2231
   844
      /// Gives back the first of the edges point to the given node.
deba@2231
   845
      ///     
deba@2231
   846
      void firstIn(Edge&, const Node&) const {}
deba@2231
   847
deba@2231
   848
      /// \brief Gives back the next of the edges points to the given
deba@2231
   849
      /// node.
deba@2231
   850
      ///
deba@2231
   851
      /// Gives back the next of the edges points to the given node.
deba@2231
   852
      ///
deba@2231
   853
      void nextIn(Edge&) const {}
deba@2231
   854
deba@2231
   855
      /// \brief Gives back the first of the edges start from the
deba@2231
   856
      /// given node.
deba@2231
   857
      ///      
deba@2231
   858
      /// Gives back the first of the edges start from the given node.
deba@2231
   859
      ///     
deba@2231
   860
      void firstOut(Edge&, const Node&) const {}
deba@2231
   861
deba@2231
   862
      /// \brief Gives back the next of the edges start from the given
deba@2231
   863
      /// node.
deba@2231
   864
      ///
deba@2231
   865
      /// Gives back the next of the edges start from the given node.
deba@2231
   866
      ///     
deba@2231
   867
      void nextOut(Edge&) const {}
deba@2231
   868
deba@2231
   869
      /// @}
deba@2231
   870
deba@2231
   871
      /// \name Class based iteration
deba@2231
   872
      /// 
deba@2231
   873
      /// This interface provides functions for iteration on graph items
deba@2231
   874
      ///
deba@2231
   875
      /// @{
deba@2126
   876
deba@2126
   877
      /// \brief This iterator goes through each node.
deba@2126
   878
      ///
deba@2126
   879
      /// This iterator goes through each node.
deba@2126
   880
      ///
deba@2126
   881
      typedef GraphItemIt<Graph, Node> NodeIt;
deba@2126
   882
deba@2126
   883
      /// \brief This iterator goes through each node.
deba@2126
   884
      ///
deba@2126
   885
      /// This iterator goes through each node.
deba@2126
   886
      ///
deba@2126
   887
      typedef GraphItemIt<Graph, Edge> EdgeIt;
deba@2126
   888
deba@2126
   889
      /// \brief This iterator goes trough the incoming edges of a node.
deba@2126
   890
      ///
deba@2126
   891
      /// This iterator goes trough the \e inccoming edges of a certain node
deba@2126
   892
      /// of a graph.
deba@2126
   893
      typedef GraphIncIt<Graph, Edge, Node, 'i'> InEdgeIt;
deba@2126
   894
deba@2126
   895
      /// \brief This iterator goes trough the outgoing edges of a node.
deba@2126
   896
      ///
deba@2126
   897
      /// This iterator goes trough the \e outgoing edges of a certain node
deba@2126
   898
      /// of a graph.
deba@2126
   899
      typedef GraphIncIt<Graph, Edge, Node, 'o'> OutEdgeIt;
deba@2126
   900
deba@2126
   901
      /// \brief The base node of the iterator.
deba@2126
   902
      ///
deba@2126
   903
      /// Gives back the base node of the iterator.
deba@2126
   904
      /// It is always the target of the pointed edge.
deba@2126
   905
      Node baseNode(const InEdgeIt&) const { return INVALID; }
deba@2126
   906
deba@2126
   907
      /// \brief The running node of the iterator.
deba@2126
   908
      ///
deba@2126
   909
      /// Gives back the running node of the iterator.
deba@2126
   910
      /// It is always the source of the pointed edge.
deba@2126
   911
      Node runningNode(const InEdgeIt&) const { return INVALID; }
deba@2126
   912
deba@2126
   913
      /// \brief The base node of the iterator.
deba@2126
   914
      ///
deba@2126
   915
      /// Gives back the base node of the iterator.
deba@2126
   916
      /// It is always the source of the pointed edge.
deba@2126
   917
      Node baseNode(const OutEdgeIt&) const { return INVALID; }
deba@2126
   918
deba@2126
   919
      /// \brief The running node of the iterator.
deba@2126
   920
      ///
deba@2126
   921
      /// Gives back the running node of the iterator.
deba@2126
   922
      /// It is always the target of the pointed edge.
deba@2126
   923
      Node runningNode(const OutEdgeIt&) const { return INVALID; }
deba@2126
   924
deba@2231
   925
      /// @}
deba@2126
   926
deba@2126
   927
      template <typename _Graph> 
deba@2126
   928
      struct Constraints {
deba@2126
   929
	void constraints() {
deba@2126
   930
	  checkConcept<Base, _Graph>();
deba@2126
   931
deba@2231
   932
          {
deba@2231
   933
            typename _Graph::Node node(INVALID);      
deba@2231
   934
            typename _Graph::Edge edge(INVALID);
deba@2231
   935
            {
deba@2231
   936
              graph.first(node);
deba@2231
   937
              graph.next(node);
deba@2231
   938
            }
deba@2231
   939
            {
deba@2231
   940
              graph.first(edge);
deba@2231
   941
              graph.next(edge);
deba@2231
   942
            }
deba@2231
   943
            {
deba@2231
   944
              graph.firstIn(edge, node);
deba@2231
   945
              graph.nextIn(edge);
deba@2231
   946
            }
deba@2231
   947
            {
deba@2231
   948
              graph.firstOut(edge, node);
deba@2231
   949
              graph.nextOut(edge);
deba@2231
   950
            }
deba@2231
   951
          }           
deba@2231
   952
deba@2231
   953
          {
deba@2231
   954
            checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
deba@2231
   955
              typename _Graph::EdgeIt >();
deba@2231
   956
            checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
deba@2231
   957
              typename _Graph::NodeIt >();
deba@2231
   958
            checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
deba@2231
   959
              typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
deba@2231
   960
            checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
deba@2231
   961
              typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
deba@2231
   962
deba@2231
   963
            typename _Graph::Node n;
deba@2231
   964
            typename _Graph::InEdgeIt ieit(INVALID);
deba@2231
   965
            typename _Graph::OutEdgeIt oeit(INVALID);
deba@2231
   966
            n = graph.baseNode(ieit);
deba@2231
   967
            n = graph.runningNode(ieit);
deba@2231
   968
            n = graph.baseNode(oeit);
deba@2231
   969
            n = graph.runningNode(oeit);
deba@2231
   970
            ignore_unused_variable_warning(n);
deba@2231
   971
          }
deba@2126
   972
        }
deba@2126
   973
	
deba@2126
   974
	const _Graph& graph;
deba@2126
   975
	
deba@2126
   976
      };
deba@2126
   977
    };
deba@2126
   978
deba@2126
   979
    /// \brief An empty iterable undirected graph class.
deba@2126
   980
    ///
deba@2126
   981
    /// This class provides beside the core graph features iterator
deba@2126
   982
    /// based iterable interface for the undirected graph structure.
deba@2231
   983
    /// This concept is part of the UGraph concept.
deba@2126
   984
    template <typename _Base = BaseUGraphComponent>
deba@2126
   985
    class IterableUGraphComponent : public IterableGraphComponent<_Base> {
deba@2126
   986
    public:
deba@2126
   987
deba@2126
   988
      typedef _Base Base;
deba@2126
   989
      typedef typename Base::Node Node;
deba@2126
   990
      typedef typename Base::Edge Edge;
deba@2126
   991
      typedef typename Base::UEdge UEdge;
deba@2126
   992
deba@2126
   993
    
deba@2126
   994
      typedef IterableUGraphComponent Graph;
deba@2231
   995
deba@2231
   996
      /// \name Base iteration
deba@2231
   997
      /// 
deba@2231
   998
      /// This interface provides functions for iteration on graph items
deba@2231
   999
      /// @{  
deba@2231
  1000
deba@2231
  1001
      using IterableGraphComponent<_Base>::first;
deba@2231
  1002
      using IterableGraphComponent<_Base>::next;
deba@2231
  1003
deba@2231
  1004
      /// \brief Gives back the first undirected edge in the iterating
deba@2231
  1005
      /// order.
deba@2231
  1006
      ///
deba@2231
  1007
      /// Gives back the first undirected edge in the iterating order.
deba@2231
  1008
      ///     
deba@2231
  1009
      void first(UEdge&) const {}
deba@2231
  1010
deba@2231
  1011
      /// \brief Gives back the next undirected edge in the iterating
deba@2231
  1012
      /// order.
deba@2231
  1013
      ///
deba@2231
  1014
      /// Gives back the next undirected edge in the iterating order.
deba@2231
  1015
      ///     
deba@2231
  1016
      void next(UEdge&) const {}
deba@2231
  1017
deba@2231
  1018
deba@2231
  1019
      /// \brief Gives back the first of the undirected edges from the
deba@2231
  1020
      /// given node.
deba@2231
  1021
      ///
deba@2231
  1022
      /// Gives back the first of the undirected edges from the given
deba@2231
  1023
      /// node. The bool parameter gives back that direction which
deba@2231
  1024
      /// gives a good direction of the uedge so the source of the
deba@2231
  1025
      /// directed edge is the given node.
deba@2231
  1026
      void firstInc(UEdge&, bool&, const Node&) const {}
deba@2231
  1027
deba@2231
  1028
      /// \brief Gives back the next of the undirected edges from the
deba@2231
  1029
      /// given node.
deba@2231
  1030
      ///
deba@2231
  1031
      /// Gives back the next of the undirected edges from the given
deba@2231
  1032
      /// node. The bool parameter should be used as the \c firstInc()
deba@2231
  1033
      /// use it.
deba@2231
  1034
      void nextInc(UEdge&, bool&) const {}
deba@2231
  1035
deba@2126
  1036
      using IterableGraphComponent<_Base>::baseNode;
deba@2126
  1037
      using IterableGraphComponent<_Base>::runningNode;
deba@2126
  1038
deba@2231
  1039
      /// @}
deba@2231
  1040
deba@2231
  1041
      /// \name Class based iteration
deba@2231
  1042
      /// 
deba@2231
  1043
      /// This interface provides functions for iteration on graph items
deba@2231
  1044
      ///
deba@2231
  1045
      /// @{
deba@2126
  1046
deba@2126
  1047
      /// \brief This iterator goes through each node.
deba@2126
  1048
      ///
deba@2126
  1049
      /// This iterator goes through each node.
deba@2126
  1050
      typedef GraphItemIt<Graph, UEdge> UEdgeIt;
deba@2126
  1051
      /// \brief This iterator goes trough the incident edges of a
deba@2126
  1052
      /// node.
deba@2126
  1053
      ///
deba@2126
  1054
      /// This iterator goes trough the incident edges of a certain
deba@2126
  1055
      /// node of a graph.
deba@2126
  1056
      typedef GraphIncIt<Graph, UEdge, Node, 'u'> IncEdgeIt;
deba@2126
  1057
      /// \brief The base node of the iterator.
deba@2126
  1058
      ///
deba@2126
  1059
      /// Gives back the base node of the iterator.
deba@2126
  1060
      Node baseNode(const IncEdgeIt&) const { return INVALID; }
deba@2126
  1061
deba@2126
  1062
      /// \brief The running node of the iterator.
deba@2126
  1063
      ///
deba@2126
  1064
      /// Gives back the running node of the iterator.
deba@2126
  1065
      Node runningNode(const IncEdgeIt&) const { return INVALID; }
deba@2126
  1066
deba@2231
  1067
      /// @}
deba@2231
  1068
deba@2126
  1069
      template <typename _Graph> 
deba@2126
  1070
      struct Constraints {
deba@2126
  1071
	void constraints() {
deba@2126
  1072
	  checkConcept<IterableGraphComponent<Base>, _Graph>();
deba@2126
  1073
deba@2231
  1074
          {
deba@2231
  1075
            typename _Graph::Node node(INVALID);
deba@2231
  1076
            typename _Graph::UEdge uedge(INVALID);
deba@2231
  1077
            bool dir;
deba@2231
  1078
            {
deba@2231
  1079
              graph.first(uedge);
deba@2231
  1080
              graph.next(uedge);
deba@2231
  1081
            }
deba@2231
  1082
            {
deba@2231
  1083
              graph.firstInc(uedge, dir, node);
deba@2231
  1084
              graph.nextInc(uedge, dir);
deba@2231
  1085
            }
deba@2231
  1086
            
deba@2231
  1087
          }	
deba@2231
  1088
  
deba@2231
  1089
          {
deba@2231
  1090
            checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
deba@2231
  1091
              typename _Graph::UEdgeIt >();
deba@2231
  1092
            checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge, 
deba@2231
  1093
              typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
deba@2231
  1094
            
deba@2231
  1095
            typename _Graph::Node n;
deba@2231
  1096
            typename _Graph::IncEdgeIt ueit(INVALID);
deba@2231
  1097
            n = graph.baseNode(ueit);
deba@2231
  1098
            n = graph.runningNode(ueit);
deba@2231
  1099
          }
deba@2231
  1100
        }
deba@2231
  1101
	
deba@2231
  1102
	const _Graph& graph;
deba@2231
  1103
	
deba@2231
  1104
      };
deba@2231
  1105
    };
deba@2231
  1106
deba@2231
  1107
    /// \brief An empty iterable bipartite undirected graph class.
deba@2231
  1108
    ///
deba@2231
  1109
    /// This class provides beside the core graph features iterator
deba@2231
  1110
    /// based iterable interface for the bipartite undirected graph
deba@2231
  1111
    /// structure. This concept is part of the BpUGraph concept.
deba@2231
  1112
    template <typename _Base = BaseUGraphComponent>
deba@2231
  1113
    class IterableBpUGraphComponent : public IterableUGraphComponent<_Base> {
deba@2231
  1114
    public:
deba@2231
  1115
deba@2231
  1116
      typedef _Base Base;
deba@2231
  1117
      typedef typename Base::Node Node;
deba@2231
  1118
      typedef typename Base::UEdge UEdge;
deba@2231
  1119
    
deba@2231
  1120
      typedef IterableBpUGraphComponent Graph;
deba@2231
  1121
deba@2231
  1122
      /// \name Base iteration
deba@2231
  1123
      /// 
deba@2231
  1124
      /// This interface provides functions for iteration on graph items
deba@2231
  1125
      /// @{  
deba@2231
  1126
deba@2231
  1127
      using IterableUGraphComponent<_Base>::first;
deba@2231
  1128
      using IterableUGraphComponent<_Base>::next;
deba@2231
  1129
deba@2231
  1130
      /// \brief Gives back the first A-node in the iterating order.
deba@2231
  1131
      ///
deba@2231
  1132
      /// Gives back the first undirected A-node in the iterating
deba@2231
  1133
      /// order.
deba@2231
  1134
      ///     
deba@2231
  1135
      void firstANode(Node&) const {}
deba@2231
  1136
deba@2231
  1137
      /// \brief Gives back the next A-node in the iterating order.
deba@2231
  1138
      ///
deba@2231
  1139
      /// Gives back the next A-node in the iterating order.
deba@2231
  1140
      ///     
deba@2231
  1141
      void nextANode(Node&) const {}
deba@2231
  1142
deba@2231
  1143
      /// \brief Gives back the first B-node in the iterating order.
deba@2231
  1144
      ///
deba@2231
  1145
      /// Gives back the first undirected B-node in the iterating
deba@2231
  1146
      /// order.
deba@2231
  1147
      ///     
deba@2231
  1148
      void firstBNode(Node&) const {}
deba@2231
  1149
deba@2231
  1150
      /// \brief Gives back the next B-node in the iterating order.
deba@2231
  1151
      ///
deba@2231
  1152
      /// Gives back the next B-node in the iterating order.
deba@2231
  1153
      ///     
deba@2231
  1154
      void nextBNode(Node&) const {}
deba@2231
  1155
deba@2231
  1156
deba@2231
  1157
      /// \brief Gives back the first of the undirected edges start
deba@2231
  1158
      /// from the given A-node.
deba@2231
  1159
      ///      
deba@2231
  1160
      /// Gives back the first of the undirected edges start from the
deba@2231
  1161
      /// given A-node.
deba@2231
  1162
      void firstFromANode(UEdge&, const Node&) const {}
deba@2231
  1163
deba@2231
  1164
      /// \brief Gives back the next of the undirected edges start
deba@2231
  1165
      /// from the given A-node.
deba@2231
  1166
      ///      
deba@2231
  1167
      /// Gives back the next of the undirected edges start from the
deba@2231
  1168
      /// given A-node.
deba@2231
  1169
      void nextFromANode(UEdge&) const {}
deba@2231
  1170
deba@2231
  1171
      /// \brief Gives back the first of the undirected edges start
deba@2231
  1172
      /// from the given B-node.
deba@2231
  1173
      ///      
deba@2231
  1174
      /// Gives back the first of the undirected edges start from the
deba@2231
  1175
      /// given B-node.
deba@2231
  1176
      void firstFromBNode(UEdge&, const Node&) const {}
deba@2231
  1177
deba@2231
  1178
      /// \brief Gives back the next of the undirected edges start
deba@2231
  1179
      /// from the given B-node.
deba@2231
  1180
      ///      
deba@2231
  1181
      /// Gives back the next of the undirected edges start from the
deba@2231
  1182
      /// given B-node.
deba@2231
  1183
      void nextFromBNode(UEdge&) const {}
deba@2231
  1184
deba@2231
  1185
deba@2231
  1186
      /// @}
deba@2231
  1187
deba@2231
  1188
      /// \name Class based iteration
deba@2231
  1189
      /// 
deba@2231
  1190
      /// This interface provides functions for iteration on graph items
deba@2231
  1191
      ///
deba@2231
  1192
      /// @{
deba@2231
  1193
deba@2231
  1194
      /// \brief This iterator goes through each A-node.
deba@2231
  1195
      ///
deba@2231
  1196
      /// This iterator goes through each A-node.
deba@2231
  1197
      typedef GraphItemIt<Graph, Node> ANodeIt;
deba@2231
  1198
deba@2231
  1199
      /// \brief This iterator goes through each B-node.
deba@2231
  1200
      ///
deba@2231
  1201
      /// This iterator goes through each B-node.
deba@2231
  1202
      typedef GraphItemIt<Graph, Node> BNodeIt;
deba@2231
  1203
deba@2231
  1204
      /// @}
deba@2231
  1205
deba@2231
  1206
      template <typename _Graph> 
deba@2231
  1207
      struct Constraints {
deba@2231
  1208
	void constraints() {
deba@2231
  1209
	  checkConcept<IterableUGraphComponent<Base>, _Graph>();
deba@2231
  1210
deba@2231
  1211
          {
deba@2231
  1212
            typename _Graph::Node node(INVALID);
deba@2231
  1213
            typename _Graph::UEdge uedge(INVALID);
deba@2231
  1214
            graph.firstANode(node);
deba@2231
  1215
            graph.nextANode(node);
deba@2231
  1216
            graph.firstBNode(node);
deba@2231
  1217
            graph.nextBNode(node);
deba@2231
  1218
deba@2231
  1219
            graph.firstFromANode(uedge, node);
deba@2231
  1220
            graph.nextFromANode(uedge);
deba@2231
  1221
            graph.firstFromBNode(uedge, node);
deba@2231
  1222
            graph.nextFromBNode(uedge);
deba@2231
  1223
          }
deba@2231
  1224
          {
deba@2231
  1225
            checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
deba@2231
  1226
              typename _Graph::ANodeIt >();
deba@2231
  1227
            checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
deba@2231
  1228
              typename _Graph::BNodeIt >();
deba@2231
  1229
          }
deba@2231
  1230
deba@2126
  1231
	}
deba@2126
  1232
	
deba@2126
  1233
	const _Graph& graph;
deba@2126
  1234
	
deba@2126
  1235
      };
deba@2126
  1236
    };
deba@2126
  1237
deba@2126
  1238
    /// \brief An empty alteration notifier graph class.
deba@2126
  1239
    ///  
deba@2126
  1240
    /// This class provides beside the core graph features alteration
deba@2126
  1241
    /// notifier interface for the graph structure.  This implements
deba@2126
  1242
    /// an observer-notifier pattern for each graph item. More
deba@2126
  1243
    /// obsevers can be registered into the notifier and whenever an
deba@2126
  1244
    /// alteration occured in the graph all the observers will
deba@2126
  1245
    /// notified about it.
deba@2126
  1246
    template <typename _Base = BaseGraphComponent>
deba@2126
  1247
    class AlterableGraphComponent : public _Base {
deba@2126
  1248
    public:
deba@2126
  1249
deba@2126
  1250
      typedef _Base Base;
deba@2126
  1251
      typedef typename Base::Node Node;
deba@2126
  1252
      typedef typename Base::Edge Edge;
deba@2126
  1253
deba@2126
  1254
deba@2126
  1255
      /// The node observer registry.
deba@2126
  1256
      typedef AlterationNotifier<AlterableGraphComponent, Node> 
deba@2126
  1257
      NodeNotifier;
deba@2126
  1258
      /// The edge observer registry.
deba@2126
  1259
      typedef AlterationNotifier<AlterableGraphComponent, Edge> 
deba@2126
  1260
      EdgeNotifier;
deba@2126
  1261
      
deba@2126
  1262
      /// \brief Gives back the node alteration notifier.
deba@2126
  1263
      ///
deba@2126
  1264
      /// Gives back the node alteration notifier.
deba@2126
  1265
      NodeNotifier& getNotifier(Node) const {
deba@2126
  1266
	return NodeNotifier();
deba@2126
  1267
      }
deba@2126
  1268
      
deba@2126
  1269
      /// \brief Gives back the edge alteration notifier.
deba@2126
  1270
      ///
deba@2126
  1271
      /// Gives back the edge alteration notifier.
deba@2126
  1272
      EdgeNotifier& getNotifier(Edge) const {
deba@2126
  1273
	return EdgeNotifier();
deba@2126
  1274
      }
deba@2126
  1275
deba@2126
  1276
      template <typename _Graph> 
deba@2126
  1277
      struct Constraints {
deba@2126
  1278
	void constraints() {
deba@2126
  1279
	  checkConcept<Base, _Graph>();
deba@2126
  1280
          typename _Graph::NodeNotifier& nn 
deba@2126
  1281
            = graph.getNotifier(typename _Graph::Node());
deba@2126
  1282
deba@2126
  1283
          typename _Graph::EdgeNotifier& en 
deba@2126
  1284
            = graph.getNotifier(typename _Graph::Edge());
deba@2126
  1285
          
deba@2126
  1286
          ignore_unused_variable_warning(nn);
deba@2126
  1287
          ignore_unused_variable_warning(en);
deba@2126
  1288
	}
deba@2126
  1289
	
deba@2126
  1290
	const _Graph& graph;
deba@2126
  1291
	
deba@2126
  1292
      };
deba@2126
  1293
      
deba@2126
  1294
    };
deba@2126
  1295
deba@2126
  1296
    /// \brief An empty alteration notifier undirected graph class.
deba@2126
  1297
    ///  
deba@2126
  1298
    /// This class provides beside the core graph features alteration
deba@2126
  1299
    /// notifier interface for the graph structure.  This implements
deba@2126
  1300
    /// an observer-notifier pattern for each graph item. More
deba@2126
  1301
    /// obsevers can be registered into the notifier and whenever an
deba@2126
  1302
    /// alteration occured in the graph all the observers will
deba@2126
  1303
    /// notified about it.
deba@2126
  1304
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1305
    class AlterableUGraphComponent : public AlterableGraphComponent<_Base> {
deba@2126
  1306
    public:
deba@2126
  1307
deba@2126
  1308
      typedef _Base Base;
deba@2126
  1309
      typedef typename Base::UEdge UEdge;
deba@2126
  1310
deba@2126
  1311
deba@2126
  1312
      /// The edge observer registry.
deba@2126
  1313
      typedef AlterationNotifier<AlterableUGraphComponent, UEdge> 
deba@2126
  1314
      UEdgeNotifier;
deba@2126
  1315
      
deba@2126
  1316
      /// \brief Gives back the edge alteration notifier.
deba@2126
  1317
      ///
deba@2126
  1318
      /// Gives back the edge alteration notifier.
deba@2126
  1319
      UEdgeNotifier& getNotifier(UEdge) const {
deba@2126
  1320
	return UEdgeNotifier();
deba@2126
  1321
      }
deba@2126
  1322
deba@2126
  1323
      template <typename _Graph> 
deba@2126
  1324
      struct Constraints {
deba@2126
  1325
	void constraints() {
deba@2231
  1326
	  checkConcept<AlterableGraphComponent<Base>, _Graph>();
deba@2126
  1327
          typename _Graph::UEdgeNotifier& uen 
deba@2126
  1328
            = graph.getNotifier(typename _Graph::UEdge());
deba@2126
  1329
          ignore_unused_variable_warning(uen);
deba@2126
  1330
	}
deba@2126
  1331
	
deba@2126
  1332
	const _Graph& graph;
deba@2126
  1333
	
deba@2126
  1334
      };
deba@2126
  1335
      
deba@2126
  1336
    };
deba@2126
  1337
deba@2231
  1338
    /// \brief An empty alteration notifier bipartite undirected graph
deba@2231
  1339
    /// class.
deba@2231
  1340
    ///  
deba@2231
  1341
    /// This class provides beside the core graph features alteration
deba@2231
  1342
    /// notifier interface for the graph structure.  This implements
deba@2231
  1343
    /// an observer-notifier pattern for each graph item. More
deba@2231
  1344
    /// obsevers can be registered into the notifier and whenever an
deba@2231
  1345
    /// alteration occured in the graph all the observers will
deba@2231
  1346
    /// notified about it.
deba@2231
  1347
    template <typename _Base = BaseUGraphComponent>
deba@2231
  1348
    class AlterableBpUGraphComponent : public AlterableUGraphComponent<_Base> {
deba@2231
  1349
    public:
deba@2231
  1350
deba@2231
  1351
      typedef _Base Base;
deba@2231
  1352
      typedef typename Base::ANode ANode;
deba@2231
  1353
      typedef typename Base::BNode BNode;
deba@2231
  1354
deba@2231
  1355
deba@2231
  1356
      /// The A-node observer registry.
deba@2231
  1357
      typedef AlterationNotifier<AlterableBpUGraphComponent, ANode> 
deba@2231
  1358
      ANodeNotifier;
deba@2231
  1359
deba@2231
  1360
      /// The B-node observer registry.
deba@2231
  1361
      typedef AlterationNotifier<AlterableBpUGraphComponent, BNode> 
deba@2231
  1362
      BNodeNotifier;
deba@2231
  1363
      
deba@2231
  1364
      /// \brief Gives back the A-node alteration notifier.
deba@2231
  1365
      ///
deba@2231
  1366
      /// Gives back the A-node alteration notifier.
deba@2231
  1367
      ANodeNotifier& getNotifier(ANode) const {
deba@2231
  1368
	return ANodeNotifier();
deba@2231
  1369
      }
deba@2231
  1370
deba@2231
  1371
      /// \brief Gives back the B-node alteration notifier.
deba@2231
  1372
      ///
deba@2231
  1373
      /// Gives back the B-node alteration notifier.
deba@2231
  1374
      BNodeNotifier& getNotifier(BNode) const {
deba@2231
  1375
	return BNodeNotifier();
deba@2231
  1376
      }
deba@2231
  1377
deba@2231
  1378
      template <typename _Graph> 
deba@2231
  1379
      struct Constraints {
deba@2231
  1380
	void constraints() {
deba@2231
  1381
          checkConcept<AlterableUGraphComponent<Base>, _Graph>();
deba@2231
  1382
          typename _Graph::ANodeNotifier& ann 
deba@2231
  1383
            = graph.getNotifier(typename _Graph::ANode());
deba@2231
  1384
          typename _Graph::BNodeNotifier& bnn 
deba@2231
  1385
            = graph.getNotifier(typename _Graph::BNode());
deba@2231
  1386
          ignore_unused_variable_warning(ann);
deba@2231
  1387
          ignore_unused_variable_warning(bnn);
deba@2231
  1388
	}
deba@2231
  1389
	
deba@2231
  1390
	const _Graph& graph;
deba@2231
  1391
	
deba@2231
  1392
      };
deba@2231
  1393
      
deba@2231
  1394
    };
deba@2231
  1395
deba@2126
  1396
deba@2126
  1397
    /// \brief Class describing the concept of graph maps
deba@2126
  1398
    /// 
deba@2126
  1399
    /// This class describes the common interface of the graph maps
deba@2126
  1400
    /// (NodeMap, EdgeMap), that is \ref maps-page "maps" which can be used to
deba@2126
  1401
    /// associate data to graph descriptors (nodes or edges).
deba@2126
  1402
    template <typename _Graph, typename _Item, typename _Value>
deba@2126
  1403
    class GraphMap : public ReadWriteMap<_Item, _Value> {
deba@2126
  1404
    public:
deba@2126
  1405
deba@2126
  1406
      typedef ReadWriteMap<_Item, _Value> Parent;
deba@2126
  1407
deba@2126
  1408
      /// The graph type of the map.
deba@2126
  1409
      typedef _Graph Graph;
deba@2126
  1410
      /// The key type of the map.
deba@2126
  1411
      typedef _Item Key;
deba@2126
  1412
      /// The value type of the map.
deba@2126
  1413
      typedef _Value Value;
deba@2126
  1414
deba@2126
  1415
      /// \brief Construct a new map.
deba@2126
  1416
      ///
deba@2126
  1417
      /// Construct a new map for the graph.
deba@2126
  1418
      explicit GraphMap(const Graph&) {}
deba@2126
  1419
      /// \brief Construct a new map with default value.
deba@2126
  1420
      ///
deba@2126
  1421
      /// Construct a new map for the graph and initalise the values.
deba@2126
  1422
      GraphMap(const Graph&, const Value&) {}
deba@2126
  1423
      /// \brief Copy constructor.
deba@2126
  1424
      ///
deba@2126
  1425
      /// Copy Constructor.
deba@2126
  1426
      GraphMap(const GraphMap&) : Parent() {}
deba@2126
  1427
      
deba@2126
  1428
      /// \brief Assign operator.
deba@2126
  1429
      ///
deba@2126
  1430
      /// Assign operator. It does not mofify the underlying graph,
deba@2126
  1431
      /// it just iterates on the current item set and set the  map
deba@2126
  1432
      /// with the value returned by the assigned map. 
deba@2126
  1433
      template <typename CMap>
deba@2126
  1434
      GraphMap& operator=(const CMap&) { 
deba@2126
  1435
        checkConcept<ReadMap<Key, Value>, CMap>();
deba@2126
  1436
        return *this;
deba@2126
  1437
      }
deba@2126
  1438
deba@2126
  1439
      template<typename _Map>
deba@2126
  1440
      struct Constraints {
deba@2126
  1441
	void constraints() {
deba@2126
  1442
	  checkConcept<ReadWriteMap<Key, Value>, _Map >();
deba@2126
  1443
	  // Construction with a graph parameter
deba@2126
  1444
	  _Map a(g);
deba@2126
  1445
	  // Constructor with a graph and a default value parameter
deba@2126
  1446
	  _Map a2(g,t);
deba@2126
  1447
	  // Copy constructor.
deba@2126
  1448
	  _Map b(c);
deba@2126
  1449
          
deba@2126
  1450
          ReadMap<Key, Value> cmap;
deba@2126
  1451
          b = cmap;
deba@2126
  1452
deba@2126
  1453
	  ignore_unused_variable_warning(a2);
deba@2126
  1454
	  ignore_unused_variable_warning(b);
deba@2126
  1455
	}
deba@2126
  1456
deba@2126
  1457
	const _Map &c;
deba@2126
  1458
	const Graph &g;
deba@2126
  1459
	const typename GraphMap::Value &t;
deba@2126
  1460
      };
deba@2126
  1461
deba@2126
  1462
    };
deba@2126
  1463
deba@2126
  1464
    /// \brief An empty mappable graph class.
deba@2126
  1465
    ///
deba@2126
  1466
    /// This class provides beside the core graph features
deba@2126
  1467
    /// map interface for the graph structure.
deba@2126
  1468
    /// This concept is part of the Graph concept.
deba@2126
  1469
    template <typename _Base = BaseGraphComponent>
deba@2126
  1470
    class MappableGraphComponent : public _Base  {
deba@2126
  1471
    public:
deba@2126
  1472
deba@2126
  1473
      typedef _Base Base;
deba@2126
  1474
      typedef typename Base::Node Node;
deba@2126
  1475
      typedef typename Base::Edge Edge;
deba@2126
  1476
deba@2126
  1477
      typedef MappableGraphComponent Graph;
deba@2126
  1478
deba@2126
  1479
      /// \brief ReadWrite map of the nodes.
deba@2126
  1480
      ///
deba@2126
  1481
      /// ReadWrite map of the nodes.
deba@2126
  1482
      ///
deba@2181
  1483
      template <typename _Value>
deba@2181
  1484
      class NodeMap : public GraphMap<Graph, Node, _Value> {
deba@2126
  1485
      private:
deba@2126
  1486
	NodeMap();
deba@2126
  1487
      public:
deba@2181
  1488
        typedef GraphMap<MappableGraphComponent, Node, _Value> Parent;
deba@2126
  1489
deba@2126
  1490
	/// \brief Construct a new map.
deba@2126
  1491
	///
deba@2126
  1492
	/// Construct a new map for the graph.
deba@2126
  1493
	/// \todo call the right parent class constructor
deba@2181
  1494
	explicit NodeMap(const MappableGraphComponent& graph) 
deba@2181
  1495
          : Parent(graph) {}
deba@2126
  1496
deba@2126
  1497
	/// \brief Construct a new map with default value.
deba@2126
  1498
	///
deba@2126
  1499
	/// Construct a new map for the graph and initalise the values.
deba@2181
  1500
	NodeMap(const MappableGraphComponent& graph, const _Value& value)
deba@2126
  1501
          : Parent(graph, value) {}
deba@2126
  1502
deba@2126
  1503
	/// \brief Copy constructor.
deba@2126
  1504
	///
deba@2126
  1505
	/// Copy Constructor.
deba@2126
  1506
	NodeMap(const NodeMap& nm) : Parent(nm) {}
deba@2126
  1507
deba@2126
  1508
	/// \brief Assign operator.
deba@2126
  1509
	///
deba@2126
  1510
	/// Assign operator.
deba@2126
  1511
        template <typename CMap>
deba@2126
  1512
        NodeMap& operator=(const CMap&) { 
deba@2181
  1513
          checkConcept<ReadMap<Node, _Value>, CMap>();
deba@2126
  1514
          return *this;
deba@2126
  1515
        }
deba@2126
  1516
deba@2126
  1517
      };
deba@2126
  1518
deba@2126
  1519
      /// \brief ReadWrite map of the edges.
deba@2126
  1520
      ///
deba@2126
  1521
      /// ReadWrite map of the edges.
deba@2126
  1522
      ///
deba@2181
  1523
      template <typename _Value>
deba@2181
  1524
      class EdgeMap : public GraphMap<Graph, Edge, _Value> {
deba@2126
  1525
      private:
deba@2126
  1526
	EdgeMap();
deba@2126
  1527
      public:
deba@2181
  1528
        typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
deba@2126
  1529
deba@2126
  1530
	/// \brief Construct a new map.
deba@2126
  1531
	///
deba@2126
  1532
	/// Construct a new map for the graph.
deba@2126
  1533
	/// \todo call the right parent class constructor
deba@2181
  1534
	explicit EdgeMap(const MappableGraphComponent& graph) 
deba@2181
  1535
          : Parent(graph) {}
deba@2126
  1536
deba@2126
  1537
	/// \brief Construct a new map with default value.
deba@2126
  1538
	///
deba@2126
  1539
	/// Construct a new map for the graph and initalise the values.
deba@2181
  1540
	EdgeMap(const MappableGraphComponent& graph, const _Value& value)
deba@2126
  1541
          : Parent(graph, value) {}
deba@2126
  1542
deba@2126
  1543
	/// \brief Copy constructor.
deba@2126
  1544
	///
deba@2126
  1545
	/// Copy Constructor.
deba@2126
  1546
	EdgeMap(const EdgeMap& nm) : Parent(nm) {}
deba@2126
  1547
deba@2126
  1548
	/// \brief Assign operator.
deba@2126
  1549
	///
deba@2126
  1550
	/// Assign operator.
deba@2126
  1551
        template <typename CMap>
deba@2126
  1552
        EdgeMap& operator=(const CMap&) { 
deba@2181
  1553
          checkConcept<ReadMap<Edge, _Value>, CMap>();
deba@2126
  1554
          return *this;
deba@2126
  1555
        }
deba@2126
  1556
deba@2126
  1557
      };
deba@2126
  1558
deba@2126
  1559
deba@2126
  1560
      template <typename _Graph>
deba@2126
  1561
      struct Constraints {
deba@2126
  1562
deba@2126
  1563
	struct Dummy {
deba@2126
  1564
	  int value;
deba@2126
  1565
	  Dummy() : value(0) {}
deba@2126
  1566
	  Dummy(int _v) : value(_v) {}
deba@2126
  1567
	};
deba@2126
  1568
deba@2126
  1569
	void constraints() {
deba@2126
  1570
	  checkConcept<Base, _Graph>();
deba@2126
  1571
	  { // int map test
deba@2126
  1572
	    typedef typename _Graph::template NodeMap<int> IntNodeMap;
deba@2126
  1573
	    checkConcept<GraphMap<_Graph, typename _Graph::Node, int>, 
deba@2126
  1574
	      IntNodeMap >();
deba@2126
  1575
	  } { // bool map test
deba@2126
  1576
	    typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
deba@2126
  1577
	    checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>,
deba@2126
  1578
	      BoolNodeMap >();
deba@2126
  1579
	  } { // Dummy map test
deba@2126
  1580
	    typedef typename _Graph::template NodeMap<Dummy> DummyNodeMap;
deba@2126
  1581
	    checkConcept<GraphMap<_Graph, typename _Graph::Node, Dummy>,
deba@2126
  1582
	      DummyNodeMap >();
deba@2126
  1583
	  } 
deba@2126
  1584
deba@2126
  1585
	  { // int map test
deba@2126
  1586
	    typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
deba@2126
  1587
	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
deba@2126
  1588
	      IntEdgeMap >();
deba@2126
  1589
	  } { // bool map test
deba@2126
  1590
	    typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
deba@2126
  1591
	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
deba@2126
  1592
	      BoolEdgeMap >();
deba@2126
  1593
	  } { // Dummy map test
deba@2126
  1594
	    typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
deba@2126
  1595
	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>, 
deba@2126
  1596
	      DummyEdgeMap >();
deba@2126
  1597
	  } 
deba@2126
  1598
	}
deba@2126
  1599
deba@2126
  1600
	_Graph& graph;
deba@2126
  1601
      };
deba@2126
  1602
    };
deba@2126
  1603
deba@2231
  1604
    /// \brief An empty mappable base bipartite undirected graph class.
deba@2126
  1605
    ///
deba@2126
  1606
    /// This class provides beside the core graph features
deba@2126
  1607
    /// map interface for the graph structure.
deba@2126
  1608
    /// This concept is part of the UGraph concept.
deba@2126
  1609
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1610
    class MappableUGraphComponent : public MappableGraphComponent<_Base>  {
deba@2126
  1611
    public:
deba@2126
  1612
deba@2126
  1613
      typedef _Base Base;
deba@2126
  1614
      typedef typename Base::UEdge UEdge;
deba@2126
  1615
deba@2126
  1616
      typedef MappableUGraphComponent Graph;
deba@2126
  1617
deba@2126
  1618
      /// \brief ReadWrite map of the uedges.
deba@2126
  1619
      ///
deba@2126
  1620
      /// ReadWrite map of the uedges.
deba@2126
  1621
      ///
deba@2181
  1622
      template <typename _Value>
deba@2181
  1623
      class UEdgeMap : public GraphMap<Graph, UEdge, _Value> {  
deba@2126
  1624
      public:
deba@2181
  1625
        typedef GraphMap<MappableUGraphComponent, UEdge, _Value> Parent;
deba@2126
  1626
deba@2126
  1627
	/// \brief Construct a new map.
deba@2126
  1628
	///
deba@2126
  1629
	/// Construct a new map for the graph.
deba@2126
  1630
	/// \todo call the right parent class constructor
deba@2181
  1631
	explicit UEdgeMap(const MappableUGraphComponent& graph) 
deba@2181
  1632
          : Parent(graph) {}
deba@2126
  1633
deba@2126
  1634
	/// \brief Construct a new map with default value.
deba@2126
  1635
	///
deba@2126
  1636
	/// Construct a new map for the graph and initalise the values.
deba@2181
  1637
	UEdgeMap(const MappableUGraphComponent& graph, const _Value& value)
deba@2126
  1638
          : Parent(graph, value) {}
deba@2126
  1639
deba@2126
  1640
	/// \brief Copy constructor.
deba@2126
  1641
	///
deba@2126
  1642
	/// Copy Constructor.
deba@2126
  1643
	UEdgeMap(const UEdgeMap& nm) : Parent(nm) {}
deba@2126
  1644
deba@2126
  1645
	/// \brief Assign operator.
deba@2126
  1646
	///
deba@2126
  1647
	/// Assign operator.
deba@2126
  1648
        template <typename CMap>
deba@2126
  1649
        UEdgeMap& operator=(const CMap&) { 
deba@2181
  1650
          checkConcept<ReadMap<UEdge, _Value>, CMap>();
deba@2126
  1651
          return *this;
deba@2126
  1652
        }
deba@2126
  1653
deba@2126
  1654
      };
deba@2126
  1655
deba@2126
  1656
deba@2126
  1657
      template <typename _Graph>
deba@2126
  1658
      struct Constraints {
deba@2126
  1659
deba@2126
  1660
	struct Dummy {
deba@2126
  1661
	  int value;
deba@2126
  1662
	  Dummy() : value(0) {}
deba@2126
  1663
	  Dummy(int _v) : value(_v) {}
deba@2126
  1664
	};
deba@2126
  1665
deba@2126
  1666
	void constraints() {
deba@2126
  1667
	  checkConcept<MappableGraphComponent<Base>, _Graph>();
deba@2126
  1668
deba@2126
  1669
	  { // int map test
deba@2126
  1670
	    typedef typename _Graph::template UEdgeMap<int> IntUEdgeMap;
deba@2126
  1671
	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, int>,
deba@2126
  1672
	      IntUEdgeMap >();
deba@2126
  1673
	  } { // bool map test
deba@2126
  1674
	    typedef typename _Graph::template UEdgeMap<bool> BoolUEdgeMap;
deba@2126
  1675
	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, bool>,
deba@2126
  1676
	      BoolUEdgeMap >();
deba@2126
  1677
	  } { // Dummy map test
deba@2126
  1678
	    typedef typename _Graph::template UEdgeMap<Dummy> DummyUEdgeMap;
deba@2126
  1679
	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, Dummy>, 
deba@2126
  1680
	      DummyUEdgeMap >();
deba@2126
  1681
	  } 
deba@2126
  1682
	}
deba@2126
  1683
deba@2126
  1684
	_Graph& graph;
deba@2126
  1685
      };
deba@2126
  1686
    };
deba@2126
  1687
deba@2231
  1688
    /// \brief An empty mappable base bipartite undirected graph
deba@2231
  1689
    /// class.
deba@2231
  1690
    ///
deba@2231
  1691
    /// This class provides beside the core graph features
deba@2231
  1692
    /// map interface for the graph structure.
deba@2231
  1693
    /// This concept is part of the BpUGraph concept.
deba@2231
  1694
    template <typename _Base = BaseBpUGraphComponent>
deba@2231
  1695
    class MappableBpUGraphComponent : public MappableUGraphComponent<_Base>  {
deba@2231
  1696
    public:
deba@2231
  1697
deba@2231
  1698
      typedef _Base Base;
deba@2231
  1699
      typedef typename Base::Node Node;
deba@2231
  1700
deba@2231
  1701
      typedef MappableBpUGraphComponent Graph;
deba@2231
  1702
deba@2231
  1703
      /// \brief ReadWrite map of the A-nodes.
deba@2231
  1704
      ///
deba@2231
  1705
      /// ReadWrite map of the A-nodes.
deba@2231
  1706
      ///
deba@2231
  1707
      template <typename _Value>
deba@2231
  1708
      class ANodeMap : public GraphMap<Graph, Node, _Value> {  
deba@2231
  1709
      public:
deba@2231
  1710
        typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
deba@2231
  1711
deba@2231
  1712
	/// \brief Construct a new map.
deba@2231
  1713
	///
deba@2231
  1714
	/// Construct a new map for the graph.
deba@2231
  1715
	/// \todo call the right parent class constructor
deba@2231
  1716
	explicit ANodeMap(const MappableBpUGraphComponent& graph) 
deba@2231
  1717
          : Parent(graph) {}
deba@2231
  1718
deba@2231
  1719
	/// \brief Construct a new map with default value.
deba@2231
  1720
	///
deba@2231
  1721
	/// Construct a new map for the graph and initalise the values.
deba@2231
  1722
	ANodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
deba@2231
  1723
          : Parent(graph, value) {}
deba@2231
  1724
deba@2231
  1725
	/// \brief Copy constructor.
deba@2231
  1726
	///
deba@2231
  1727
	/// Copy Constructor.
deba@2231
  1728
	ANodeMap(const ANodeMap& nm) : Parent(nm) {}
deba@2231
  1729
deba@2231
  1730
	/// \brief Assign operator.
deba@2231
  1731
	///
deba@2231
  1732
	/// Assign operator.
deba@2231
  1733
        template <typename CMap>
deba@2231
  1734
        ANodeMap& operator=(const CMap&) { 
deba@2231
  1735
          checkConcept<ReadMap<Node, _Value>, CMap>();
deba@2231
  1736
          return *this;
deba@2231
  1737
        }
deba@2231
  1738
deba@2231
  1739
      };
deba@2231
  1740
deba@2231
  1741
      /// \brief ReadWrite map of the B-nodes.
deba@2231
  1742
      ///
deba@2231
  1743
      /// ReadWrite map of the A-nodes.
deba@2231
  1744
      ///
deba@2231
  1745
      template <typename _Value>
deba@2231
  1746
      class BNodeMap : public GraphMap<Graph, Node, _Value> {  
deba@2231
  1747
      public:
deba@2231
  1748
        typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
deba@2231
  1749
deba@2231
  1750
	/// \brief Construct a new map.
deba@2231
  1751
	///
deba@2231
  1752
	/// Construct a new map for the graph.
deba@2231
  1753
	/// \todo call the right parent class constructor
deba@2231
  1754
	explicit BNodeMap(const MappableBpUGraphComponent& graph) 
deba@2231
  1755
          : Parent(graph) {}
deba@2231
  1756
deba@2231
  1757
	/// \brief Construct a new map with default value.
deba@2231
  1758
	///
deba@2231
  1759
	/// Construct a new map for the graph and initalise the values.
deba@2231
  1760
	BNodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
deba@2231
  1761
          : Parent(graph, value) {}
deba@2231
  1762
deba@2231
  1763
	/// \brief Copy constructor.
deba@2231
  1764
	///
deba@2231
  1765
	/// Copy Constructor.
deba@2231
  1766
	BNodeMap(const BNodeMap& nm) : Parent(nm) {}
deba@2231
  1767
deba@2231
  1768
	/// \brief Assign operator.
deba@2231
  1769
	///
deba@2231
  1770
	/// Assign operator.
deba@2231
  1771
        template <typename CMap>
deba@2231
  1772
        BNodeMap& operator=(const CMap&) { 
deba@2231
  1773
          checkConcept<ReadMap<Node, _Value>, CMap>();
deba@2231
  1774
          return *this;
deba@2231
  1775
        }
deba@2231
  1776
deba@2231
  1777
      };
deba@2231
  1778
deba@2231
  1779
deba@2231
  1780
      template <typename _Graph>
deba@2231
  1781
      struct Constraints {
deba@2231
  1782
deba@2231
  1783
	struct Dummy {
deba@2231
  1784
	  int value;
deba@2231
  1785
	  Dummy() : value(0) {}
deba@2231
  1786
	  Dummy(int _v) : value(_v) {}
deba@2231
  1787
	};
deba@2231
  1788
deba@2231
  1789
	void constraints() {
deba@2231
  1790
	  checkConcept<MappableUGraphComponent<Base>, _Graph>();
deba@2231
  1791
deba@2231
  1792
	  { // int map test
deba@2231
  1793
	    typedef typename _Graph::template ANodeMap<int> IntANodeMap;
deba@2231
  1794
	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, int>,
deba@2231
  1795
	      IntANodeMap >();
deba@2231
  1796
	  } { // bool map test
deba@2231
  1797
	    typedef typename _Graph::template ANodeMap<bool> BoolANodeMap;
deba@2231
  1798
	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, bool>,
deba@2231
  1799
	      BoolANodeMap >();
deba@2231
  1800
	  } { // Dummy map test
deba@2231
  1801
	    typedef typename _Graph::template ANodeMap<Dummy> DummyANodeMap;
deba@2231
  1802
	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, Dummy>, 
deba@2231
  1803
	      DummyANodeMap >();
deba@2231
  1804
	  } 
deba@2231
  1805
	}
deba@2231
  1806
deba@2231
  1807
	_Graph& graph;
deba@2231
  1808
      };
deba@2231
  1809
    };
deba@2231
  1810
deba@2126
  1811
deba@2126
  1812
    /// \brief An empty extendable graph class.
deba@2126
  1813
    ///
deba@2126
  1814
    /// This class provides beside the core graph features graph
deba@2126
  1815
    /// extendable interface for the graph structure.  The main
deba@2126
  1816
    /// difference between the base and this interface is that the
deba@2126
  1817
    /// graph alterations should handled already on this level.
deba@2126
  1818
    template <typename _Base = BaseGraphComponent>
deba@2126
  1819
    class ExtendableGraphComponent : public _Base {
deba@2126
  1820
    public:
deba@2231
  1821
      typedef _Base Base;
deba@2126
  1822
deba@2126
  1823
      typedef typename _Base::Node Node;
deba@2126
  1824
      typedef typename _Base::Edge Edge;
deba@2126
  1825
deba@2126
  1826
      /// \brief Adds a new node to the graph.
deba@2126
  1827
      ///
deba@2126
  1828
      /// Adds a new node to the graph.
deba@2126
  1829
      ///
deba@2126
  1830
      Node addNode() {
deba@2126
  1831
	return INVALID;
deba@2126
  1832
      }
deba@2126
  1833
    
deba@2126
  1834
      /// \brief Adds a new edge connects the given two nodes.
deba@2126
  1835
      ///
deba@2126
  1836
      /// Adds a new edge connects the the given two nodes.
deba@2126
  1837
      Edge addEdge(const Node&, const Node&) {
deba@2126
  1838
	return INVALID;
deba@2126
  1839
      }
deba@2126
  1840
deba@2126
  1841
      template <typename _Graph>
deba@2126
  1842
      struct Constraints {
deba@2126
  1843
	void constraints() {
deba@2231
  1844
          checkConcept<Base, _Graph>();
deba@2126
  1845
	  typename _Graph::Node node_a, node_b;
deba@2126
  1846
	  node_a = graph.addNode();
deba@2126
  1847
	  node_b = graph.addNode();
deba@2126
  1848
	  typename _Graph::Edge edge;
deba@2126
  1849
	  edge = graph.addEdge(node_a, node_b);
deba@2126
  1850
	}
deba@2126
  1851
deba@2126
  1852
	_Graph& graph;
deba@2126
  1853
      };
deba@2126
  1854
    };
deba@2126
  1855
deba@2126
  1856
    /// \brief An empty extendable base undirected graph class.
deba@2126
  1857
    ///
deba@2126
  1858
    /// This class provides beside the core undirected graph features
deba@2126
  1859
    /// core undircted graph extend interface for the graph structure.
deba@2126
  1860
    /// The main difference between the base and this interface is
deba@2126
  1861
    /// that the graph alterations should handled already on this
deba@2126
  1862
    /// level.
deba@2126
  1863
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1864
    class ExtendableUGraphComponent : public _Base {
deba@2126
  1865
    public:
deba@2126
  1866
deba@2231
  1867
      typedef _Base Base;
deba@2126
  1868
      typedef typename _Base::Node Node;
deba@2126
  1869
      typedef typename _Base::UEdge UEdge;
deba@2126
  1870
deba@2126
  1871
      /// \brief Adds a new node to the graph.
deba@2126
  1872
      ///
deba@2126
  1873
      /// Adds a new node to the graph.
deba@2126
  1874
      ///
deba@2126
  1875
      Node addNode() {
deba@2126
  1876
	return INVALID;
deba@2126
  1877
      }
deba@2126
  1878
    
deba@2126
  1879
      /// \brief Adds a new edge connects the given two nodes.
deba@2126
  1880
      ///
deba@2126
  1881
      /// Adds a new edge connects the the given two nodes.
deba@2126
  1882
      UEdge addEdge(const Node&, const Node&) {
deba@2126
  1883
	return INVALID;
deba@2126
  1884
      }
deba@2126
  1885
deba@2126
  1886
      template <typename _Graph>
deba@2126
  1887
      struct Constraints {
deba@2126
  1888
	void constraints() {
deba@2231
  1889
	  checkConcept<Base, _Graph>();
deba@2126
  1890
	  typename _Graph::Node node_a, node_b;
deba@2126
  1891
	  node_a = graph.addNode();
deba@2126
  1892
	  node_b = graph.addNode();
deba@2126
  1893
	  typename _Graph::UEdge uedge;
deba@2126
  1894
	  uedge = graph.addUEdge(node_a, node_b);
deba@2126
  1895
	}
deba@2126
  1896
deba@2126
  1897
	_Graph& graph;
deba@2126
  1898
      };
deba@2126
  1899
    };
deba@2126
  1900
deba@2231
  1901
    /// \brief An empty extendable base undirected graph class.
deba@2231
  1902
    ///
deba@2231
  1903
    /// This class provides beside the core bipartite undirected graph
deba@2231
  1904
    /// features core undircted graph extend interface for the graph
deba@2231
  1905
    /// structure.  The main difference between the base and this
deba@2231
  1906
    /// interface is that the graph alterations should handled already
deba@2231
  1907
    /// on this level.
deba@2231
  1908
    template <typename _Base = BaseBpUGraphComponent>
deba@2231
  1909
    class ExtendableBpUGraphComponent 
deba@2231
  1910
      : public ExtendableUGraphComponent<_Base> {
deba@2231
  1911
deba@2231
  1912
      typedef _Base Base;
deba@2231
  1913
deba@2231
  1914
      template <typename _Graph>
deba@2231
  1915
      struct Constraints {
deba@2231
  1916
	void constraints() {
deba@2231
  1917
          checkConcept<ExtendableUGraphComponent<Base>, _Graph>();
deba@2231
  1918
	}
deba@2231
  1919
      };
deba@2231
  1920
    };
deba@2231
  1921
deba@2126
  1922
    /// \brief An empty erasable graph class.
deba@2126
  1923
    ///  
deba@2126
  1924
    /// This class provides beside the core graph features core erase
deba@2126
  1925
    /// functions for the graph structure. The main difference between
deba@2126
  1926
    /// the base and this interface is that the graph alterations
deba@2126
  1927
    /// should handled already on this level.
deba@2126
  1928
    template <typename _Base = BaseGraphComponent>
deba@2126
  1929
    class ErasableGraphComponent : public _Base {
deba@2126
  1930
    public:
deba@2126
  1931
deba@2126
  1932
      typedef _Base Base;
deba@2126
  1933
      typedef typename Base::Node Node;
deba@2126
  1934
      typedef typename Base::Edge Edge;
deba@2126
  1935
deba@2126
  1936
      /// \brief Erase a node from the graph.
deba@2126
  1937
      ///
deba@2126
  1938
      /// Erase a node from the graph. This function should 
deba@2126
  1939
      /// erase all edges connecting to the node.
deba@2126
  1940
      void erase(const Node&) {}    
deba@2126
  1941
deba@2126
  1942
      /// \brief Erase an edge from the graph.
deba@2126
  1943
      ///
deba@2126
  1944
      /// Erase an edge from the graph.
deba@2126
  1945
      ///
deba@2126
  1946
      void erase(const Edge&) {}
deba@2126
  1947
deba@2126
  1948
      template <typename _Graph>
deba@2126
  1949
      struct Constraints {
deba@2126
  1950
	void constraints() {
deba@2231
  1951
          checkConcept<Base, _Graph>();
deba@2126
  1952
	  typename _Graph::Node node;
deba@2126
  1953
	  graph.erase(node);
deba@2126
  1954
	  typename _Graph::Edge edge;
deba@2126
  1955
	  graph.erase(edge);
deba@2126
  1956
	}
deba@2126
  1957
deba@2126
  1958
	_Graph& graph;
deba@2126
  1959
      };
deba@2126
  1960
    };
deba@2126
  1961
deba@2126
  1962
    /// \brief An empty erasable base undirected graph class.
deba@2126
  1963
    ///  
deba@2126
  1964
    /// This class provides beside the core undirected graph features
deba@2126
  1965
    /// core erase functions for the undirceted graph structure. The
deba@2126
  1966
    /// main difference between the base and this interface is that
deba@2126
  1967
    /// the graph alterations should handled already on this level.
deba@2126
  1968
    template <typename _Base = BaseUGraphComponent>
deba@2126
  1969
    class ErasableUGraphComponent : public _Base {
deba@2126
  1970
    public:
deba@2126
  1971
deba@2126
  1972
      typedef _Base Base;
deba@2126
  1973
      typedef typename Base::Node Node;
deba@2126
  1974
      typedef typename Base::UEdge UEdge;
deba@2126
  1975
deba@2126
  1976
      /// \brief Erase a node from the graph.
deba@2126
  1977
      ///
deba@2126
  1978
      /// Erase a node from the graph. This function should erase
deba@2126
  1979
      /// edges connecting to the node.
deba@2126
  1980
      void erase(const Node&) {}    
deba@2126
  1981
deba@2126
  1982
      /// \brief Erase an edge from the graph.
deba@2126
  1983
      ///
deba@2126
  1984
      /// Erase an edge from the graph.
deba@2126
  1985
      ///
deba@2126
  1986
      void erase(const UEdge&) {}
deba@2126
  1987
deba@2126
  1988
      template <typename _Graph>
deba@2126
  1989
      struct Constraints {
deba@2126
  1990
	void constraints() {
deba@2231
  1991
          checkConcept<Base, _Graph>();
deba@2126
  1992
	  typename _Graph::Node node;
deba@2126
  1993
	  graph.erase(node);
deba@2126
  1994
	  typename _Graph::Edge edge;
deba@2126
  1995
	  graph.erase(edge);
deba@2126
  1996
	}
deba@2126
  1997
deba@2126
  1998
	_Graph& graph;
deba@2126
  1999
      };
deba@2126
  2000
    };
deba@2126
  2001
deba@2231
  2002
    /// \brief An empty erasable base bipartite undirected graph class.
deba@2231
  2003
    ///  
deba@2231
  2004
    /// This class provides beside the core bipartite undirected graph
deba@2231
  2005
    /// features core erase functions for the undirceted graph
deba@2231
  2006
    /// structure. The main difference between the base and this
deba@2231
  2007
    /// interface is that the graph alterations should handled already
deba@2231
  2008
    /// on this level.
deba@2231
  2009
    template <typename _Base = BaseBpUGraphComponent>
deba@2231
  2010
    class ErasableBpUGraphComponent : public ErasableUGraphComponent<_Base> {
deba@2231
  2011
    public:
deba@2231
  2012
deba@2231
  2013
      typedef _Base Base;
deba@2231
  2014
deba@2231
  2015
      template <typename _Graph>
deba@2231
  2016
      struct Constraints {
deba@2231
  2017
	void constraints() {
deba@2231
  2018
          checkConcept<ErasableUGraphComponent<Base>, _Graph>();
deba@2231
  2019
	}
deba@2231
  2020
      };
deba@2231
  2021
    };
deba@2231
  2022
deba@2126
  2023
    /// \brief An empty clearable base graph class.
deba@2126
  2024
    ///
deba@2126
  2025
    /// This class provides beside the core graph features core clear
deba@2126
  2026
    /// functions for the graph structure. The main difference between
deba@2126
  2027
    /// the base and this interface is that the graph alterations
deba@2126
  2028
    /// should handled already on this level.
deba@2126
  2029
    template <typename _Base = BaseGraphComponent>
deba@2126
  2030
    class ClearableGraphComponent : public _Base {
deba@2126
  2031
    public:
deba@2126
  2032
deba@2231
  2033
      typedef _Base Base;
deba@2231
  2034
deba@2126
  2035
      /// \brief Erase all nodes and edges from the graph.
deba@2126
  2036
      ///
deba@2126
  2037
      /// Erase all nodes and edges from the graph.
deba@2126
  2038
      ///
deba@2126
  2039
      void clear() {}    
deba@2126
  2040
deba@2126
  2041
      template <typename _Graph>
deba@2126
  2042
      struct Constraints {
deba@2126
  2043
	void constraints() {
deba@2231
  2044
          checkConcept<Base, _Graph>();
deba@2126
  2045
	  graph.clear();
deba@2126
  2046
	}
deba@2126
  2047
deba@2126
  2048
	_Graph graph;
deba@2126
  2049
      };
deba@2126
  2050
    };
deba@2126
  2051
deba@2126
  2052
    /// \brief An empty clearable base undirected graph class.
deba@2126
  2053
    ///
deba@2126
  2054
    /// This class provides beside the core undirected graph features
deba@2126
  2055
    /// core clear functions for the undirected graph structure. The
deba@2126
  2056
    /// main difference between the base and this interface is that
deba@2126
  2057
    /// the graph alterations should handled already on this level.
deba@2126
  2058
    template <typename _Base = BaseUGraphComponent>
deba@2231
  2059
    class ClearableUGraphComponent : public ClearableUGraphComponent<_Base> {
deba@2126
  2060
    public:
deba@2126
  2061
deba@2231
  2062
      typedef _Base Base;
deba@2126
  2063
deba@2126
  2064
      template <typename _Graph>
deba@2126
  2065
      struct Constraints {
deba@2126
  2066
	void constraints() {
deba@2231
  2067
          checkConcept<ClearableUGraphComponent<Base>, _Graph>();
deba@2126
  2068
	}
deba@2126
  2069
deba@2126
  2070
	_Graph graph;
deba@2126
  2071
      };
deba@2126
  2072
    };
deba@2126
  2073
deba@2231
  2074
    /// \brief An empty clearable base bipartite undirected graph
deba@2231
  2075
    /// class.
deba@2231
  2076
    ///
deba@2231
  2077
    /// This class provides beside the core bipartite undirected graph
deba@2231
  2078
    /// features core clear functions for the undirected graph
deba@2231
  2079
    /// structure. The main difference between the base and this
deba@2231
  2080
    /// interface is that the graph alterations should handled already
deba@2231
  2081
    /// on this level.
deba@2231
  2082
    template <typename _Base = BaseUGraphComponent>
deba@2231
  2083
    class ClearableBpUGraphComponent 
deba@2231
  2084
      : public ClearableBpUGraphComponent<_Base> {
deba@2231
  2085
    public:
deba@2231
  2086
deba@2231
  2087
      typedef _Base Base;
deba@2231
  2088
deba@2231
  2089
      template <typename _Graph>
deba@2231
  2090
      struct Constraints {
deba@2231
  2091
	void constraints() {
deba@2231
  2092
          checkConcept<ClearableBpUGraphComponent<Base>, _Graph>();
deba@2231
  2093
	}
deba@2231
  2094
deba@2231
  2095
      };
deba@2231
  2096
deba@2231
  2097
    };
deba@2231
  2098
deba@2126
  2099
  }
deba@2126
  2100
deba@2126
  2101
}
deba@2126
  2102
deba@2126
  2103
#endif