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