Revising the bpugraph concept
authordeba
Tue, 31 Jan 2006 20:04:36 +0000
changeset 1933a876a3d6a4c7
parent 1932 c65711e5a26d
child 1934 272fa8a0b680
Revising the bpugraph concept

We need a public but very limited ANode and BNode class
It can be used with ItemSetTraits and with some special maps

By example:
DescriptorMap<Graph, ANode>
InvertableMap<Graph, ANode, string>
IterableBoolMap<Graph, ANode>
IterableIntMap<Graph, ANode>
IterableValueMap<Graph, ANode, string>
lemon/bits/iterable_graph_extender.h
lemon/concept/bpugraph.h
     1.1 --- a/lemon/bits/iterable_graph_extender.h	Tue Jan 31 19:57:35 2006 +0000
     1.2 +++ b/lemon/bits/iterable_graph_extender.h	Tue Jan 31 20:04:36 2006 +0000
     1.3 @@ -303,7 +303,7 @@
     1.4  
     1.5      };
     1.6  
     1.7 -    class ANodeIt : public Node { 
     1.8 +    class ANodeIt : public ANode { 
     1.9        friend class IterableBpUGraphExtender;
    1.10        const Graph* graph;
    1.11      public:
    1.12 @@ -325,7 +325,7 @@
    1.13        }
    1.14      };
    1.15  
    1.16 -    class BNodeIt : public Node { 
    1.17 +    class BNodeIt : public BNode { 
    1.18        friend class IterableBpUGraphExtender;
    1.19        const Graph* graph;
    1.20      public:
     2.1 --- a/lemon/concept/bpugraph.h	Tue Jan 31 19:57:35 2006 +0000
     2.2 +++ b/lemon/concept/bpugraph.h	Tue Jan 31 20:04:36 2006 +0000
     2.3 @@ -56,9 +56,11 @@
     2.4      /// as an undirected graph and consequently as a static graph.
     2.5      ///
     2.6      /// The bipartite graph stores two types of nodes which are named
     2.7 -    /// ANode and BNode. Even so the graph type does not contain ANode
     2.8 -    /// and BNode classes, becaue the nodes can be accessed just with the
     2.9 -    /// common Node class. 
    2.10 +    /// ANode and BNode. The graph type contains two types ANode and BNode
    2.11 +    /// which are inherited from Node type. Moreover they have
    2.12 +    /// constructor which converts Node to either ANode or BNode when it is
    2.13 +    /// possible. Therefor everywhere the Node type can be used instead of
    2.14 +    /// ANode and BNode. So the usage of the ANode and BNode is suggested.  
    2.15      ///
    2.16      /// The iteration on the partition can be done with the ANodeIt and 
    2.17      /// BNodeIt classes. The node map can be used to map values to the nodes
    2.18 @@ -122,6 +124,120 @@
    2.19  	bool operator<(Node) const { return false; }
    2.20  
    2.21        };
    2.22 +
    2.23 +      /// \brief The base type of anode iterators, 
    2.24 +      /// or in other words, the trivial anode iterator.
    2.25 +      ///
    2.26 +      /// This is the base type of each anode iterator,
    2.27 +      /// thus each kind of anode iterator converts to this.
    2.28 +      /// More precisely each kind of node iterator should be inherited 
    2.29 +      /// from the trivial anode iterator. The ANode class should be used
    2.30 +      /// only in special cases. Usually the Node type should be used insted
    2.31 +      /// of it. 
    2.32 +      class ANode {
    2.33 +      public:
    2.34 +        /// Default constructor
    2.35 +
    2.36 +        /// @warning The default constructor sets the iterator
    2.37 +        /// to an undefined value.
    2.38 +        ANode() { }
    2.39 +        /// Copy constructor.
    2.40 +
    2.41 +        /// Copy constructor.
    2.42 +        ///
    2.43 +        ANode(const ANode&) { }
    2.44 +
    2.45 +        /// Construct the same node as ANode.
    2.46 +
    2.47 +        /// Construct the same node as ANode. It may throws assertion
    2.48 +        /// when the given node is from the BNode set.
    2.49 +        ANode(const Node&) { }
    2.50 +
    2.51 +        /// Invalid constructor \& conversion.
    2.52 +
    2.53 +        /// This constructor initializes the iterator to be invalid.
    2.54 +        /// \sa Invalid for more details.
    2.55 +        ANode(Invalid) { }
    2.56 +        /// Equality operator
    2.57 +
    2.58 +        /// Two iterators are equal if and only if they point to the
    2.59 +        /// same object or both are invalid.
    2.60 +        bool operator==(ANode) const { return true; }
    2.61 +
    2.62 +        /// Inequality operator
    2.63 +        
    2.64 +        /// \sa operator==(ANode n)
    2.65 +        ///
    2.66 +        bool operator!=(ANode) const { return true; }
    2.67 +
    2.68 +	/// Artificial ordering operator.
    2.69 +	
    2.70 +	/// To allow the use of graph descriptors as key type in std::map or
    2.71 +	/// similar associative container we require this.
    2.72 +	///
    2.73 +	/// \note This operator only have to define some strict ordering of
    2.74 +	/// the items; this order has nothing to do with the iteration
    2.75 +	/// ordering of the items.
    2.76 +	bool operator<(ANode) const { return false; }
    2.77 +
    2.78 +      };
    2.79 +
    2.80 +      /// \brief The base type of bnode iterators, 
    2.81 +      /// or in other words, the trivial bnode iterator.
    2.82 +      ///
    2.83 +      /// This is the base type of each anode iterator,
    2.84 +      /// thus each kind of anode iterator converts to this.
    2.85 +      /// More precisely each kind of node iterator should be inherited 
    2.86 +      /// from the trivial anode iterator. The BNode class should be used
    2.87 +      /// only in special cases. Usually the Node type should be used insted
    2.88 +      /// of it. 
    2.89 +      class BNode {
    2.90 +      public:
    2.91 +        /// Default constructor
    2.92 +
    2.93 +        /// @warning The default constructor sets the iterator
    2.94 +        /// to an undefined value.
    2.95 +        BNode() { }
    2.96 +        /// Copy constructor.
    2.97 +
    2.98 +        /// Copy constructor.
    2.99 +        ///
   2.100 +        BNode(const BNode&) { }
   2.101 +
   2.102 +        /// Construct the same node as BNode.
   2.103 +
   2.104 +        /// Construct the same node as BNode. It may throws assertion
   2.105 +        /// when the given node is from the ANode set.
   2.106 +        BNode(const Node&) { }
   2.107 +
   2.108 +        /// Invalid constructor \& conversion.
   2.109 +
   2.110 +        /// This constructor initializes the iterator to be invalid.
   2.111 +        /// \sa Invalid for more details.
   2.112 +        BNode(Invalid) { }
   2.113 +        /// Equality operator
   2.114 +
   2.115 +        /// Two iterators are equal if and only if they point to the
   2.116 +        /// same object or both are invalid.
   2.117 +        bool operator==(BNode) const { return true; }
   2.118 +
   2.119 +        /// Inequality operator
   2.120 +        
   2.121 +        /// \sa operator==(BNode n)
   2.122 +        ///
   2.123 +        bool operator!=(BNode) const { return true; }
   2.124 +
   2.125 +	/// Artificial ordering operator.
   2.126 +	
   2.127 +	/// To allow the use of graph descriptors as key type in std::map or
   2.128 +	/// similar associative container we require this.
   2.129 +	///
   2.130 +	/// \note This operator only have to define some strict ordering of
   2.131 +	/// the items; this order has nothing to do with the iteration
   2.132 +	/// ordering of the items.
   2.133 +	bool operator<(BNode) const { return false; }
   2.134 +
   2.135 +      };
   2.136      
   2.137        /// This iterator goes through each node.
   2.138  
   2.139 @@ -177,7 +293,7 @@
   2.140        /// int count=0;
   2.141        /// for (Graph::ANodeIt n(g); n!=INVALID; ++n) ++count;
   2.142        /// \endcode
   2.143 -      class ANodeIt : public Node {
   2.144 +      class ANodeIt : public ANode {
   2.145        public:
   2.146          /// Default constructor
   2.147  
   2.148 @@ -222,7 +338,7 @@
   2.149        /// int count=0;
   2.150        /// for (Graph::BNodeIt n(g); n!=INVALID; ++n) ++count;
   2.151        /// \endcode
   2.152 -      class BNodeIt : public Node {
   2.153 +      class BNodeIt : public BNode {
   2.154        public:
   2.155          /// Default constructor
   2.156