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