lemon/concepts/bpgraph.h
changeset 1193 c8fa41fcc4a7
parent 1186 2e959a5a0c2d
child 1194 699c7eac2c6d
equal deleted inserted replaced
0:142b410bcc44 1:fc65f86d7076
   147 
   147 
   148         /// Initializes the object to be invalid.
   148         /// Initializes the object to be invalid.
   149         /// \sa Invalid for more details.
   149         /// \sa Invalid for more details.
   150         RedNode(Invalid) { }
   150         RedNode(Invalid) { }
   151 
   151 
   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&) {}
       
   158       };
   152       };
   159 
   153 
   160       /// Class to represent blue nodes.
   154       /// Class to represent blue nodes.
   161 
   155 
   162       /// This class represents the blue nodes of the graph. It does
   156       /// This class represents the blue nodes of the graph. It does
   180 
   174 
   181         /// Initializes the object to be invalid.
   175         /// Initializes the object to be invalid.
   182         /// \sa Invalid for more details.
   176         /// \sa Invalid for more details.
   183         BlueNode(Invalid) { }
   177         BlueNode(Invalid) { }
   184 
   178 
   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&) {}
       
   191       };
   179       };
   192 
   180 
   193       /// Iterator class for the red nodes.
   181       /// Iterator class for the red nodes.
   194 
   182 
   195       /// This iterator goes through each red node of the graph.
   183       /// This iterator goes through each red node of the graph.
   197       /// of red nodes in a graph \c g of type \c %BpGraph like this:
   185       /// of red nodes in a graph \c g of type \c %BpGraph like this:
   198       ///\code
   186       ///\code
   199       /// int count=0;
   187       /// int count=0;
   200       /// for (BpGraph::RedNodeIt n(g); n!=INVALID; ++n) ++count;
   188       /// for (BpGraph::RedNodeIt n(g); n!=INVALID; ++n) ++count;
   201       ///\endcode
   189       ///\endcode
   202       class RedIt : public Node {
   190       class RedIt : public RedNode {
   203       public:
   191       public:
   204         /// Default constructor
   192         /// Default constructor
   205 
   193 
   206         /// Default constructor.
   194         /// Default constructor.
   207         /// \warning It sets the iterator to an undefined value.
   195         /// \warning It sets the iterator to an undefined value.
   208         RedIt() { }
   196         RedIt() { }
   209         /// Copy constructor.
   197         /// Copy constructor.
   210 
   198 
   211         /// Copy constructor.
   199         /// Copy constructor.
   212         ///
   200         ///
   213         RedIt(const RedIt& n) : Node(n) { }
   201         RedIt(const RedIt& n) : RedNode(n) { }
   214         /// %Invalid constructor \& conversion.
   202         /// %Invalid constructor \& conversion.
   215 
   203 
   216         /// Initializes the iterator to be invalid.
   204         /// Initializes the iterator to be invalid.
   217         /// \sa Invalid for more details.
   205         /// \sa Invalid for more details.
   218         RedIt(Invalid) { }
   206         RedIt(Invalid) { }
   223         explicit RedIt(const BpGraph&) { }
   211         explicit RedIt(const BpGraph&) { }
   224         /// Sets the iterator to the given red node.
   212         /// Sets the iterator to the given red node.
   225 
   213 
   226         /// Sets the iterator to the given red node of the given
   214         /// Sets the iterator to the given red node of the given
   227         /// digraph.
   215         /// digraph.
   228         RedIt(const BpGraph&, const Node&) { }
   216         RedIt(const BpGraph&, const RedNode&) { }
   229         /// Next node.
   217         /// Next node.
   230 
   218 
   231         /// Assign the iterator to the next red node.
   219         /// Assign the iterator to the next red node.
   232         ///
   220         ///
   233         RedIt& operator++() { return *this; }
   221         RedIt& operator++() { return *this; }
   240       /// of blue nodes in a graph \c g of type \c %BpGraph like this:
   228       /// of blue nodes in a graph \c g of type \c %BpGraph like this:
   241       ///\code
   229       ///\code
   242       /// int count=0;
   230       /// int count=0;
   243       /// for (BpGraph::BlueNodeIt n(g); n!=INVALID; ++n) ++count;
   231       /// for (BpGraph::BlueNodeIt n(g); n!=INVALID; ++n) ++count;
   244       ///\endcode
   232       ///\endcode
   245       class BlueIt : public Node {
   233       class BlueIt : public BlueNode {
   246       public:
   234       public:
   247         /// Default constructor
   235         /// Default constructor
   248 
   236 
   249         /// Default constructor.
   237         /// Default constructor.
   250         /// \warning It sets the iterator to an undefined value.
   238         /// \warning It sets the iterator to an undefined value.
   251         BlueIt() { }
   239         BlueIt() { }
   252         /// Copy constructor.
   240         /// Copy constructor.
   253 
   241 
   254         /// Copy constructor.
   242         /// Copy constructor.
   255         ///
   243         ///
   256         BlueIt(const BlueIt& n) : Node(n) { }
   244         BlueIt(const BlueIt& n) : BlueNode(n) { }
   257         /// %Invalid constructor \& conversion.
   245         /// %Invalid constructor \& conversion.
   258 
   246 
   259         /// Initializes the iterator to be invalid.
   247         /// Initializes the iterator to be invalid.
   260         /// \sa Invalid for more details.
   248         /// \sa Invalid for more details.
   261         BlueIt(Invalid) { }
   249         BlueIt(Invalid) { }
   266         explicit BlueIt(const BpGraph&) { }
   254         explicit BlueIt(const BpGraph&) { }
   267         /// Sets the iterator to the given blue node.
   255         /// Sets the iterator to the given blue node.
   268 
   256 
   269         /// Sets the iterator to the given blue node of the given
   257         /// Sets the iterator to the given blue node of the given
   270         /// digraph.
   258         /// digraph.
   271         BlueIt(const BpGraph&, const Node&) { }
   259         BlueIt(const BpGraph&, const BlueNode&) { }
   272         /// Next node.
   260         /// Next node.
   273 
   261 
   274         /// Assign the iterator to the next blue node.
   262         /// Assign the iterator to the next blue node.
   275         ///
   263         ///
   276         BlueIt& operator++() { return *this; }
   264         BlueIt& operator++() { return *this; }
   782       /// \brief Gives back %true for blue nodes.
   770       /// \brief Gives back %true for blue nodes.
   783       ///
   771       ///
   784       /// Gives back %true for blue nodes.
   772       /// Gives back %true for blue nodes.
   785       bool blue(const Node&) const { return true; }
   773       bool blue(const Node&) const { return true; }
   786 
   774 
       
   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 
   787       /// \brief Gives back the red end node of the edge.
   814       /// \brief Gives back the red end node of the edge.
   788       /// 
   815       /// 
   789       /// Gives back the red end node of the edge.
   816       /// 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(); }
   791 
   818 
   792       /// \brief Gives back the blue end node of the edge.
   819       /// \brief Gives back the blue end node of the edge.
   793       /// 
   820       /// 
   794       /// Gives back the blue end node of the edge.
   821       /// 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(); }
   796 
   823 
   797       /// \brief The first node of the edge.
   824       /// \brief The first node of the edge.
   798       ///
   825       ///
   799       /// It is a synonim for the \c redNode().
   826       /// It is a synonim for the \c redNode().
   800       Node u(Edge) const { return INVALID; }
   827       Node u(Edge) const { return INVALID; }
   820       int id(Node) const { return -1; }
   847       int id(Node) const { return -1; }
   821 
   848 
   822       /// \brief The red ID of the node.
   849       /// \brief The red ID of the node.
   823       ///
   850       ///
   824       /// Returns the red ID of the given node.
   851       /// 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.
       
   830       int id(RedNode) const { return -1; }
   852       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; }
       
   836 
   853 
   837       /// \brief The blue ID of the node.
   854       /// \brief The blue ID of the node.
   838       ///
   855       ///
   839       /// Returns the blue ID of the given node.
   856       /// Returns the blue ID of the given node.
   840       int id(BlueNode) const { return -1; }
   857       int id(BlueNode) const { return -1; }
   926       Node oppositeNode(Node, Edge) const { return INVALID; }
   943       Node oppositeNode(Node, Edge) const { return INVALID; }
   927 
   944 
   928       void first(Node&) const {}
   945       void first(Node&) const {}
   929       void next(Node&) const {}
   946       void next(Node&) const {}
   930 
   947 
   931       void firstRed(Node&) const {}
   948       void firstRed(RedNode&) const {}
   932       void nextRed(Node&) const {}
   949       void nextRed(RedNode&) const {}
   933 
   950 
   934       void firstBlue(Node&) const {}
   951       void firstBlue(BlueNode&) const {}
   935       void nextBlue(Node&) const {}
   952       void nextBlue(BlueNode&) const {}
   936 
   953 
   937       void first(Edge&) const {}
   954       void first(Edge&) const {}
   938       void next(Edge&) const {}
   955       void next(Edge&) const {}
   939 
   956 
   940       void first(Arc&) const {}
   957       void first(Arc&) const {}