deba@1911: /* -*- C++ -*- deba@1911: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library deba@1911: * alpar@1956: * Copyright (C) 2003-2006 alpar@1956: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1956: * (Egervary Research Group on Combinatorial Optimization, EGRES). deba@1911: * deba@1911: * Permission to use, modify and distribute this software is granted deba@1911: * provided that this copyright notice appears in all copies. For deba@1911: * precise terms see the accompanying LICENSE file. deba@1911: * deba@1911: * This software is provided "AS IS" with no warranty of any kind, deba@1911: * express or implied, and with no claim as to its suitability for any deba@1911: * purpose. deba@1911: * deba@1911: */ deba@1911: deba@1911: /// \ingroup graph_concepts deba@1911: /// \file deba@1911: /// \brief Undirected bipartite graphs and components of. deba@1911: deba@1911: deba@1911: #ifndef LEMON_CONCEPT_BPUGRAPH_H deba@1911: #define LEMON_CONCEPT_BPUGRAPH_H deba@1911: deba@2126: #include deba@1911: deba@1911: #include deba@1911: #include deba@1911: deba@1993: #include deba@1911: deba@1911: namespace lemon { deba@1911: namespace concept { deba@1911: deba@1911: /// \addtogroup graph_concepts deba@1911: /// @{ deba@1911: deba@1911: deba@1911: /// \brief Class describing the concept of Bipartite Undirected Graphs. deba@1911: /// deba@1911: /// This class describes the common interface of all deba@1911: /// Undirected Bipartite Graphs. deba@1911: /// deba@1911: /// As all concept describing classes it provides only interface deba@1911: /// without any sensible implementation. So any algorithm for deba@1911: /// bipartite undirected graph should compile with this class, but it deba@1911: /// will not run properly, of course. deba@1911: /// deba@1911: /// In LEMON bipartite undirected graphs also fulfill the concept of deba@1911: /// the undirected graphs (\ref lemon::concept::UGraph "UGraph Concept"). deba@1911: /// deba@1911: /// You can assume that all undirected bipartite graph can be handled deba@1911: /// as an undirected graph and consequently as a static graph. deba@1911: /// deba@1911: /// The bipartite graph stores two types of nodes which are named deba@2163: /// ANode and BNode. The graph type contains two types ANode and deba@2163: /// BNode which are inherited from Node type. Moreover they have deba@2163: /// constructor which converts Node to either ANode or BNode when deba@2163: /// it is possible. Therefor everywhere the Node type can be used deba@2163: /// instead of ANode and BNode. So the usage of the ANode and deba@2163: /// BNode is not suggested. deba@1911: /// deba@1911: /// The iteration on the partition can be done with the ANodeIt and deba@1911: /// BNodeIt classes. The node map can be used to map values to the nodes deba@1911: /// and similarly we can use to map values for just the ANodes and deba@1911: /// BNodes the ANodeMap and BNodeMap template classes. deba@1911: deba@1911: class BpUGraph { deba@1911: public: deba@2163: /// \brief The undirected graph should be tagged by the deba@2163: /// UndirectedTag. deba@1911: /// deba@2163: /// The undirected graph should be tagged by the UndirectedTag. This deba@2163: /// tag helps the enable_if technics to make compile time deba@2163: /// specializations for undirected graphs. deba@1979: typedef True UndirectedTag; deba@1911: deba@1911: /// \brief The base type of node iterators, deba@1911: /// or in other words, the trivial node iterator. deba@1911: /// deba@1911: /// This is the base type of each node iterator, deba@1911: /// thus each kind of node iterator converts to this. deba@1911: /// More precisely each kind of node iterator should be inherited deba@1911: /// from the trivial node iterator. The Node class represents deba@1911: /// both of two types of nodes. deba@1911: class Node { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: Node() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: Node(const Node&) { } deba@1911: deba@1911: /// Invalid constructor \& conversion. deba@1911: deba@1911: /// This constructor initializes the iterator to be invalid. deba@1911: /// \sa Invalid for more details. deba@1911: Node(Invalid) { } deba@1911: /// Equality operator deba@1911: deba@1911: /// Two iterators are equal if and only if they point to the deba@1911: /// same object or both are invalid. deba@1911: bool operator==(Node) const { return true; } deba@1911: deba@1911: /// Inequality operator deba@1911: deba@1911: /// \sa operator==(Node n) deba@1911: /// deba@1911: bool operator!=(Node) const { return true; } deba@1911: deba@1911: /// Artificial ordering operator. deba@1911: deba@1911: /// To allow the use of graph descriptors as key type in std::map or deba@1911: /// similar associative container we require this. deba@1911: /// deba@1911: /// \note This operator only have to define some strict ordering of deba@1911: /// the items; this order has nothing to do with the iteration deba@1911: /// ordering of the items. deba@1911: bool operator<(Node) const { return false; } deba@1911: deba@1911: }; deba@1933: deba@2163: /// \brief Helper class for ANodes. deba@1933: /// deba@2163: /// This class is just a helper class for ANodes, it is not deba@2163: /// suggested to use it directly. It can be converted easily to deba@2163: /// node and vice versa. The usage of this class is limited deba@2231: /// to use just as template parameters for special map types. deba@2231: class ANode : public Node { deba@1933: public: deba@1933: /// Default constructor deba@1933: deba@1933: /// @warning The default constructor sets the iterator deba@1933: /// to an undefined value. deba@2231: ANode() : Node() { } deba@1933: /// Copy constructor. deba@1933: deba@1933: /// Copy constructor. deba@1933: /// deba@2231: ANode(const ANode&) : Node() { } deba@1933: deba@1933: /// Construct the same node as ANode. deba@1933: deba@1933: /// Construct the same node as ANode. It may throws assertion deba@1933: /// when the given node is from the BNode set. deba@2231: ANode(const Node&) : Node() { } deba@2231: deba@2231: /// Assign node to A-node. deba@2231: deba@2231: /// Besides the core graph item functionality each node should deba@2231: /// be convertible to the represented A-node if it is it possible. deba@2231: ANode& operator=(const Node&) { return *this; } deba@1933: deba@1933: /// Invalid constructor \& conversion. deba@1933: deba@1933: /// This constructor initializes the iterator to be invalid. deba@1933: /// \sa Invalid for more details. deba@1933: ANode(Invalid) { } deba@1933: /// Equality operator deba@1933: deba@1933: /// Two iterators are equal if and only if they point to the deba@1933: /// same object or both are invalid. deba@1933: bool operator==(ANode) const { return true; } deba@1933: deba@1933: /// Inequality operator deba@1933: deba@1933: /// \sa operator==(ANode n) deba@1933: /// deba@1933: bool operator!=(ANode) const { return true; } deba@1933: deba@1933: /// Artificial ordering operator. deba@1933: deba@1933: /// To allow the use of graph descriptors as key type in std::map or deba@1933: /// similar associative container we require this. deba@1933: /// deba@1933: /// \note This operator only have to define some strict ordering of deba@1933: /// the items; this order has nothing to do with the iteration deba@1933: /// ordering of the items. deba@1933: bool operator<(ANode) const { return false; } deba@1933: deba@1933: }; deba@1933: deba@2163: /// \brief Helper class for BNodes. deba@1933: /// deba@2163: /// This class is just a helper class for BNodes, it is not deba@2163: /// suggested to use it directly. It can be converted easily to deba@2163: /// node and vice versa. The usage of this class is limited deba@2231: /// to use just as template parameters for special map types. deba@2231: class BNode : public Node { deba@1933: public: deba@1933: /// Default constructor deba@1933: deba@1933: /// @warning The default constructor sets the iterator deba@1933: /// to an undefined value. deba@2231: BNode() : Node() { } deba@1933: /// Copy constructor. deba@1933: deba@1933: /// Copy constructor. deba@1933: /// deba@2231: BNode(const BNode&) : Node() { } deba@1933: deba@1933: /// Construct the same node as BNode. deba@1933: deba@1933: /// Construct the same node as BNode. It may throws assertion deba@1933: /// when the given node is from the ANode set. deba@2231: BNode(const Node&) : Node() { } deba@2231: deba@2231: /// Assign node to B-node. deba@2231: deba@2231: /// Besides the core graph item functionality each node should deba@2231: /// be convertible to the represented B-node if it is it possible. deba@2231: BNode& operator=(const Node&) { return *this; } deba@1933: deba@1933: /// Invalid constructor \& conversion. deba@1933: deba@1933: /// This constructor initializes the iterator to be invalid. deba@1933: /// \sa Invalid for more details. deba@1933: BNode(Invalid) { } deba@1933: /// Equality operator deba@1933: deba@1933: /// Two iterators are equal if and only if they point to the deba@1933: /// same object or both are invalid. deba@1933: bool operator==(BNode) const { return true; } deba@1933: deba@1933: /// Inequality operator deba@1933: deba@1933: /// \sa operator==(BNode n) deba@1933: /// deba@1933: bool operator!=(BNode) const { return true; } deba@1933: deba@1933: /// Artificial ordering operator. deba@1933: deba@1933: /// To allow the use of graph descriptors as key type in std::map or deba@1933: /// similar associative container we require this. deba@1933: /// deba@1933: /// \note This operator only have to define some strict ordering of deba@1933: /// the items; this order has nothing to do with the iteration deba@1933: /// ordering of the items. deba@1933: bool operator<(BNode) const { return false; } deba@1933: deba@1933: }; deba@1911: deba@1911: /// This iterator goes through each node. deba@1911: deba@1911: /// This iterator goes through each node. deba@1911: /// Its usage is quite simple, for example you can count the number deba@1911: /// of nodes in graph \c g of type \c Graph like this: alpar@1946: ///\code deba@1911: /// int count=0; deba@1911: /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count; alpar@1946: ///\endcode deba@1911: class NodeIt : public Node { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: NodeIt() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: NodeIt(const NodeIt& n) : Node(n) { } deba@1911: /// Invalid constructor \& conversion. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// \sa Invalid for more details. deba@1911: NodeIt(Invalid) { } deba@1911: /// Sets the iterator to the first node. deba@1911: deba@1911: /// Sets the iterator to the first node of \c g. deba@1911: /// deba@1911: NodeIt(const BpUGraph&) { } deba@1911: /// Node -> NodeIt conversion. deba@1911: deba@1911: /// Sets the iterator to the node of \c the graph pointed by deba@1911: /// the trivial iterator. deba@1911: /// This feature necessitates that each time we deba@1911: /// iterate the edge-set, the iteration order is the same. deba@1911: NodeIt(const BpUGraph&, const Node&) { } deba@1911: /// Next node. deba@1911: deba@1911: /// Assign the iterator to the next node. deba@1911: /// deba@1911: NodeIt& operator++() { return *this; } deba@1911: }; deba@1911: deba@1911: /// This iterator goes through each ANode. deba@1911: deba@1911: /// This iterator goes through each ANode. deba@1911: /// Its usage is quite simple, for example you can count the number deba@1911: /// of nodes in graph \c g of type \c Graph like this: alpar@1946: ///\code deba@1911: /// int count=0; deba@1911: /// for (Graph::ANodeIt n(g); n!=INVALID; ++n) ++count; alpar@1946: ///\endcode deba@2163: class ANodeIt : public Node { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: ANodeIt() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: ANodeIt(const ANodeIt& n) : Node(n) { } deba@1911: /// Invalid constructor \& conversion. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// \sa Invalid for more details. deba@1911: ANodeIt(Invalid) { } deba@1911: /// Sets the iterator to the first node. deba@1911: deba@1911: /// Sets the iterator to the first node of \c g. deba@1911: /// deba@1911: ANodeIt(const BpUGraph&) { } deba@1911: /// Node -> ANodeIt conversion. deba@1911: deba@1911: /// Sets the iterator to the node of \c the graph pointed by deba@1911: /// the trivial iterator. deba@1911: /// This feature necessitates that each time we deba@1911: /// iterate the edge-set, the iteration order is the same. deba@1911: ANodeIt(const BpUGraph&, const Node&) { } deba@1911: /// Next node. deba@1911: deba@1911: /// Assign the iterator to the next node. deba@1911: /// deba@1911: ANodeIt& operator++() { return *this; } deba@1911: }; deba@1911: deba@1911: /// This iterator goes through each BNode. deba@1911: deba@1911: /// This iterator goes through each BNode. deba@1911: /// Its usage is quite simple, for example you can count the number deba@1911: /// of nodes in graph \c g of type \c Graph like this: alpar@1946: ///\code deba@1911: /// int count=0; deba@1911: /// for (Graph::BNodeIt n(g); n!=INVALID; ++n) ++count; alpar@1946: ///\endcode deba@2163: class BNodeIt : public Node { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: BNodeIt() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: BNodeIt(const BNodeIt& n) : Node(n) { } deba@1911: /// Invalid constructor \& conversion. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// \sa Invalid for more details. deba@1911: BNodeIt(Invalid) { } deba@1911: /// Sets the iterator to the first node. deba@1911: deba@1911: /// Sets the iterator to the first node of \c g. deba@1911: /// deba@1911: BNodeIt(const BpUGraph&) { } deba@1911: /// Node -> BNodeIt conversion. deba@1911: deba@1911: /// Sets the iterator to the node of \c the graph pointed by deba@1911: /// the trivial iterator. deba@1911: /// This feature necessitates that each time we deba@1911: /// iterate the edge-set, the iteration order is the same. deba@1911: BNodeIt(const BpUGraph&, const Node&) { } deba@1911: /// Next node. deba@1911: deba@1911: /// Assign the iterator to the next node. deba@1911: /// deba@1911: BNodeIt& operator++() { return *this; } deba@1911: }; deba@1911: deba@1911: deba@1911: /// The base type of the undirected edge iterators. deba@1911: deba@1911: /// The base type of the undirected edge iterators. deba@1911: /// deba@1911: class UEdge { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: UEdge() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: UEdge(const UEdge&) { } deba@1911: /// Initialize the iterator to be invalid. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// deba@1911: UEdge(Invalid) { } deba@1911: /// Equality operator deba@1911: deba@1911: /// Two iterators are equal if and only if they point to the deba@1911: /// same object or both are invalid. deba@1911: bool operator==(UEdge) const { return true; } deba@1911: /// Inequality operator deba@1911: deba@1911: /// \sa operator==(UEdge n) deba@1911: /// deba@1911: bool operator!=(UEdge) const { return true; } deba@1911: deba@1911: /// Artificial ordering operator. deba@1911: deba@1911: /// To allow the use of graph descriptors as key type in std::map or deba@1911: /// similar associative container we require this. deba@1911: /// deba@1911: /// \note This operator only have to define some strict ordering of deba@1911: /// the items; this order has nothing to do with the iteration deba@1911: /// ordering of the items. deba@1911: bool operator<(UEdge) const { return false; } deba@1911: }; deba@1911: deba@1911: /// This iterator goes through each undirected edge. deba@1911: deba@1911: /// This iterator goes through each undirected edge of a graph. deba@1911: /// Its usage is quite simple, for example you can count the number deba@1911: /// of undirected edges in a graph \c g of type \c Graph as follows: alpar@1946: ///\code deba@1911: /// int count=0; deba@1911: /// for(Graph::UEdgeIt e(g); e!=INVALID; ++e) ++count; alpar@1946: ///\endcode deba@1911: class UEdgeIt : public UEdge { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: UEdgeIt() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: UEdgeIt(const UEdgeIt& e) : UEdge(e) { } deba@1911: /// Initialize the iterator to be invalid. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// deba@1911: UEdgeIt(Invalid) { } deba@1911: /// This constructor sets the iterator to the first undirected edge. deba@1911: deba@1911: /// This constructor sets the iterator to the first undirected edge. deba@1911: UEdgeIt(const BpUGraph&) { } deba@1911: /// UEdge -> UEdgeIt conversion deba@1911: deba@1911: /// Sets the iterator to the value of the trivial iterator. deba@1911: /// This feature necessitates that each time we deba@1911: /// iterate the undirected edge-set, the iteration order is the deba@1911: /// same. deba@1911: UEdgeIt(const BpUGraph&, const UEdge&) { } deba@1911: /// Next undirected edge deba@1911: deba@1911: /// Assign the iterator to the next undirected edge. deba@1911: UEdgeIt& operator++() { return *this; } deba@1911: }; deba@1911: deba@1911: /// \brief This iterator goes trough the incident undirected deba@1911: /// edges of a node. deba@1911: /// deba@1911: /// This iterator goes trough the incident undirected edges deba@1911: /// of a certain node deba@1911: /// of a graph. deba@1911: /// Its usage is quite simple, for example you can compute the deba@1911: /// degree (i.e. count the number deba@1911: /// of incident edges of a node \c n deba@1911: /// in graph \c g of type \c Graph as follows. alpar@1946: ///\code deba@1911: /// int count=0; deba@1911: /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count; alpar@1946: ///\endcode deba@1911: class IncEdgeIt : public UEdge { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: IncEdgeIt() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: IncEdgeIt(const IncEdgeIt& e) : UEdge(e) { } deba@1911: /// Initialize the iterator to be invalid. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// deba@1911: IncEdgeIt(Invalid) { } deba@1911: /// This constructor sets the iterator to first incident edge. deba@1911: deba@1911: /// This constructor set the iterator to the first incident edge of deba@1911: /// the node. deba@1911: IncEdgeIt(const BpUGraph&, const Node&) { } deba@1911: /// UEdge -> IncEdgeIt conversion deba@1911: deba@1911: /// Sets the iterator to the value of the trivial iterator \c e. deba@1911: /// This feature necessitates that each time we deba@1911: /// iterate the edge-set, the iteration order is the same. deba@1911: IncEdgeIt(const BpUGraph&, const UEdge&) { } deba@1911: /// Next incident edge deba@1911: deba@1911: /// Assign the iterator to the next incident edge deba@1911: /// of the corresponding node. deba@1911: IncEdgeIt& operator++() { return *this; } deba@1911: }; deba@1911: deba@1911: /// The directed edge type. deba@1911: deba@1911: /// The directed edge type. It can be converted to the deba@1911: /// undirected edge. deba@1911: class Edge : public UEdge { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: Edge() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: Edge(const Edge& e) : UEdge(e) { } deba@1911: /// Initialize the iterator to be invalid. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// deba@1911: Edge(Invalid) { } deba@1911: /// Equality operator deba@1911: deba@1911: /// Two iterators are equal if and only if they point to the deba@1911: /// same object or both are invalid. deba@1911: bool operator==(Edge) const { return true; } deba@1911: /// Inequality operator deba@1911: deba@1911: /// \sa operator==(Edge n) deba@1911: /// deba@1911: bool operator!=(Edge) const { return true; } deba@1911: deba@1911: /// Artificial ordering operator. deba@1911: deba@1911: /// To allow the use of graph descriptors as key type in std::map or deba@1911: /// similar associative container we require this. deba@1911: /// deba@1911: /// \note This operator only have to define some strict ordering of deba@1911: /// the items; this order has nothing to do with the iteration deba@1911: /// ordering of the items. deba@1911: bool operator<(Edge) const { return false; } deba@1911: deba@1911: }; deba@1911: /// This iterator goes through each directed edge. deba@1911: deba@1911: /// This iterator goes through each edge of a graph. deba@1911: /// Its usage is quite simple, for example you can count the number deba@1911: /// of edges in a graph \c g of type \c Graph as follows: alpar@1946: ///\code deba@1911: /// int count=0; deba@1911: /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count; alpar@1946: ///\endcode deba@1911: class EdgeIt : public Edge { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: EdgeIt() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: EdgeIt(const EdgeIt& e) : Edge(e) { } deba@1911: /// Initialize the iterator to be invalid. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// deba@1911: EdgeIt(Invalid) { } deba@1911: /// This constructor sets the iterator to the first edge. deba@1911: deba@1911: /// This constructor sets the iterator to the first edge of \c g. deba@1911: ///@param g the graph deba@1911: EdgeIt(const BpUGraph &g) { ignore_unused_variable_warning(g); } deba@1911: /// Edge -> EdgeIt conversion deba@1911: deba@1911: /// Sets the iterator to the value of the trivial iterator \c e. deba@1911: /// This feature necessitates that each time we deba@1911: /// iterate the edge-set, the iteration order is the same. deba@1911: EdgeIt(const BpUGraph&, const Edge&) { } deba@1911: ///Next edge deba@1911: deba@1911: /// Assign the iterator to the next edge. deba@1911: EdgeIt& operator++() { return *this; } deba@1911: }; deba@1911: deba@1911: /// This iterator goes trough the outgoing directed edges of a node. deba@1911: deba@1911: /// This iterator goes trough the \e outgoing edges of a certain node deba@1911: /// of a graph. deba@1911: /// Its usage is quite simple, for example you can count the number deba@1911: /// of outgoing edges of a node \c n deba@1911: /// in graph \c g of type \c Graph as follows. alpar@1946: ///\code deba@1911: /// int count=0; deba@1911: /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count; alpar@1946: ///\endcode deba@1911: deba@1911: class OutEdgeIt : public Edge { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: OutEdgeIt() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: OutEdgeIt(const OutEdgeIt& e) : Edge(e) { } deba@1911: /// Initialize the iterator to be invalid. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// deba@1911: OutEdgeIt(Invalid) { } deba@1911: /// This constructor sets the iterator to the first outgoing edge. deba@1911: deba@1911: /// This constructor sets the iterator to the first outgoing edge of deba@1911: /// the node. deba@1911: ///@param n the node deba@1911: ///@param g the graph deba@1911: OutEdgeIt(const BpUGraph& n, const Node& g) { deba@1911: ignore_unused_variable_warning(n); deba@1911: ignore_unused_variable_warning(g); deba@1911: } deba@1911: /// Edge -> OutEdgeIt conversion deba@1911: deba@1911: /// Sets the iterator to the value of the trivial iterator. deba@1911: /// This feature necessitates that each time we deba@1911: /// iterate the edge-set, the iteration order is the same. deba@1911: OutEdgeIt(const BpUGraph&, const Edge&) { } deba@1911: ///Next outgoing edge deba@1911: deba@1911: /// Assign the iterator to the next deba@1911: /// outgoing edge of the corresponding node. deba@1911: OutEdgeIt& operator++() { return *this; } deba@1911: }; deba@1911: deba@1911: /// This iterator goes trough the incoming directed edges of a node. deba@1911: deba@1911: /// This iterator goes trough the \e incoming edges of a certain node deba@1911: /// of a graph. deba@1911: /// Its usage is quite simple, for example you can count the number deba@1911: /// of outgoing edges of a node \c n deba@1911: /// in graph \c g of type \c Graph as follows. alpar@1946: ///\code deba@1911: /// int count=0; deba@1911: /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count; alpar@1946: ///\endcode deba@1911: deba@1911: class InEdgeIt : public Edge { deba@1911: public: deba@1911: /// Default constructor deba@1911: deba@1911: /// @warning The default constructor sets the iterator deba@1911: /// to an undefined value. deba@1911: InEdgeIt() { } deba@1911: /// Copy constructor. deba@1911: deba@1911: /// Copy constructor. deba@1911: /// deba@1911: InEdgeIt(const InEdgeIt& e) : Edge(e) { } deba@1911: /// Initialize the iterator to be invalid. deba@1911: deba@1911: /// Initialize the iterator to be invalid. deba@1911: /// deba@1911: InEdgeIt(Invalid) { } deba@1911: /// This constructor sets the iterator to first incoming edge. deba@1911: deba@1911: /// This constructor set the iterator to the first incoming edge of deba@1911: /// the node. deba@1911: ///@param n the node deba@1911: ///@param g the graph deba@1911: InEdgeIt(const BpUGraph& g, const Node& n) { deba@1911: ignore_unused_variable_warning(n); deba@1911: ignore_unused_variable_warning(g); deba@1911: } deba@1911: /// Edge -> InEdgeIt conversion deba@1911: deba@1911: /// Sets the iterator to the value of the trivial iterator \c e. deba@1911: /// This feature necessitates that each time we deba@1911: /// iterate the edge-set, the iteration order is the same. deba@1911: InEdgeIt(const BpUGraph&, const Edge&) { } deba@1911: /// Next incoming edge deba@1911: deba@1911: /// Assign the iterator to the next inedge of the corresponding node. deba@1911: /// deba@1911: InEdgeIt& operator++() { return *this; } deba@1911: }; deba@1911: deba@1911: /// \brief Read write map of the nodes to type \c T. deba@1911: /// deba@1911: /// ReadWrite map of the nodes to type \c T. deba@1911: /// \sa Reference deba@1911: /// \warning Making maps that can handle bool type (NodeMap) deba@1911: /// needs some extra attention! deba@1911: /// \todo Wrong documentation deba@1911: template deba@1911: class NodeMap : public ReadWriteMap< Node, T > deba@1911: { deba@1911: public: deba@1911: deba@1911: ///\e deba@1911: NodeMap(const BpUGraph&) { } deba@1911: ///\e deba@1911: NodeMap(const BpUGraph&, T) { } deba@1911: deba@1911: ///Copy constructor deba@1911: NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { } deba@1911: ///Assignment operator deba@1911: NodeMap& operator=(const NodeMap&) { return *this; } deba@2231: ///Assignment operator deba@2231: template deba@2231: NodeMap& operator=(const CMap&) { deba@2231: checkConcept, CMap>(); deba@2231: return *this; deba@2231: } deba@1911: }; deba@1911: deba@1911: /// \brief Read write map of the ANodes to type \c T. deba@1911: /// deba@1911: /// ReadWrite map of the ANodes to type \c T. deba@1911: /// \sa Reference deba@1911: /// \warning Making maps that can handle bool type (NodeMap) deba@1911: /// needs some extra attention! deba@1911: /// \todo Wrong documentation deba@1911: template deba@1911: class ANodeMap : public ReadWriteMap< Node, T > deba@1911: { deba@1911: public: deba@1911: deba@1911: ///\e deba@1911: ANodeMap(const BpUGraph&) { } deba@1911: ///\e deba@1911: ANodeMap(const BpUGraph&, T) { } deba@1911: deba@1911: ///Copy constructor deba@2231: ANodeMap(const ANodeMap& nm) : ReadWriteMap< Node, T >(nm) { } deba@1911: ///Assignment operator deba@2231: ANodeMap& operator=(const ANodeMap&) { return *this; } deba@2231: ///Assignment operator deba@2231: template deba@2231: ANodeMap& operator=(const CMap&) { deba@2231: checkConcept, CMap>(); deba@2231: return *this; deba@2231: } deba@1911: }; deba@1911: deba@1911: /// \brief Read write map of the BNodes to type \c T. deba@1911: /// deba@1911: /// ReadWrite map of the BNodes to type \c T. deba@1911: /// \sa Reference deba@1911: /// \warning Making maps that can handle bool type (NodeMap) deba@1911: /// needs some extra attention! deba@1911: /// \todo Wrong documentation deba@1911: template deba@1911: class BNodeMap : public ReadWriteMap< Node, T > deba@1911: { deba@1911: public: deba@1911: deba@1911: ///\e deba@1911: BNodeMap(const BpUGraph&) { } deba@1911: ///\e deba@1911: BNodeMap(const BpUGraph&, T) { } deba@1911: deba@1911: ///Copy constructor deba@2231: BNodeMap(const BNodeMap& nm) : ReadWriteMap< Node, T >(nm) { } deba@1911: ///Assignment operator deba@2231: BNodeMap& operator=(const BNodeMap&) { return *this; } deba@2231: ///Assignment operator deba@2231: template deba@2231: BNodeMap& operator=(const CMap&) { deba@2231: checkConcept, CMap>(); deba@2231: return *this; deba@2231: } deba@1911: }; deba@1911: deba@1911: /// \brief Read write map of the directed edges to type \c T. deba@1911: /// deba@1911: /// Reference map of the directed edges to type \c T. deba@1911: /// \sa Reference deba@1911: /// \warning Making maps that can handle bool type (EdgeMap) deba@1911: /// needs some extra attention! deba@1911: /// \todo Wrong documentation deba@1911: template deba@1911: class EdgeMap : public ReadWriteMap deba@1911: { deba@1911: public: deba@1911: deba@1911: ///\e deba@1911: EdgeMap(const BpUGraph&) { } deba@1911: ///\e deba@1911: EdgeMap(const BpUGraph&, T) { } deba@1911: ///Copy constructor deba@1911: EdgeMap(const EdgeMap& em) : ReadWriteMap(em) { } deba@1911: ///Assignment operator deba@1911: EdgeMap& operator=(const EdgeMap&) { return *this; } deba@2231: ///Assignment operator deba@2231: template deba@2231: EdgeMap& operator=(const CMap&) { deba@2231: checkConcept, CMap>(); deba@2231: return *this; deba@2231: } deba@1911: }; deba@1911: deba@1911: /// Read write map of the undirected edges to type \c T. deba@1911: deba@1911: /// Reference map of the edges to type \c T. deba@1911: /// \sa Reference deba@1911: /// \warning Making maps that can handle bool type (UEdgeMap) deba@1911: /// needs some extra attention! deba@1911: /// \todo Wrong documentation deba@1911: template deba@1911: class UEdgeMap : public ReadWriteMap deba@1911: { deba@1911: public: deba@1911: deba@1911: ///\e deba@1911: UEdgeMap(const BpUGraph&) { } deba@1911: ///\e deba@1911: UEdgeMap(const BpUGraph&, T) { } deba@1911: ///Copy constructor deba@1911: UEdgeMap(const UEdgeMap& em) : ReadWriteMap(em) {} deba@1911: ///Assignment operator deba@1911: UEdgeMap &operator=(const UEdgeMap&) { return *this; } deba@2231: ///Assignment operator deba@2231: template deba@2231: UEdgeMap& operator=(const CMap&) { deba@2231: checkConcept, CMap>(); deba@2231: return *this; deba@2231: } deba@1911: }; deba@1911: deba@1911: /// \brief Direct the given undirected edge. deba@1911: /// deba@1911: /// Direct the given undirected edge. The returned edge source deba@2163: /// will be the given node. deba@1911: Edge direct(const UEdge&, const Node&) const { deba@1911: return INVALID; deba@1911: } deba@1911: deba@1911: /// \brief Direct the given undirected edge. deba@1911: /// deba@2163: /// Direct the given undirected edge. The returned edge deba@2163: /// represents the given undireted edge and the direction comes deba@2163: /// from the given bool. The source of the undirected edge and deba@2163: /// the directed edge is the same when the given bool is true. deba@1911: Edge direct(const UEdge&, bool) const { deba@1911: return INVALID; deba@1911: } deba@1911: deba@1911: /// \brief Returns true when the given node is an ANode. deba@1911: /// deba@1911: /// Returns true when the given node is an ANode. deba@1911: bool aNode(Node) const { return true;} deba@1911: deba@1911: /// \brief Returns true when the given node is an BNode. deba@1911: /// deba@1911: /// Returns true when the given node is an BNode. deba@1911: bool bNode(Node) const { return true;} deba@1911: deba@1911: /// \brief Returns the edge's end node which is in the ANode set. deba@1911: /// deba@1911: /// Returns the edge's end node which is in the ANode set. deba@1911: Node aNode(UEdge) const { return INVALID;} deba@1911: deba@1911: /// \brief Returns the edge's end node which is in the BNode set. deba@1911: /// deba@1911: /// Returns the edge's end node which is in the BNode set. deba@1911: Node bNode(UEdge) const { return INVALID;} deba@1911: deba@1911: /// \brief Returns true if the edge has default orientation. deba@1911: /// deba@1911: /// Returns whether the given directed edge is same orientation as deba@2163: /// the corresponding undirected edge's default orientation. deba@1911: bool direction(Edge) const { return true; } deba@1911: deba@1911: /// \brief Returns the opposite directed edge. deba@1911: /// deba@1911: /// Returns the opposite directed edge. deba@1911: Edge oppositeEdge(Edge) const { return INVALID; } deba@1911: deba@1911: /// \brief Opposite node on an edge deba@1911: /// deba@2163: /// \return the opposite of the given Node on the given UEdge deba@1911: Node oppositeNode(Node, UEdge) const { return INVALID; } deba@1911: deba@1911: /// \brief First node of the undirected edge. deba@1911: /// deba@1911: /// \return the first node of the given UEdge. deba@1911: /// deba@2163: /// Naturally undirected edges don't have direction and thus deba@1911: /// don't have source and target node. But we use these two methods deba@1911: /// to query the two endnodes of the edge. The direction of the edge deba@1911: /// which arises this way is called the inherent direction of the deba@1911: /// undirected edge, and is used to define the "default" direction deba@1911: /// of the directed versions of the edges. deba@1911: /// \sa direction deba@1911: Node source(UEdge) const { return INVALID; } deba@1911: deba@1911: /// \brief Second node of the undirected edge. deba@1911: Node target(UEdge) const { return INVALID; } deba@1911: deba@1911: /// \brief Source node of the directed edge. deba@1911: Node source(Edge) const { return INVALID; } deba@1911: deba@1911: /// \brief Target node of the directed edge. deba@1911: Node target(Edge) const { return INVALID; } deba@1911: deba@1911: /// \brief Base node of the iterator deba@1911: /// deba@1911: /// Returns the base node (the source in this case) of the iterator deba@1911: Node baseNode(OutEdgeIt e) const { deba@1911: return source(e); deba@1911: } deba@1911: deba@1911: /// \brief Running node of the iterator deba@1911: /// deba@1911: /// Returns the running node (the target in this case) of the deba@1911: /// iterator deba@1911: Node runningNode(OutEdgeIt e) const { deba@1911: return target(e); deba@1911: } deba@1911: deba@1911: /// \brief Base node of the iterator deba@1911: /// deba@1911: /// Returns the base node (the target in this case) of the iterator deba@1911: Node baseNode(InEdgeIt e) const { deba@1911: return target(e); deba@1911: } deba@1911: /// \brief Running node of the iterator deba@1911: /// deba@1911: /// Returns the running node (the source in this case) of the deba@1911: /// iterator deba@1911: Node runningNode(InEdgeIt e) const { deba@1911: return source(e); deba@1911: } deba@1911: deba@1911: /// \brief Base node of the iterator deba@1911: /// deba@1911: /// Returns the base node of the iterator deba@1911: Node baseNode(IncEdgeIt) const { deba@1911: return INVALID; deba@1911: } deba@1911: deba@1911: /// \brief Running node of the iterator deba@1911: /// deba@1911: /// Returns the running node of the iterator deba@1911: Node runningNode(IncEdgeIt) const { deba@1911: return INVALID; deba@1911: } deba@1911: deba@2231: void first(Node&) const {} deba@2231: void next(Node&) const {} deba@2231: deba@2231: void first(Edge&) const {} deba@2231: void next(Edge&) const {} deba@2231: deba@2231: void first(UEdge&) const {} deba@2231: void next(UEdge&) const {} deba@2231: deba@2231: void firstANode(Node&) const {} deba@2231: void nextANode(Node&) const {} deba@2231: deba@2231: void firstBNode(Node&) const {} deba@2231: void nextBNode(Node&) const {} deba@2231: deba@2231: void firstIn(Edge&, const Node&) const {} deba@2231: void nextIn(Edge&) const {} deba@2231: deba@2231: void firstOut(Edge&, const Node&) const {} deba@2231: void nextOut(Edge&) const {} deba@2231: deba@2231: void firstInc(UEdge &, bool &, const Node &) const {} deba@2231: void nextInc(UEdge &, bool &) const {} deba@2231: deba@2231: void firstFromANode(UEdge&, const Node&) const {} deba@2231: void nextFromANode(UEdge&) const {} deba@2231: deba@2231: void firstFromBNode(UEdge&, const Node&) const {} deba@2231: void nextFromBNode(UEdge&) const {} deba@2231: deba@1911: template deba@1911: struct Constraints { deba@1911: void constraints() { deba@2231: checkConcept, Graph>(); deba@2231: checkConcept, Graph>(); deba@1911: } deba@1911: }; deba@1911: deba@1911: }; deba@1911: deba@1911: deba@1911: /// @} deba@1911: deba@1911: } deba@1911: deba@1911: } deba@1911: deba@1911: #endif