COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
12/01/11 09:05:47 (12 years ago)
Author:
Balazs Dezso <deba@…>
Branch:
default
Phase:
public
Message:

Type safe red and blue node set (#69)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/concepts/bpgraph.h

    r1186 r1193  
    150150        RedNode(Invalid) { }
    151151
    152         /// Constructor for conversion from a node.
    153 
    154         /// Constructor for conversion from a node. The conversion can
    155         /// be invalid, since the Node can be member of the blue
    156         /// set.
    157         RedNode(const Node&) {}
    158152      };
    159153
     
    183177        BlueNode(Invalid) { }
    184178
    185         /// Constructor for conversion from a node.
    186 
    187         /// Constructor for conversion from a node. The conversion can
    188         /// be invalid, since the Node can be member of the red
    189         /// set.
    190         BlueNode(const Node&) {}
    191179      };
    192180
     
    200188      /// for (BpGraph::RedNodeIt n(g); n!=INVALID; ++n) ++count;
    201189      ///\endcode
    202       class RedIt : public Node {
     190      class RedIt : public RedNode {
    203191      public:
    204192        /// Default constructor
     
    211199        /// Copy constructor.
    212200        ///
    213         RedIt(const RedIt& n) : Node(n) { }
     201        RedIt(const RedIt& n) : RedNode(n) { }
    214202        /// %Invalid constructor \& conversion.
    215203
     
    226214        /// Sets the iterator to the given red node of the given
    227215        /// digraph.
    228         RedIt(const BpGraph&, const Node&) { }
     216        RedIt(const BpGraph&, const RedNode&) { }
    229217        /// Next node.
    230218
     
    243231      /// for (BpGraph::BlueNodeIt n(g); n!=INVALID; ++n) ++count;
    244232      ///\endcode
    245       class BlueIt : public Node {
     233      class BlueIt : public BlueNode {
    246234      public:
    247235        /// Default constructor
     
    254242        /// Copy constructor.
    255243        ///
    256         BlueIt(const BlueIt& n) : Node(n) { }
     244        BlueIt(const BlueIt& n) : BlueNode(n) { }
    257245        /// %Invalid constructor \& conversion.
    258246
     
    269257        /// Sets the iterator to the given blue node of the given
    270258        /// digraph.
    271         BlueIt(const BpGraph&, const Node&) { }
     259        BlueIt(const BpGraph&, const BlueNode&) { }
    272260        /// Next node.
    273261
     
    785773      bool blue(const Node&) const { return true; }
    786774
     775      /// \brief Converts the node to red node object.
     776      ///
     777      /// This class is converts unsafely the node to red node
     778      /// object. It should be called only if the node is from the red
     779      /// partition or INVALID.
     780      RedNode asRedNodeUnsafe(const Node&) const { return RedNode(); }
     781
     782      /// \brief Converts the node to blue node object.
     783      ///
     784      /// This class is converts unsafely the node to blue node
     785      /// object. It should be called only if the node is from the red
     786      /// partition or INVALID.
     787      BlueNode asBlueNodeUnsafe(const Node&) const { return BlueNode(); }
     788
     789      /// \brief Converts the node to red node object.
     790      ///
     791      /// This class is converts safely the node to red node
     792      /// object. If the node is not from the red partition, then it
     793      /// returns INVALID.
     794      RedNode asRedNode(const Node&) const { return RedNode(); }
     795
     796      /// \brief Converts the node to blue node object.
     797      ///
     798      /// This class is converts unsafely the node to blue node
     799      /// object. If the node is not from the blue partition, then it
     800      /// returns INVALID.
     801      BlueNode asBlueNode(const Node&) const { return BlueNode(); }
     802
     803      /// \brief Convert the node to either red or blue node.
     804      ///
     805      /// If the node is from the red partition then it is returned in
     806      /// first and second is INVALID. If the node is from the blue
     807      /// partition then it is returned in second and first is
     808      /// INVALID. If the node INVALID then both first and second are
     809      /// INVALID in the return value.
     810      std::pair<RedNode, BlueNode> asRedBlueNode(const Node&) const {
     811        return std::make_pair(RedNode(), BlueNode());
     812      }
     813
    787814      /// \brief Gives back the red end node of the edge.
    788815      ///
    789816      /// Gives back the red end node of the edge.
    790       Node redNode(const Edge&) const { return Node(); }
     817      RedNode redNode(const Edge&) const { return RedNode(); }
    791818
    792819      /// \brief Gives back the blue end node of the edge.
    793820      ///
    794821      /// Gives back the blue end node of the edge.
    795       Node blueNode(const Edge&) const { return Node(); }
     822      BlueNode blueNode(const Edge&) const { return BlueNode(); }
    796823
    797824      /// \brief The first node of the edge.
     
    823850      ///
    824851      /// Returns the red ID of the given node.
    825       int redId(Node) const { return -1; }
    826 
    827       /// \brief The red ID of the node.
    828       ///
    829       /// Returns the red ID of the given node.
    830852      int id(RedNode) const { return -1; }
    831 
    832       /// \brief The blue ID of the node.
    833       ///
    834       /// Returns the blue ID of the given node.
    835       int blueId(Node) const { return -1; }
    836853
    837854      /// \brief The blue ID of the node.
     
    929946      void next(Node&) const {}
    930947
    931       void firstRed(Node&) const {}
    932       void nextRed(Node&) const {}
    933 
    934       void firstBlue(Node&) const {}
    935       void nextBlue(Node&) const {}
     948      void firstRed(RedNode&) const {}
     949      void nextRed(RedNode&) const {}
     950
     951      void firstBlue(BlueNode&) const {}
     952      void nextBlue(BlueNode&) const {}
    936953
    937954      void first(Edge&) const {}
Note: See TracChangeset for help on using the changeset viewer.