lemon/concepts/bpgraph.h
changeset 1025 c8fa41fcc4a7
parent 1018 2e959a5a0c2d
child 1026 699c7eac2c6d
     1.1 --- a/lemon/concepts/bpgraph.h	Thu Nov 25 22:45:29 2010 +0100
     1.2 +++ b/lemon/concepts/bpgraph.h	Thu Dec 01 09:05:47 2011 +0100
     1.3 @@ -149,12 +149,6 @@
     1.4          /// \sa Invalid for more details.
     1.5          RedNode(Invalid) { }
     1.6  
     1.7 -        /// Constructor for conversion from a node.
     1.8 -
     1.9 -        /// Constructor for conversion from a node. The conversion can
    1.10 -        /// be invalid, since the Node can be member of the blue
    1.11 -        /// set.
    1.12 -        RedNode(const Node&) {}
    1.13        };
    1.14  
    1.15        /// Class to represent blue nodes.
    1.16 @@ -182,12 +176,6 @@
    1.17          /// \sa Invalid for more details.
    1.18          BlueNode(Invalid) { }
    1.19  
    1.20 -        /// Constructor for conversion from a node.
    1.21 -
    1.22 -        /// Constructor for conversion from a node. The conversion can
    1.23 -        /// be invalid, since the Node can be member of the red
    1.24 -        /// set.
    1.25 -        BlueNode(const Node&) {}
    1.26        };
    1.27  
    1.28        /// Iterator class for the red nodes.
    1.29 @@ -199,7 +187,7 @@
    1.30        /// int count=0;
    1.31        /// for (BpGraph::RedNodeIt n(g); n!=INVALID; ++n) ++count;
    1.32        ///\endcode
    1.33 -      class RedIt : public Node {
    1.34 +      class RedIt : public RedNode {
    1.35        public:
    1.36          /// Default constructor
    1.37  
    1.38 @@ -210,7 +198,7 @@
    1.39  
    1.40          /// Copy constructor.
    1.41          ///
    1.42 -        RedIt(const RedIt& n) : Node(n) { }
    1.43 +        RedIt(const RedIt& n) : RedNode(n) { }
    1.44          /// %Invalid constructor \& conversion.
    1.45  
    1.46          /// Initializes the iterator to be invalid.
    1.47 @@ -225,7 +213,7 @@
    1.48  
    1.49          /// Sets the iterator to the given red node of the given
    1.50          /// digraph.
    1.51 -        RedIt(const BpGraph&, const Node&) { }
    1.52 +        RedIt(const BpGraph&, const RedNode&) { }
    1.53          /// Next node.
    1.54  
    1.55          /// Assign the iterator to the next red node.
    1.56 @@ -242,7 +230,7 @@
    1.57        /// int count=0;
    1.58        /// for (BpGraph::BlueNodeIt n(g); n!=INVALID; ++n) ++count;
    1.59        ///\endcode
    1.60 -      class BlueIt : public Node {
    1.61 +      class BlueIt : public BlueNode {
    1.62        public:
    1.63          /// Default constructor
    1.64  
    1.65 @@ -253,7 +241,7 @@
    1.66  
    1.67          /// Copy constructor.
    1.68          ///
    1.69 -        BlueIt(const BlueIt& n) : Node(n) { }
    1.70 +        BlueIt(const BlueIt& n) : BlueNode(n) { }
    1.71          /// %Invalid constructor \& conversion.
    1.72  
    1.73          /// Initializes the iterator to be invalid.
    1.74 @@ -268,7 +256,7 @@
    1.75  
    1.76          /// Sets the iterator to the given blue node of the given
    1.77          /// digraph.
    1.78 -        BlueIt(const BpGraph&, const Node&) { }
    1.79 +        BlueIt(const BpGraph&, const BlueNode&) { }
    1.80          /// Next node.
    1.81  
    1.82          /// Assign the iterator to the next blue node.
    1.83 @@ -784,15 +772,54 @@
    1.84        /// Gives back %true for blue nodes.
    1.85        bool blue(const Node&) const { return true; }
    1.86  
    1.87 +      /// \brief Converts the node to red node object.
    1.88 +      ///
    1.89 +      /// This class is converts unsafely the node to red node
    1.90 +      /// object. It should be called only if the node is from the red
    1.91 +      /// partition or INVALID.
    1.92 +      RedNode asRedNodeUnsafe(const Node&) const { return RedNode(); }
    1.93 +
    1.94 +      /// \brief Converts the node to blue node object.
    1.95 +      ///
    1.96 +      /// This class is converts unsafely the node to blue node
    1.97 +      /// object. It should be called only if the node is from the red
    1.98 +      /// partition or INVALID.
    1.99 +      BlueNode asBlueNodeUnsafe(const Node&) const { return BlueNode(); }
   1.100 +
   1.101 +      /// \brief Converts the node to red node object.
   1.102 +      ///
   1.103 +      /// This class is converts safely the node to red node
   1.104 +      /// object. If the node is not from the red partition, then it
   1.105 +      /// returns INVALID.
   1.106 +      RedNode asRedNode(const Node&) const { return RedNode(); }
   1.107 +
   1.108 +      /// \brief Converts the node to blue node object.
   1.109 +      ///
   1.110 +      /// This class is converts unsafely the node to blue node
   1.111 +      /// object. If the node is not from the blue partition, then it
   1.112 +      /// returns INVALID.
   1.113 +      BlueNode asBlueNode(const Node&) const { return BlueNode(); }
   1.114 +
   1.115 +      /// \brief Convert the node to either red or blue node.
   1.116 +      ///
   1.117 +      /// If the node is from the red partition then it is returned in
   1.118 +      /// first and second is INVALID. If the node is from the blue
   1.119 +      /// partition then it is returned in second and first is
   1.120 +      /// INVALID. If the node INVALID then both first and second are
   1.121 +      /// INVALID in the return value.
   1.122 +      std::pair<RedNode, BlueNode> asRedBlueNode(const Node&) const {
   1.123 +        return std::make_pair(RedNode(), BlueNode());
   1.124 +      }
   1.125 +
   1.126        /// \brief Gives back the red end node of the edge.
   1.127        /// 
   1.128        /// Gives back the red end node of the edge.
   1.129 -      Node redNode(const Edge&) const { return Node(); }
   1.130 +      RedNode redNode(const Edge&) const { return RedNode(); }
   1.131  
   1.132        /// \brief Gives back the blue end node of the edge.
   1.133        /// 
   1.134        /// Gives back the blue end node of the edge.
   1.135 -      Node blueNode(const Edge&) const { return Node(); }
   1.136 +      BlueNode blueNode(const Edge&) const { return BlueNode(); }
   1.137  
   1.138        /// \brief The first node of the edge.
   1.139        ///
   1.140 @@ -822,21 +849,11 @@
   1.141        /// \brief The red ID of the node.
   1.142        ///
   1.143        /// Returns the red ID of the given node.
   1.144 -      int redId(Node) const { return -1; }
   1.145 -
   1.146 -      /// \brief The red ID of the node.
   1.147 -      ///
   1.148 -      /// Returns the red ID of the given node.
   1.149        int id(RedNode) const { return -1; }
   1.150  
   1.151        /// \brief The blue ID of the node.
   1.152        ///
   1.153        /// Returns the blue ID of the given node.
   1.154 -      int blueId(Node) const { return -1; }
   1.155 -
   1.156 -      /// \brief The blue ID of the node.
   1.157 -      ///
   1.158 -      /// Returns the blue ID of the given node.
   1.159        int id(BlueNode) const { return -1; }
   1.160  
   1.161        /// \brief The ID of the edge.
   1.162 @@ -928,11 +945,11 @@
   1.163        void first(Node&) const {}
   1.164        void next(Node&) const {}
   1.165  
   1.166 -      void firstRed(Node&) const {}
   1.167 -      void nextRed(Node&) const {}
   1.168 +      void firstRed(RedNode&) const {}
   1.169 +      void nextRed(RedNode&) const {}
   1.170  
   1.171 -      void firstBlue(Node&) const {}
   1.172 -      void nextBlue(Node&) const {}
   1.173 +      void firstBlue(BlueNode&) const {}
   1.174 +      void nextBlue(BlueNode&) const {}
   1.175  
   1.176        void first(Edge&) const {}
   1.177        void next(Edge&) const {}