lemon/concept/bpugraph.h
author deba
Fri, 27 Jan 2006 08:18:47 +0000
changeset 1913 49fe71fce7fb
child 1933 a876a3d6a4c7
permissions -rw-r--r--
Making iterable bool map dynamic
Changed interface
deba@1911
     1
/* -*- C++ -*-
deba@1911
     2
 *
deba@1911
     3
 * lemon/concept/ugraph_component.h - Part of LEMON, a generic
deba@1911
     4
 * C++ optimization library
deba@1911
     5
 *
deba@1911
     6
 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi
deba@1911
     7
 * Kutatocsoport (Egervary Research Group on Combinatorial Optimization,
deba@1911
     8
 * EGRES).
deba@1911
     9
 *
deba@1911
    10
 * Permission to use, modify and distribute this software is granted
deba@1911
    11
 * provided that this copyright notice appears in all copies. For
deba@1911
    12
 * precise terms see the accompanying LICENSE file.
deba@1911
    13
 *
deba@1911
    14
 * This software is provided "AS IS" with no warranty of any kind,
deba@1911
    15
 * express or implied, and with no claim as to its suitability for any
deba@1911
    16
 * purpose.
deba@1911
    17
 *
deba@1911
    18
 */
deba@1911
    19
deba@1911
    20
/// \ingroup graph_concepts
deba@1911
    21
/// \file
deba@1911
    22
/// \brief Undirected bipartite graphs and components of.
deba@1911
    23
deba@1911
    24
deba@1911
    25
#ifndef LEMON_CONCEPT_BPUGRAPH_H
deba@1911
    26
#define LEMON_CONCEPT_BPUGRAPH_H
deba@1911
    27
deba@1911
    28
#include <lemon/concept/graph_component.h>
deba@1911
    29
deba@1911
    30
#include <lemon/concept/graph.h>
deba@1911
    31
#include <lemon/concept/ugraph.h>
deba@1911
    32
deba@1911
    33
#include <lemon/utility.h>
deba@1911
    34
deba@1911
    35
namespace lemon {
deba@1911
    36
  namespace concept {
deba@1911
    37
deba@1911
    38
    /// \addtogroup graph_concepts
deba@1911
    39
    /// @{
deba@1911
    40
deba@1911
    41
deba@1911
    42
    /// \brief Class describing the concept of Bipartite Undirected Graphs.
deba@1911
    43
    ///
deba@1911
    44
    /// This class describes the common interface of all 
deba@1911
    45
    /// Undirected Bipartite Graphs.
deba@1911
    46
    ///
deba@1911
    47
    /// As all concept describing classes it provides only interface
deba@1911
    48
    /// without any sensible implementation. So any algorithm for
deba@1911
    49
    /// bipartite undirected graph should compile with this class, but it 
deba@1911
    50
    /// will not run properly, of course.
deba@1911
    51
    ///
deba@1911
    52
    /// In LEMON bipartite undirected graphs also fulfill the concept of 
deba@1911
    53
    /// the undirected graphs (\ref lemon::concept::UGraph "UGraph Concept"). 
deba@1911
    54
    ///
deba@1911
    55
    /// You can assume that all undirected bipartite graph can be handled
deba@1911
    56
    /// as an undirected graph and consequently as a static graph.
deba@1911
    57
    ///
deba@1911
    58
    /// The bipartite graph stores two types of nodes which are named
deba@1911
    59
    /// ANode and BNode. Even so the graph type does not contain ANode
deba@1911
    60
    /// and BNode classes, becaue the nodes can be accessed just with the
deba@1911
    61
    /// common Node class. 
deba@1911
    62
    ///
deba@1911
    63
    /// The iteration on the partition can be done with the ANodeIt and 
deba@1911
    64
    /// BNodeIt classes. The node map can be used to map values to the nodes
deba@1911
    65
    /// and similarly we can use to map values for just the ANodes and
deba@1911
    66
    /// BNodes the ANodeMap and BNodeMap template classes.
deba@1911
    67
deba@1911
    68
    class BpUGraph {
deba@1911
    69
    public:
deba@1911
    70
      /// \todo undocumented
deba@1911
    71
      ///
deba@1911
    72
      typedef True UTag;
deba@1911
    73
deba@1911
    74
      /// \brief The base type of node iterators, 
deba@1911
    75
      /// or in other words, the trivial node iterator.
deba@1911
    76
      ///
deba@1911
    77
      /// This is the base type of each node iterator,
deba@1911
    78
      /// thus each kind of node iterator converts to this.
deba@1911
    79
      /// More precisely each kind of node iterator should be inherited 
deba@1911
    80
      /// from the trivial node iterator. The Node class represents
deba@1911
    81
      /// both of two types of nodes. 
deba@1911
    82
      class Node {
deba@1911
    83
      public:
deba@1911
    84
        /// Default constructor
deba@1911
    85
deba@1911
    86
        /// @warning The default constructor sets the iterator
deba@1911
    87
        /// to an undefined value.
deba@1911
    88
        Node() { }
deba@1911
    89
        /// Copy constructor.
deba@1911
    90
deba@1911
    91
        /// Copy constructor.
deba@1911
    92
        ///
deba@1911
    93
        Node(const Node&) { }
deba@1911
    94
deba@1911
    95
        /// Invalid constructor \& conversion.
deba@1911
    96
deba@1911
    97
        /// This constructor initializes the iterator to be invalid.
deba@1911
    98
        /// \sa Invalid for more details.
deba@1911
    99
        Node(Invalid) { }
deba@1911
   100
        /// Equality operator
deba@1911
   101
deba@1911
   102
        /// Two iterators are equal if and only if they point to the
deba@1911
   103
        /// same object or both are invalid.
deba@1911
   104
        bool operator==(Node) const { return true; }
deba@1911
   105
deba@1911
   106
        /// Inequality operator
deba@1911
   107
        
deba@1911
   108
        /// \sa operator==(Node n)
deba@1911
   109
        ///
deba@1911
   110
        bool operator!=(Node) const { return true; }
deba@1911
   111
deba@1911
   112
	/// Artificial ordering operator.
deba@1911
   113
	
deba@1911
   114
	/// To allow the use of graph descriptors as key type in std::map or
deba@1911
   115
	/// similar associative container we require this.
deba@1911
   116
	///
deba@1911
   117
	/// \note This operator only have to define some strict ordering of
deba@1911
   118
	/// the items; this order has nothing to do with the iteration
deba@1911
   119
	/// ordering of the items.
deba@1911
   120
	///
deba@1911
   121
	/// \bug This is a technical requirement. Do we really need this?
deba@1911
   122
	bool operator<(Node) const { return false; }
deba@1911
   123
deba@1911
   124
      };
deba@1911
   125
    
deba@1911
   126
      /// This iterator goes through each node.
deba@1911
   127
deba@1911
   128
      /// This iterator goes through each node.
deba@1911
   129
      /// Its usage is quite simple, for example you can count the number
deba@1911
   130
      /// of nodes in graph \c g of type \c Graph like this:
deba@1911
   131
      /// \code
deba@1911
   132
      /// int count=0;
deba@1911
   133
      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
deba@1911
   134
      /// \endcode
deba@1911
   135
      class NodeIt : public Node {
deba@1911
   136
      public:
deba@1911
   137
        /// Default constructor
deba@1911
   138
deba@1911
   139
        /// @warning The default constructor sets the iterator
deba@1911
   140
        /// to an undefined value.
deba@1911
   141
        NodeIt() { }
deba@1911
   142
        /// Copy constructor.
deba@1911
   143
        
deba@1911
   144
        /// Copy constructor.
deba@1911
   145
        ///
deba@1911
   146
        NodeIt(const NodeIt& n) : Node(n) { }
deba@1911
   147
        /// Invalid constructor \& conversion.
deba@1911
   148
deba@1911
   149
        /// Initialize the iterator to be invalid.
deba@1911
   150
        /// \sa Invalid for more details.
deba@1911
   151
        NodeIt(Invalid) { }
deba@1911
   152
        /// Sets the iterator to the first node.
deba@1911
   153
deba@1911
   154
        /// Sets the iterator to the first node of \c g.
deba@1911
   155
        ///
deba@1911
   156
        NodeIt(const BpUGraph&) { }
deba@1911
   157
        /// Node -> NodeIt conversion.
deba@1911
   158
deba@1911
   159
        /// Sets the iterator to the node of \c the graph pointed by 
deba@1911
   160
	/// the trivial iterator.
deba@1911
   161
        /// This feature necessitates that each time we 
deba@1911
   162
        /// iterate the edge-set, the iteration order is the same.
deba@1911
   163
        NodeIt(const BpUGraph&, const Node&) { }
deba@1911
   164
        /// Next node.
deba@1911
   165
deba@1911
   166
        /// Assign the iterator to the next node.
deba@1911
   167
        ///
deba@1911
   168
        NodeIt& operator++() { return *this; }
deba@1911
   169
      };
deba@1911
   170
deba@1911
   171
      /// This iterator goes through each ANode.
deba@1911
   172
deba@1911
   173
      /// This iterator goes through each ANode.
deba@1911
   174
      /// Its usage is quite simple, for example you can count the number
deba@1911
   175
      /// of nodes in graph \c g of type \c Graph like this:
deba@1911
   176
      /// \code
deba@1911
   177
      /// int count=0;
deba@1911
   178
      /// for (Graph::ANodeIt n(g); n!=INVALID; ++n) ++count;
deba@1911
   179
      /// \endcode
deba@1911
   180
      class ANodeIt : public Node {
deba@1911
   181
      public:
deba@1911
   182
        /// Default constructor
deba@1911
   183
deba@1911
   184
        /// @warning The default constructor sets the iterator
deba@1911
   185
        /// to an undefined value.
deba@1911
   186
        ANodeIt() { }
deba@1911
   187
        /// Copy constructor.
deba@1911
   188
        
deba@1911
   189
        /// Copy constructor.
deba@1911
   190
        ///
deba@1911
   191
        ANodeIt(const ANodeIt& n) : Node(n) { }
deba@1911
   192
        /// Invalid constructor \& conversion.
deba@1911
   193
deba@1911
   194
        /// Initialize the iterator to be invalid.
deba@1911
   195
        /// \sa Invalid for more details.
deba@1911
   196
        ANodeIt(Invalid) { }
deba@1911
   197
        /// Sets the iterator to the first node.
deba@1911
   198
deba@1911
   199
        /// Sets the iterator to the first node of \c g.
deba@1911
   200
        ///
deba@1911
   201
        ANodeIt(const BpUGraph&) { }
deba@1911
   202
        /// Node -> ANodeIt conversion.
deba@1911
   203
deba@1911
   204
        /// Sets the iterator to the node of \c the graph pointed by 
deba@1911
   205
	/// the trivial iterator.
deba@1911
   206
        /// This feature necessitates that each time we 
deba@1911
   207
        /// iterate the edge-set, the iteration order is the same.
deba@1911
   208
        ANodeIt(const BpUGraph&, const Node&) { }
deba@1911
   209
        /// Next node.
deba@1911
   210
deba@1911
   211
        /// Assign the iterator to the next node.
deba@1911
   212
        ///
deba@1911
   213
        ANodeIt& operator++() { return *this; }
deba@1911
   214
      };
deba@1911
   215
deba@1911
   216
      /// This iterator goes through each BNode.
deba@1911
   217
deba@1911
   218
      /// This iterator goes through each BNode.
deba@1911
   219
      /// Its usage is quite simple, for example you can count the number
deba@1911
   220
      /// of nodes in graph \c g of type \c Graph like this:
deba@1911
   221
      /// \code
deba@1911
   222
      /// int count=0;
deba@1911
   223
      /// for (Graph::BNodeIt n(g); n!=INVALID; ++n) ++count;
deba@1911
   224
      /// \endcode
deba@1911
   225
      class BNodeIt : public Node {
deba@1911
   226
      public:
deba@1911
   227
        /// Default constructor
deba@1911
   228
deba@1911
   229
        /// @warning The default constructor sets the iterator
deba@1911
   230
        /// to an undefined value.
deba@1911
   231
        BNodeIt() { }
deba@1911
   232
        /// Copy constructor.
deba@1911
   233
        
deba@1911
   234
        /// Copy constructor.
deba@1911
   235
        ///
deba@1911
   236
        BNodeIt(const BNodeIt& n) : Node(n) { }
deba@1911
   237
        /// Invalid constructor \& conversion.
deba@1911
   238
deba@1911
   239
        /// Initialize the iterator to be invalid.
deba@1911
   240
        /// \sa Invalid for more details.
deba@1911
   241
        BNodeIt(Invalid) { }
deba@1911
   242
        /// Sets the iterator to the first node.
deba@1911
   243
deba@1911
   244
        /// Sets the iterator to the first node of \c g.
deba@1911
   245
        ///
deba@1911
   246
        BNodeIt(const BpUGraph&) { }
deba@1911
   247
        /// Node -> BNodeIt conversion.
deba@1911
   248
deba@1911
   249
        /// Sets the iterator to the node of \c the graph pointed by 
deba@1911
   250
	/// the trivial iterator.
deba@1911
   251
        /// This feature necessitates that each time we 
deba@1911
   252
        /// iterate the edge-set, the iteration order is the same.
deba@1911
   253
        BNodeIt(const BpUGraph&, const Node&) { }
deba@1911
   254
        /// Next node.
deba@1911
   255
deba@1911
   256
        /// Assign the iterator to the next node.
deba@1911
   257
        ///
deba@1911
   258
        BNodeIt& operator++() { return *this; }
deba@1911
   259
      };
deba@1911
   260
    
deba@1911
   261
    
deba@1911
   262
      /// The base type of the undirected edge iterators.
deba@1911
   263
deba@1911
   264
      /// The base type of the undirected edge iterators.
deba@1911
   265
      ///
deba@1911
   266
      class UEdge {
deba@1911
   267
      public:
deba@1911
   268
        /// Default constructor
deba@1911
   269
deba@1911
   270
        /// @warning The default constructor sets the iterator
deba@1911
   271
        /// to an undefined value.
deba@1911
   272
        UEdge() { }
deba@1911
   273
        /// Copy constructor.
deba@1911
   274
deba@1911
   275
        /// Copy constructor.
deba@1911
   276
        ///
deba@1911
   277
        UEdge(const UEdge&) { }
deba@1911
   278
        /// Initialize the iterator to be invalid.
deba@1911
   279
deba@1911
   280
        /// Initialize the iterator to be invalid.
deba@1911
   281
        ///
deba@1911
   282
        UEdge(Invalid) { }
deba@1911
   283
        /// Equality operator
deba@1911
   284
deba@1911
   285
        /// Two iterators are equal if and only if they point to the
deba@1911
   286
        /// same object or both are invalid.
deba@1911
   287
        bool operator==(UEdge) const { return true; }
deba@1911
   288
        /// Inequality operator
deba@1911
   289
deba@1911
   290
        /// \sa operator==(UEdge n)
deba@1911
   291
        ///
deba@1911
   292
        bool operator!=(UEdge) const { return true; }
deba@1911
   293
deba@1911
   294
	/// Artificial ordering operator.
deba@1911
   295
	
deba@1911
   296
	/// To allow the use of graph descriptors as key type in std::map or
deba@1911
   297
	/// similar associative container we require this.
deba@1911
   298
	///
deba@1911
   299
	/// \note This operator only have to define some strict ordering of
deba@1911
   300
	/// the items; this order has nothing to do with the iteration
deba@1911
   301
	/// ordering of the items.
deba@1911
   302
	///
deba@1911
   303
	/// \bug This is a technical requirement. Do we really need this?
deba@1911
   304
	bool operator<(UEdge) const { return false; }
deba@1911
   305
      };
deba@1911
   306
deba@1911
   307
      /// This iterator goes through each undirected edge.
deba@1911
   308
deba@1911
   309
      /// This iterator goes through each undirected edge of a graph.
deba@1911
   310
      /// Its usage is quite simple, for example you can count the number
deba@1911
   311
      /// of undirected edges in a graph \c g of type \c Graph as follows:
deba@1911
   312
      /// \code
deba@1911
   313
      /// int count=0;
deba@1911
   314
      /// for(Graph::UEdgeIt e(g); e!=INVALID; ++e) ++count;
deba@1911
   315
      /// \endcode
deba@1911
   316
      class UEdgeIt : public UEdge {
deba@1911
   317
      public:
deba@1911
   318
        /// Default constructor
deba@1911
   319
deba@1911
   320
        /// @warning The default constructor sets the iterator
deba@1911
   321
        /// to an undefined value.
deba@1911
   322
        UEdgeIt() { }
deba@1911
   323
        /// Copy constructor.
deba@1911
   324
deba@1911
   325
        /// Copy constructor.
deba@1911
   326
        ///
deba@1911
   327
        UEdgeIt(const UEdgeIt& e) : UEdge(e) { }
deba@1911
   328
        /// Initialize the iterator to be invalid.
deba@1911
   329
deba@1911
   330
        /// Initialize the iterator to be invalid.
deba@1911
   331
        ///
deba@1911
   332
        UEdgeIt(Invalid) { }
deba@1911
   333
        /// This constructor sets the iterator to the first undirected edge.
deba@1911
   334
    
deba@1911
   335
        /// This constructor sets the iterator to the first undirected edge.
deba@1911
   336
        UEdgeIt(const BpUGraph&) { }
deba@1911
   337
        /// UEdge -> UEdgeIt conversion
deba@1911
   338
deba@1911
   339
        /// Sets the iterator to the value of the trivial iterator.
deba@1911
   340
        /// This feature necessitates that each time we
deba@1911
   341
        /// iterate the undirected edge-set, the iteration order is the 
deba@1911
   342
	/// same.
deba@1911
   343
        UEdgeIt(const BpUGraph&, const UEdge&) { } 
deba@1911
   344
        /// Next undirected edge
deba@1911
   345
        
deba@1911
   346
        /// Assign the iterator to the next undirected edge.
deba@1911
   347
        UEdgeIt& operator++() { return *this; }
deba@1911
   348
      };
deba@1911
   349
deba@1911
   350
      /// \brief This iterator goes trough the incident undirected 
deba@1911
   351
      /// edges of a node.
deba@1911
   352
      ///
deba@1911
   353
      /// This iterator goes trough the incident undirected edges
deba@1911
   354
      /// of a certain node
deba@1911
   355
      /// of a graph.
deba@1911
   356
      /// Its usage is quite simple, for example you can compute the
deba@1911
   357
      /// degree (i.e. count the number
deba@1911
   358
      /// of incident edges of a node \c n
deba@1911
   359
      /// in graph \c g of type \c Graph as follows.
deba@1911
   360
      /// \code
deba@1911
   361
      /// int count=0;
deba@1911
   362
      /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1911
   363
      /// \endcode
deba@1911
   364
      class IncEdgeIt : public UEdge {
deba@1911
   365
      public:
deba@1911
   366
        /// Default constructor
deba@1911
   367
deba@1911
   368
        /// @warning The default constructor sets the iterator
deba@1911
   369
        /// to an undefined value.
deba@1911
   370
        IncEdgeIt() { }
deba@1911
   371
        /// Copy constructor.
deba@1911
   372
deba@1911
   373
        /// Copy constructor.
deba@1911
   374
        ///
deba@1911
   375
        IncEdgeIt(const IncEdgeIt& e) : UEdge(e) { }
deba@1911
   376
        /// Initialize the iterator to be invalid.
deba@1911
   377
deba@1911
   378
        /// Initialize the iterator to be invalid.
deba@1911
   379
        ///
deba@1911
   380
        IncEdgeIt(Invalid) { }
deba@1911
   381
        /// This constructor sets the iterator to first incident edge.
deba@1911
   382
    
deba@1911
   383
        /// This constructor set the iterator to the first incident edge of
deba@1911
   384
        /// the node.
deba@1911
   385
        IncEdgeIt(const BpUGraph&, const Node&) { }
deba@1911
   386
        /// UEdge -> IncEdgeIt conversion
deba@1911
   387
deba@1911
   388
        /// Sets the iterator to the value of the trivial iterator \c e.
deba@1911
   389
        /// This feature necessitates that each time we 
deba@1911
   390
        /// iterate the edge-set, the iteration order is the same.
deba@1911
   391
        IncEdgeIt(const BpUGraph&, const UEdge&) { }
deba@1911
   392
        /// Next incident edge
deba@1911
   393
deba@1911
   394
        /// Assign the iterator to the next incident edge
deba@1911
   395
	/// of the corresponding node.
deba@1911
   396
        IncEdgeIt& operator++() { return *this; }
deba@1911
   397
      };
deba@1911
   398
deba@1911
   399
      /// The directed edge type.
deba@1911
   400
deba@1911
   401
      /// The directed edge type. It can be converted to the
deba@1911
   402
      /// undirected edge.
deba@1911
   403
      class Edge : public UEdge {
deba@1911
   404
      public:
deba@1911
   405
        /// Default constructor
deba@1911
   406
deba@1911
   407
        /// @warning The default constructor sets the iterator
deba@1911
   408
        /// to an undefined value.
deba@1911
   409
        Edge() { }
deba@1911
   410
        /// Copy constructor.
deba@1911
   411
deba@1911
   412
        /// Copy constructor.
deba@1911
   413
        ///
deba@1911
   414
        Edge(const Edge& e) : UEdge(e) { }
deba@1911
   415
        /// Initialize the iterator to be invalid.
deba@1911
   416
deba@1911
   417
        /// Initialize the iterator to be invalid.
deba@1911
   418
        ///
deba@1911
   419
        Edge(Invalid) { }
deba@1911
   420
        /// Equality operator
deba@1911
   421
deba@1911
   422
        /// Two iterators are equal if and only if they point to the
deba@1911
   423
        /// same object or both are invalid.
deba@1911
   424
        bool operator==(Edge) const { return true; }
deba@1911
   425
        /// Inequality operator
deba@1911
   426
deba@1911
   427
        /// \sa operator==(Edge n)
deba@1911
   428
        ///
deba@1911
   429
        bool operator!=(Edge) const { return true; }
deba@1911
   430
deba@1911
   431
	/// Artificial ordering operator.
deba@1911
   432
	
deba@1911
   433
	/// To allow the use of graph descriptors as key type in std::map or
deba@1911
   434
	/// similar associative container we require this.
deba@1911
   435
	///
deba@1911
   436
	/// \note This operator only have to define some strict ordering of
deba@1911
   437
	/// the items; this order has nothing to do with the iteration
deba@1911
   438
	/// ordering of the items.
deba@1911
   439
	///
deba@1911
   440
	/// \bug This is a technical requirement. Do we really need this?
deba@1911
   441
	bool operator<(Edge) const { return false; }
deba@1911
   442
	
deba@1911
   443
      }; 
deba@1911
   444
      /// This iterator goes through each directed edge.
deba@1911
   445
deba@1911
   446
      /// This iterator goes through each edge of a graph.
deba@1911
   447
      /// Its usage is quite simple, for example you can count the number
deba@1911
   448
      /// of edges in a graph \c g of type \c Graph as follows:
deba@1911
   449
      /// \code
deba@1911
   450
      /// int count=0;
deba@1911
   451
      /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
deba@1911
   452
      /// \endcode
deba@1911
   453
      class EdgeIt : public Edge {
deba@1911
   454
      public:
deba@1911
   455
        /// Default constructor
deba@1911
   456
deba@1911
   457
        /// @warning The default constructor sets the iterator
deba@1911
   458
        /// to an undefined value.
deba@1911
   459
        EdgeIt() { }
deba@1911
   460
        /// Copy constructor.
deba@1911
   461
deba@1911
   462
        /// Copy constructor.
deba@1911
   463
        ///
deba@1911
   464
        EdgeIt(const EdgeIt& e) : Edge(e) { }
deba@1911
   465
        /// Initialize the iterator to be invalid.
deba@1911
   466
deba@1911
   467
        /// Initialize the iterator to be invalid.
deba@1911
   468
        ///
deba@1911
   469
        EdgeIt(Invalid) { }
deba@1911
   470
        /// This constructor sets the iterator to the first edge.
deba@1911
   471
    
deba@1911
   472
        /// This constructor sets the iterator to the first edge of \c g.
deba@1911
   473
        ///@param g the graph
deba@1911
   474
        EdgeIt(const BpUGraph &g) { ignore_unused_variable_warning(g); }
deba@1911
   475
        /// Edge -> EdgeIt conversion
deba@1911
   476
deba@1911
   477
        /// Sets the iterator to the value of the trivial iterator \c e.
deba@1911
   478
        /// This feature necessitates that each time we 
deba@1911
   479
        /// iterate the edge-set, the iteration order is the same.
deba@1911
   480
        EdgeIt(const BpUGraph&, const Edge&) { } 
deba@1911
   481
        ///Next edge
deba@1911
   482
        
deba@1911
   483
        /// Assign the iterator to the next edge.
deba@1911
   484
        EdgeIt& operator++() { return *this; }
deba@1911
   485
      };
deba@1911
   486
   
deba@1911
   487
      /// This iterator goes trough the outgoing directed edges of a node.
deba@1911
   488
deba@1911
   489
      /// This iterator goes trough the \e outgoing edges of a certain node
deba@1911
   490
      /// of a graph.
deba@1911
   491
      /// Its usage is quite simple, for example you can count the number
deba@1911
   492
      /// of outgoing edges of a node \c n
deba@1911
   493
      /// in graph \c g of type \c Graph as follows.
deba@1911
   494
      /// \code
deba@1911
   495
      /// int count=0;
deba@1911
   496
      /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1911
   497
      /// \endcode
deba@1911
   498
    
deba@1911
   499
      class OutEdgeIt : public Edge {
deba@1911
   500
      public:
deba@1911
   501
        /// Default constructor
deba@1911
   502
deba@1911
   503
        /// @warning The default constructor sets the iterator
deba@1911
   504
        /// to an undefined value.
deba@1911
   505
        OutEdgeIt() { }
deba@1911
   506
        /// Copy constructor.
deba@1911
   507
deba@1911
   508
        /// Copy constructor.
deba@1911
   509
        ///
deba@1911
   510
        OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
deba@1911
   511
        /// Initialize the iterator to be invalid.
deba@1911
   512
deba@1911
   513
        /// Initialize the iterator to be invalid.
deba@1911
   514
        ///
deba@1911
   515
        OutEdgeIt(Invalid) { }
deba@1911
   516
        /// This constructor sets the iterator to the first outgoing edge.
deba@1911
   517
    
deba@1911
   518
        /// This constructor sets the iterator to the first outgoing edge of
deba@1911
   519
        /// the node.
deba@1911
   520
        ///@param n the node
deba@1911
   521
        ///@param g the graph
deba@1911
   522
        OutEdgeIt(const BpUGraph& n, const Node& g) {
deba@1911
   523
	  ignore_unused_variable_warning(n);
deba@1911
   524
	  ignore_unused_variable_warning(g);
deba@1911
   525
	}
deba@1911
   526
        /// Edge -> OutEdgeIt conversion
deba@1911
   527
deba@1911
   528
        /// Sets the iterator to the value of the trivial iterator.
deba@1911
   529
	/// This feature necessitates that each time we 
deba@1911
   530
        /// iterate the edge-set, the iteration order is the same.
deba@1911
   531
        OutEdgeIt(const BpUGraph&, const Edge&) { }
deba@1911
   532
        ///Next outgoing edge
deba@1911
   533
        
deba@1911
   534
        /// Assign the iterator to the next 
deba@1911
   535
        /// outgoing edge of the corresponding node.
deba@1911
   536
        OutEdgeIt& operator++() { return *this; }
deba@1911
   537
      };
deba@1911
   538
deba@1911
   539
      /// This iterator goes trough the incoming directed edges of a node.
deba@1911
   540
deba@1911
   541
      /// This iterator goes trough the \e incoming edges of a certain node
deba@1911
   542
      /// of a graph.
deba@1911
   543
      /// Its usage is quite simple, for example you can count the number
deba@1911
   544
      /// of outgoing edges of a node \c n
deba@1911
   545
      /// in graph \c g of type \c Graph as follows.
deba@1911
   546
      /// \code
deba@1911
   547
      /// int count=0;
deba@1911
   548
      /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
deba@1911
   549
      /// \endcode
deba@1911
   550
deba@1911
   551
      class InEdgeIt : public Edge {
deba@1911
   552
      public:
deba@1911
   553
        /// Default constructor
deba@1911
   554
deba@1911
   555
        /// @warning The default constructor sets the iterator
deba@1911
   556
        /// to an undefined value.
deba@1911
   557
        InEdgeIt() { }
deba@1911
   558
        /// Copy constructor.
deba@1911
   559
deba@1911
   560
        /// Copy constructor.
deba@1911
   561
        ///
deba@1911
   562
        InEdgeIt(const InEdgeIt& e) : Edge(e) { }
deba@1911
   563
        /// Initialize the iterator to be invalid.
deba@1911
   564
deba@1911
   565
        /// Initialize the iterator to be invalid.
deba@1911
   566
        ///
deba@1911
   567
        InEdgeIt(Invalid) { }
deba@1911
   568
        /// This constructor sets the iterator to first incoming edge.
deba@1911
   569
    
deba@1911
   570
        /// This constructor set the iterator to the first incoming edge of
deba@1911
   571
        /// the node.
deba@1911
   572
        ///@param n the node
deba@1911
   573
        ///@param g the graph
deba@1911
   574
        InEdgeIt(const BpUGraph& g, const Node& n) { 
deba@1911
   575
	  ignore_unused_variable_warning(n);
deba@1911
   576
	  ignore_unused_variable_warning(g);
deba@1911
   577
	}
deba@1911
   578
        /// Edge -> InEdgeIt conversion
deba@1911
   579
deba@1911
   580
        /// Sets the iterator to the value of the trivial iterator \c e.
deba@1911
   581
        /// This feature necessitates that each time we 
deba@1911
   582
        /// iterate the edge-set, the iteration order is the same.
deba@1911
   583
        InEdgeIt(const BpUGraph&, const Edge&) { }
deba@1911
   584
        /// Next incoming edge
deba@1911
   585
deba@1911
   586
        /// Assign the iterator to the next inedge of the corresponding node.
deba@1911
   587
        ///
deba@1911
   588
        InEdgeIt& operator++() { return *this; }
deba@1911
   589
      };
deba@1911
   590
deba@1911
   591
      /// \brief Read write map of the nodes to type \c T.
deba@1911
   592
      /// 
deba@1911
   593
      /// ReadWrite map of the nodes to type \c T.
deba@1911
   594
      /// \sa Reference
deba@1911
   595
      /// \warning Making maps that can handle bool type (NodeMap<bool>)
deba@1911
   596
      /// needs some extra attention!
deba@1911
   597
      /// \todo Wrong documentation
deba@1911
   598
      template<class T> 
deba@1911
   599
      class NodeMap : public ReadWriteMap< Node, T >
deba@1911
   600
      {
deba@1911
   601
      public:
deba@1911
   602
deba@1911
   603
        ///\e
deba@1911
   604
        NodeMap(const BpUGraph&) { }
deba@1911
   605
        ///\e
deba@1911
   606
        NodeMap(const BpUGraph&, T) { }
deba@1911
   607
deba@1911
   608
        ///Copy constructor
deba@1911
   609
        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
deba@1911
   610
        ///Assignment operator
deba@1911
   611
        NodeMap& operator=(const NodeMap&) { return *this; }
deba@1911
   612
        // \todo fix this concept
deba@1911
   613
      };
deba@1911
   614
deba@1911
   615
      /// \brief Read write map of the ANodes to type \c T.
deba@1911
   616
      /// 
deba@1911
   617
      /// ReadWrite map of the ANodes to type \c T.
deba@1911
   618
      /// \sa Reference
deba@1911
   619
      /// \warning Making maps that can handle bool type (NodeMap<bool>)
deba@1911
   620
      /// needs some extra attention!
deba@1911
   621
      /// \todo Wrong documentation
deba@1911
   622
      template<class T> 
deba@1911
   623
      class ANodeMap : public ReadWriteMap< Node, T >
deba@1911
   624
      {
deba@1911
   625
      public:
deba@1911
   626
deba@1911
   627
        ///\e
deba@1911
   628
        ANodeMap(const BpUGraph&) { }
deba@1911
   629
        ///\e
deba@1911
   630
        ANodeMap(const BpUGraph&, T) { }
deba@1911
   631
deba@1911
   632
        ///Copy constructor
deba@1911
   633
        ANodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
deba@1911
   634
        ///Assignment operator
deba@1911
   635
        ANodeMap& operator=(const NodeMap&) { return *this; }
deba@1911
   636
        // \todo fix this concept
deba@1911
   637
      };
deba@1911
   638
deba@1911
   639
      /// \brief Read write map of the BNodes to type \c T.
deba@1911
   640
      /// 
deba@1911
   641
      /// ReadWrite map of the BNodes to type \c T.
deba@1911
   642
      /// \sa Reference
deba@1911
   643
      /// \warning Making maps that can handle bool type (NodeMap<bool>)
deba@1911
   644
      /// needs some extra attention!
deba@1911
   645
      /// \todo Wrong documentation
deba@1911
   646
      template<class T> 
deba@1911
   647
      class BNodeMap : public ReadWriteMap< Node, T >
deba@1911
   648
      {
deba@1911
   649
      public:
deba@1911
   650
deba@1911
   651
        ///\e
deba@1911
   652
        BNodeMap(const BpUGraph&) { }
deba@1911
   653
        ///\e
deba@1911
   654
        BNodeMap(const BpUGraph&, T) { }
deba@1911
   655
deba@1911
   656
        ///Copy constructor
deba@1911
   657
        BNodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
deba@1911
   658
        ///Assignment operator
deba@1911
   659
        BNodeMap& operator=(const NodeMap&) { return *this; }
deba@1911
   660
        // \todo fix this concept
deba@1911
   661
      };
deba@1911
   662
deba@1911
   663
      /// \brief Read write map of the directed edges to type \c T.
deba@1911
   664
      ///
deba@1911
   665
      /// Reference map of the directed edges to type \c T.
deba@1911
   666
      /// \sa Reference
deba@1911
   667
      /// \warning Making maps that can handle bool type (EdgeMap<bool>)
deba@1911
   668
      /// needs some extra attention!
deba@1911
   669
      /// \todo Wrong documentation
deba@1911
   670
      template<class T> 
deba@1911
   671
      class EdgeMap : public ReadWriteMap<Edge,T>
deba@1911
   672
      {
deba@1911
   673
      public:
deba@1911
   674
deba@1911
   675
        ///\e
deba@1911
   676
        EdgeMap(const BpUGraph&) { }
deba@1911
   677
        ///\e
deba@1911
   678
        EdgeMap(const BpUGraph&, T) { }
deba@1911
   679
        ///Copy constructor
deba@1911
   680
        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
deba@1911
   681
        ///Assignment operator
deba@1911
   682
        EdgeMap& operator=(const EdgeMap&) { return *this; }
deba@1911
   683
        // \todo fix this concept    
deba@1911
   684
      };
deba@1911
   685
deba@1911
   686
      /// Read write map of the undirected edges to type \c T.
deba@1911
   687
deba@1911
   688
      /// Reference map of the edges to type \c T.
deba@1911
   689
      /// \sa Reference
deba@1911
   690
      /// \warning Making maps that can handle bool type (UEdgeMap<bool>)
deba@1911
   691
      /// needs some extra attention!
deba@1911
   692
      /// \todo Wrong documentation
deba@1911
   693
      template<class T> 
deba@1911
   694
      class UEdgeMap : public ReadWriteMap<UEdge,T>
deba@1911
   695
      {
deba@1911
   696
      public:
deba@1911
   697
deba@1911
   698
        ///\e
deba@1911
   699
        UEdgeMap(const BpUGraph&) { }
deba@1911
   700
        ///\e
deba@1911
   701
        UEdgeMap(const BpUGraph&, T) { }
deba@1911
   702
        ///Copy constructor
deba@1911
   703
        UEdgeMap(const UEdgeMap& em) : ReadWriteMap<UEdge,T>(em) {}
deba@1911
   704
        ///Assignment operator
deba@1911
   705
        UEdgeMap &operator=(const UEdgeMap&) { return *this; }
deba@1911
   706
        // \todo fix this concept    
deba@1911
   707
      };
deba@1911
   708
deba@1911
   709
      /// \brief Direct the given undirected edge.
deba@1911
   710
      ///
deba@1911
   711
      /// Direct the given undirected edge. The returned edge source
deba@1911
   712
      /// will be the given edge.
deba@1911
   713
      Edge direct(const UEdge&, const Node&) const {
deba@1911
   714
	return INVALID;
deba@1911
   715
      }
deba@1911
   716
deba@1911
   717
      /// \brief Direct the given undirected edge.
deba@1911
   718
      ///
deba@1911
   719
      /// Direct the given undirected edge. The returned edge source
deba@1911
   720
      /// will be the source of the undirected edge if the given bool
deba@1911
   721
      /// is true.
deba@1911
   722
      Edge direct(const UEdge&, bool) const {
deba@1911
   723
	return INVALID;
deba@1911
   724
      }
deba@1911
   725
deba@1911
   726
      /// \brief Returns true when the given node is an ANode.
deba@1911
   727
      ///
deba@1911
   728
      /// Returns true when the given node is an ANode.
deba@1911
   729
      bool aNode(Node) const { return true;}
deba@1911
   730
deba@1911
   731
      /// \brief Returns true when the given node is an BNode.
deba@1911
   732
      ///
deba@1911
   733
      /// Returns true when the given node is an BNode.
deba@1911
   734
      bool bNode(Node) const { return true;}
deba@1911
   735
deba@1911
   736
      /// \brief Returns the edge's end node which is in the ANode set.
deba@1911
   737
      ///
deba@1911
   738
      /// Returns the edge's end node which is in the ANode set.
deba@1911
   739
      Node aNode(UEdge) const { return INVALID;}
deba@1911
   740
deba@1911
   741
      /// \brief Returns the edge's end node which is in the BNode set.
deba@1911
   742
      ///
deba@1911
   743
      /// Returns the edge's end node which is in the BNode set.
deba@1911
   744
      Node bNode(UEdge) const { return INVALID;}
deba@1911
   745
deba@1911
   746
      /// \brief Returns true if the edge has default orientation.
deba@1911
   747
      ///
deba@1911
   748
      /// Returns whether the given directed edge is same orientation as
deba@1911
   749
      /// the corresponding undirected edge.
deba@1911
   750
      bool direction(Edge) const { return true; }
deba@1911
   751
deba@1911
   752
      /// \brief Returns the opposite directed edge.
deba@1911
   753
      ///
deba@1911
   754
      /// Returns the opposite directed edge.
deba@1911
   755
      Edge oppositeEdge(Edge) const { return INVALID; }
deba@1911
   756
deba@1911
   757
      /// \brief Opposite node on an edge
deba@1911
   758
      ///
deba@1911
   759
      /// \return the opposite of the given Node on the given Edge
deba@1911
   760
      Node oppositeNode(Node, UEdge) const { return INVALID; }
deba@1911
   761
deba@1911
   762
      /// \brief First node of the undirected edge.
deba@1911
   763
      ///
deba@1911
   764
      /// \return the first node of the given UEdge.
deba@1911
   765
      ///
deba@1911
   766
      /// Naturally uectected edges don't have direction and thus
deba@1911
   767
      /// don't have source and target node. But we use these two methods
deba@1911
   768
      /// to query the two endnodes of the edge. The direction of the edge
deba@1911
   769
      /// which arises this way is called the inherent direction of the
deba@1911
   770
      /// undirected edge, and is used to define the "default" direction
deba@1911
   771
      /// of the directed versions of the edges.
deba@1911
   772
      /// \sa direction
deba@1911
   773
      Node source(UEdge) const { return INVALID; }
deba@1911
   774
deba@1911
   775
      /// \brief Second node of the undirected edge.
deba@1911
   776
      Node target(UEdge) const { return INVALID; }
deba@1911
   777
deba@1911
   778
      /// \brief Source node of the directed edge.
deba@1911
   779
      Node source(Edge) const { return INVALID; }
deba@1911
   780
deba@1911
   781
      /// \brief Target node of the directed edge.
deba@1911
   782
      Node target(Edge) const { return INVALID; }
deba@1911
   783
deba@1911
   784
      /// \brief Base node of the iterator
deba@1911
   785
      ///
deba@1911
   786
      /// Returns the base node (the source in this case) of the iterator
deba@1911
   787
      Node baseNode(OutEdgeIt e) const {
deba@1911
   788
	return source(e);
deba@1911
   789
      }
deba@1911
   790
deba@1911
   791
      /// \brief Running node of the iterator
deba@1911
   792
      ///
deba@1911
   793
      /// Returns the running node (the target in this case) of the
deba@1911
   794
      /// iterator
deba@1911
   795
      Node runningNode(OutEdgeIt e) const {
deba@1911
   796
	return target(e);
deba@1911
   797
      }
deba@1911
   798
deba@1911
   799
      /// \brief Base node of the iterator
deba@1911
   800
      ///
deba@1911
   801
      /// Returns the base node (the target in this case) of the iterator
deba@1911
   802
      Node baseNode(InEdgeIt e) const {
deba@1911
   803
	return target(e);
deba@1911
   804
      }
deba@1911
   805
      /// \brief Running node of the iterator
deba@1911
   806
      ///
deba@1911
   807
      /// Returns the running node (the source in this case) of the
deba@1911
   808
      /// iterator
deba@1911
   809
      Node runningNode(InEdgeIt e) const {
deba@1911
   810
	return source(e);
deba@1911
   811
      }
deba@1911
   812
deba@1911
   813
      /// \brief Base node of the iterator
deba@1911
   814
      ///
deba@1911
   815
      /// Returns the base node of the iterator
deba@1911
   816
      Node baseNode(IncEdgeIt) const {
deba@1911
   817
	return INVALID;
deba@1911
   818
      }
deba@1911
   819
      
deba@1911
   820
      /// \brief Running node of the iterator
deba@1911
   821
      ///
deba@1911
   822
      /// Returns the running node of the iterator
deba@1911
   823
      Node runningNode(IncEdgeIt) const {
deba@1911
   824
	return INVALID;
deba@1911
   825
      }
deba@1911
   826
deba@1911
   827
      template <typename Graph>
deba@1911
   828
      struct Constraints {
deba@1911
   829
	void constraints() {
deba@1911
   830
	}
deba@1911
   831
      };
deba@1911
   832
deba@1911
   833
    };
deba@1911
   834
deba@1911
   835
    /// \brief An empty non-static undirected graph class.
deba@1911
   836
    ///    
deba@1911
   837
    /// This class provides everything that \ref BpUGraph does.
deba@1911
   838
    /// Additionally it enables building graphs from scratch.
deba@1911
   839
    class ExtendableBpUGraph : public BpUGraph {
deba@1911
   840
    public:
deba@1911
   841
      
deba@1911
   842
      /// \brief Add a new ANode to the graph.
deba@1911
   843
      ///
deba@1911
   844
      /// Add a new ANode to the graph.
deba@1911
   845
      /// \return the new node.
deba@1911
   846
      Node addANode();
deba@1911
   847
deba@1911
   848
      /// \brief Add a new ANode to the graph.
deba@1911
   849
      ///
deba@1911
   850
      /// Add a new ANode to the graph.
deba@1911
   851
      /// \return the new node.
deba@1911
   852
      Node addBNode();
deba@1911
   853
deba@1911
   854
      /// \brief Add a new undirected edge to the graph.
deba@1911
   855
      ///
deba@1911
   856
      /// Add a new undirected edge to the graph. One of the nodes
deba@1911
   857
      /// should be ANode and the other should be BNode.
deba@1911
   858
      /// \pre The nodes are not in the same nodeset.
deba@1911
   859
      /// \return the new edge.
deba@1911
   860
      UEdge addEdge(const Node& from, const Node& to);
deba@1911
   861
deba@1911
   862
      /// \brief Resets the graph.
deba@1911
   863
      ///
deba@1911
   864
      /// This function deletes all undirected edges and nodes of the graph.
deba@1911
   865
      /// It also frees the memory allocated to store them.
deba@1911
   866
      void clear() { }
deba@1911
   867
deba@1911
   868
      template <typename Graph>
deba@1911
   869
      struct Constraints {
deba@1911
   870
	void constraints() {}
deba@1911
   871
      };
deba@1911
   872
deba@1911
   873
    };
deba@1911
   874
deba@1911
   875
    /// \brief An empty erasable undirected graph class.
deba@1911
   876
    ///
deba@1911
   877
    /// This class is an extension of \ref ExtendableBpUGraph. It makes it
deba@1911
   878
    /// possible to erase undirected edges or nodes.
deba@1911
   879
    class ErasableBpUGraph : public ExtendableBpUGraph {
deba@1911
   880
    public:
deba@1911
   881
deba@1911
   882
      /// \brief Deletes a node.
deba@1911
   883
      ///
deba@1911
   884
      /// Deletes a node.
deba@1911
   885
      ///
deba@1911
   886
      void erase(Node) { }
deba@1911
   887
      /// \brief Deletes an undirected edge.
deba@1911
   888
      ///
deba@1911
   889
      /// Deletes an undirected edge.
deba@1911
   890
      ///
deba@1911
   891
      void erase(UEdge) { }
deba@1911
   892
deba@1911
   893
      template <typename Graph>
deba@1911
   894
      struct Constraints {
deba@1911
   895
	void constraints() {}
deba@1911
   896
      };
deba@1911
   897
deba@1911
   898
    };
deba@1911
   899
deba@1911
   900
    /// @}
deba@1911
   901
deba@1911
   902
  }
deba@1911
   903
deba@1911
   904
}
deba@1911
   905
deba@1911
   906
#endif