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