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