deba@1018: /* -*- mode: C++; indent-tabs-mode: nil; -*- deba@1018: * deba@1018: * This file is a part of LEMON, a generic C++ optimization library. deba@1018: * deba@1018: * Copyright (C) 2003-2010 deba@1018: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport deba@1018: * (Egervary Research Group on Combinatorial Optimization, EGRES). deba@1018: * deba@1018: * Permission to use, modify and distribute this software is granted deba@1018: * provided that this copyright notice appears in all copies. For deba@1018: * precise terms see the accompanying LICENSE file. deba@1018: * deba@1018: * This software is provided "AS IS" with no warranty of any kind, deba@1018: * express or implied, and with no claim as to its suitability for any deba@1018: * purpose. deba@1018: * deba@1018: */ deba@1018: deba@1018: ///\ingroup graph_concepts deba@1018: ///\file deba@1018: ///\brief The concept of undirected graphs. deba@1018: deba@1018: #ifndef LEMON_CONCEPTS_BPGRAPH_H deba@1018: #define LEMON_CONCEPTS_BPGRAPH_H deba@1018: deba@1018: #include deba@1018: #include deba@1018: #include deba@1018: #include deba@1018: deba@1018: namespace lemon { deba@1018: namespace concepts { deba@1018: deba@1018: /// \ingroup graph_concepts deba@1018: /// deba@1018: /// \brief Class describing the concept of undirected bipartite graphs. deba@1018: /// deba@1018: /// This class describes the common interface of all undirected deba@1018: /// bipartite graphs. deba@1018: /// deba@1018: /// Like all concept classes, it only provides an interface deba@1018: /// without any sensible implementation. So any general algorithm for deba@1018: /// undirected bipartite graphs should compile with this class, deba@1018: /// but it will not run properly, of course. deba@1018: /// An actual graph implementation like \ref ListBpGraph or deba@1018: /// \ref SmartBpGraph may have additional functionality. deba@1018: /// deba@1018: /// The bipartite graphs also fulfill the concept of \ref Graph deba@1018: /// "undirected graphs". Bipartite graphs provide a bipartition of deba@1018: /// the node set, namely a red and blue set of the nodes. The deba@1026: /// nodes can be iterated with the RedNodeIt and BlueNodeIt in the deba@1026: /// two node sets. With RedNodeMap and BlueNodeMap values can be deba@1026: /// assigned to the nodes in the two sets. deba@1018: /// deba@1018: /// The edges of the graph cannot connect two nodes of the same deba@1018: /// set. The edges inherent orientation is from the red nodes to deba@1018: /// the blue nodes. deba@1018: /// deba@1018: /// \sa Graph deba@1018: class BpGraph { deba@1018: private: deba@1018: /// BpGraphs are \e not copy constructible. Use bpGraphCopy instead. deba@1018: BpGraph(const BpGraph&) {} deba@1018: /// \brief Assignment of a graph to another one is \e not allowed. deba@1018: /// Use bpGraphCopy instead. deba@1018: void operator=(const BpGraph&) {} deba@1018: deba@1018: public: deba@1018: /// Default constructor. deba@1018: BpGraph() {} deba@1018: deba@1018: /// \brief Undirected graphs should be tagged with \c UndirectedTag. deba@1018: /// deba@1018: /// Undirected graphs should be tagged with \c UndirectedTag. deba@1018: /// deba@1018: /// This tag helps the \c enable_if technics to make compile time deba@1018: /// specializations for undirected graphs. deba@1018: typedef True UndirectedTag; deba@1018: deba@1018: /// The node type of the graph deba@1018: deba@1018: /// This class identifies a node of the graph. It also serves deba@1018: /// as a base class of the node iterators, deba@1018: /// thus they convert to this type. deba@1018: class Node { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the object to an undefined value. deba@1018: Node() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: Node(const Node&) { } deba@1018: deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the object to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: Node(Invalid) { } deba@1018: /// Equality operator deba@1018: deba@1018: /// Equality operator. deba@1018: /// deba@1018: /// Two iterators are equal if and only if they point to the deba@1018: /// same object or both are \c INVALID. deba@1018: bool operator==(Node) const { return true; } deba@1018: deba@1018: /// Inequality operator deba@1018: deba@1018: /// Inequality operator. deba@1018: bool operator!=(Node) const { return true; } deba@1018: deba@1018: /// Artificial ordering operator. deba@1018: deba@1018: /// Artificial ordering operator. deba@1018: /// deba@1018: /// \note This operator only has to define some strict ordering of deba@1018: /// the items; this order has nothing to do with the iteration deba@1018: /// ordering of the items. deba@1018: bool operator<(Node) const { return false; } deba@1018: deba@1018: }; deba@1018: deba@1018: /// Class to represent red nodes. deba@1018: deba@1018: /// This class represents the red nodes of the graph. It does deba@1018: /// not supposed to be used directly, because the nodes can be deba@1018: /// represented as Node instances. This class can be used as deba@1018: /// template parameter for special map classes. deba@1018: class RedNode : public Node { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the object to an undefined value. deba@1018: RedNode() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: RedNode(const RedNode&) : Node() { } deba@1018: deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the object to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: RedNode(Invalid) { } deba@1018: deba@1018: }; deba@1018: deba@1018: /// Class to represent blue nodes. deba@1018: deba@1018: /// This class represents the blue nodes of the graph. It does deba@1018: /// not supposed to be used directly, because the nodes can be deba@1018: /// represented as Node instances. This class can be used as deba@1018: /// template parameter for special map classes. deba@1018: class BlueNode : public Node { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the object to an undefined value. deba@1018: BlueNode() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: BlueNode(const BlueNode&) : Node() { } deba@1018: deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the object to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: BlueNode(Invalid) { } deba@1018: deba@1018: }; deba@1018: deba@1018: /// Iterator class for the red nodes. deba@1018: deba@1018: /// This iterator goes through each red node of the graph. deba@1018: /// Its usage is quite simple, for example, you can count the number deba@1018: /// of red nodes in a graph \c g of type \c %BpGraph like this: deba@1018: ///\code deba@1018: /// int count=0; deba@1018: /// for (BpGraph::RedNodeIt n(g); n!=INVALID; ++n) ++count; deba@1018: ///\endcode deba@1026: class RedNodeIt : public RedNode { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the iterator to an undefined value. deba@1026: RedNodeIt() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1026: RedNodeIt(const RedNodeIt& n) : RedNode(n) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the iterator to be invalid. deba@1018: /// \sa Invalid for more details. deba@1026: RedNodeIt(Invalid) { } deba@1018: /// Sets the iterator to the first red node. deba@1018: deba@1018: /// Sets the iterator to the first red node of the given deba@1018: /// digraph. deba@1026: explicit RedNodeIt(const BpGraph&) { } deba@1018: /// Sets the iterator to the given red node. deba@1018: deba@1018: /// Sets the iterator to the given red node of the given deba@1018: /// digraph. deba@1026: RedNodeIt(const BpGraph&, const RedNode&) { } deba@1018: /// Next node. deba@1018: deba@1018: /// Assign the iterator to the next red node. deba@1018: /// deba@1026: RedNodeIt& operator++() { return *this; } deba@1018: }; deba@1018: deba@1018: /// Iterator class for the blue nodes. deba@1018: deba@1018: /// This iterator goes through each blue node of the graph. deba@1018: /// Its usage is quite simple, for example, you can count the number deba@1018: /// of blue nodes in a graph \c g of type \c %BpGraph like this: deba@1018: ///\code deba@1018: /// int count=0; deba@1018: /// for (BpGraph::BlueNodeIt n(g); n!=INVALID; ++n) ++count; deba@1018: ///\endcode deba@1026: class BlueNodeIt : public BlueNode { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the iterator to an undefined value. deba@1026: BlueNodeIt() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1026: BlueNodeIt(const BlueNodeIt& n) : BlueNode(n) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the iterator to be invalid. deba@1018: /// \sa Invalid for more details. deba@1026: BlueNodeIt(Invalid) { } deba@1018: /// Sets the iterator to the first blue node. deba@1018: deba@1018: /// Sets the iterator to the first blue node of the given deba@1018: /// digraph. deba@1026: explicit BlueNodeIt(const BpGraph&) { } deba@1018: /// Sets the iterator to the given blue node. deba@1018: deba@1018: /// Sets the iterator to the given blue node of the given deba@1018: /// digraph. deba@1026: BlueNodeIt(const BpGraph&, const BlueNode&) { } deba@1018: /// Next node. deba@1018: deba@1018: /// Assign the iterator to the next blue node. deba@1018: /// deba@1026: BlueNodeIt& operator++() { return *this; } deba@1018: }; deba@1018: deba@1018: /// Iterator class for the nodes. deba@1018: deba@1018: /// This iterator goes through each node of the graph. deba@1018: /// Its usage is quite simple, for example, you can count the number deba@1018: /// of nodes in a graph \c g of type \c %BpGraph like this: deba@1018: ///\code deba@1018: /// int count=0; deba@1018: /// for (BpGraph::NodeIt n(g); n!=INVALID; ++n) ++count; deba@1018: ///\endcode deba@1018: class NodeIt : public Node { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the iterator to an undefined value. deba@1018: NodeIt() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: NodeIt(const NodeIt& n) : Node(n) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the iterator to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: NodeIt(Invalid) { } deba@1018: /// Sets the iterator to the first node. deba@1018: deba@1018: /// Sets the iterator to the first node of the given digraph. deba@1018: /// deba@1018: explicit NodeIt(const BpGraph&) { } deba@1018: /// Sets the iterator to the given node. deba@1018: deba@1018: /// Sets the iterator to the given node of the given digraph. deba@1018: /// deba@1018: NodeIt(const BpGraph&, const Node&) { } deba@1018: /// Next node. deba@1018: deba@1018: /// Assign the iterator to the next node. deba@1018: /// deba@1018: NodeIt& operator++() { return *this; } deba@1018: }; deba@1018: deba@1018: deba@1018: /// The edge type of the graph deba@1018: deba@1018: /// This class identifies an edge of the graph. It also serves deba@1018: /// as a base class of the edge iterators, deba@1018: /// thus they will convert to this type. deba@1018: class Edge { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the object to an undefined value. deba@1018: Edge() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: Edge(const Edge&) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the object to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: Edge(Invalid) { } deba@1018: /// Equality operator deba@1018: deba@1018: /// Equality operator. deba@1018: /// deba@1018: /// Two iterators are equal if and only if they point to the deba@1018: /// same object or both are \c INVALID. deba@1018: bool operator==(Edge) const { return true; } deba@1018: /// Inequality operator deba@1018: deba@1018: /// Inequality operator. deba@1018: bool operator!=(Edge) const { return true; } deba@1018: deba@1018: /// Artificial ordering operator. deba@1018: deba@1018: /// Artificial ordering operator. deba@1018: /// deba@1018: /// \note This operator only has to define some strict ordering of deba@1018: /// the edges; this order has nothing to do with the iteration deba@1018: /// ordering of the edges. deba@1018: bool operator<(Edge) const { return false; } deba@1018: }; deba@1018: deba@1018: /// Iterator class for the edges. deba@1018: deba@1018: /// This iterator goes through each edge of the graph. deba@1018: /// Its usage is quite simple, for example, you can count the number deba@1018: /// of edges in a graph \c g of type \c %BpGraph as follows: deba@1018: ///\code deba@1018: /// int count=0; deba@1018: /// for(BpGraph::EdgeIt e(g); e!=INVALID; ++e) ++count; deba@1018: ///\endcode deba@1018: class EdgeIt : public Edge { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the iterator to an undefined value. deba@1018: EdgeIt() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: EdgeIt(const EdgeIt& e) : Edge(e) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the iterator to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: EdgeIt(Invalid) { } deba@1018: /// Sets the iterator to the first edge. deba@1018: deba@1018: /// Sets the iterator to the first edge of the given graph. deba@1018: /// deba@1018: explicit EdgeIt(const BpGraph&) { } deba@1018: /// Sets the iterator to the given edge. deba@1018: deba@1018: /// Sets the iterator to the given edge of the given graph. deba@1018: /// deba@1018: EdgeIt(const BpGraph&, const Edge&) { } deba@1018: /// Next edge deba@1018: deba@1018: /// Assign the iterator to the next edge. deba@1018: /// deba@1018: EdgeIt& operator++() { return *this; } deba@1018: }; deba@1018: deba@1018: /// Iterator class for the incident edges of a node. deba@1018: deba@1018: /// This iterator goes trough the incident undirected edges deba@1018: /// of a certain node of a graph. deba@1018: /// Its usage is quite simple, for example, you can compute the deba@1018: /// degree (i.e. the number of incident edges) of a node \c n deba@1018: /// in a graph \c g of type \c %BpGraph as follows. deba@1018: /// deba@1018: ///\code deba@1018: /// int count=0; deba@1018: /// for(BpGraph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count; deba@1018: ///\endcode deba@1018: /// deba@1018: /// \warning Loop edges will be iterated twice. deba@1018: class IncEdgeIt : public Edge { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the iterator to an undefined value. deba@1018: IncEdgeIt() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: IncEdgeIt(const IncEdgeIt& e) : Edge(e) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the iterator to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: IncEdgeIt(Invalid) { } deba@1018: /// Sets the iterator to the first incident edge. deba@1018: deba@1018: /// Sets the iterator to the first incident edge of the given node. deba@1018: /// deba@1018: IncEdgeIt(const BpGraph&, const Node&) { } deba@1018: /// Sets the iterator to the given edge. deba@1018: deba@1018: /// Sets the iterator to the given edge of the given graph. deba@1018: /// deba@1018: IncEdgeIt(const BpGraph&, const Edge&) { } deba@1018: /// Next incident edge deba@1018: deba@1018: /// Assign the iterator to the next incident edge deba@1018: /// of the corresponding node. deba@1018: IncEdgeIt& operator++() { return *this; } deba@1018: }; deba@1018: deba@1018: /// The arc type of the graph deba@1018: deba@1018: /// This class identifies a directed arc of the graph. It also serves deba@1018: /// as a base class of the arc iterators, deba@1018: /// thus they will convert to this type. deba@1018: class Arc { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the object to an undefined value. deba@1018: Arc() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: Arc(const Arc&) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the object to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: Arc(Invalid) { } deba@1018: /// Equality operator deba@1018: deba@1018: /// Equality operator. deba@1018: /// deba@1018: /// Two iterators are equal if and only if they point to the deba@1018: /// same object or both are \c INVALID. deba@1018: bool operator==(Arc) const { return true; } deba@1018: /// Inequality operator deba@1018: deba@1018: /// Inequality operator. deba@1018: bool operator!=(Arc) const { return true; } deba@1018: deba@1018: /// Artificial ordering operator. deba@1018: deba@1018: /// Artificial ordering operator. deba@1018: /// deba@1018: /// \note This operator only has to define some strict ordering of deba@1018: /// the arcs; this order has nothing to do with the iteration deba@1018: /// ordering of the arcs. deba@1018: bool operator<(Arc) const { return false; } deba@1018: deba@1018: /// Converison to \c Edge deba@1018: deba@1018: /// Converison to \c Edge. deba@1018: /// deba@1018: operator Edge() const { return Edge(); } deba@1018: }; deba@1018: deba@1018: /// Iterator class for the arcs. deba@1018: deba@1018: /// This iterator goes through each directed arc of the graph. deba@1018: /// Its usage is quite simple, for example, you can count the number deba@1018: /// of arcs in a graph \c g of type \c %BpGraph as follows: deba@1018: ///\code deba@1018: /// int count=0; deba@1018: /// for(BpGraph::ArcIt a(g); a!=INVALID; ++a) ++count; deba@1018: ///\endcode deba@1018: class ArcIt : public Arc { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the iterator to an undefined value. deba@1018: ArcIt() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: ArcIt(const ArcIt& e) : Arc(e) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the iterator to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: ArcIt(Invalid) { } deba@1018: /// Sets the iterator to the first arc. deba@1018: deba@1018: /// Sets the iterator to the first arc of the given graph. deba@1018: /// deba@1018: explicit ArcIt(const BpGraph &g) { ignore_unused_variable_warning(g); } deba@1018: /// Sets the iterator to the given arc. deba@1018: deba@1018: /// Sets the iterator to the given arc of the given graph. deba@1018: /// deba@1018: ArcIt(const BpGraph&, const Arc&) { } deba@1018: /// Next arc deba@1018: deba@1018: /// Assign the iterator to the next arc. deba@1018: /// deba@1018: ArcIt& operator++() { return *this; } deba@1018: }; deba@1018: deba@1018: /// Iterator class for the outgoing arcs of a node. deba@1018: deba@1018: /// This iterator goes trough the \e outgoing directed arcs of a deba@1018: /// certain node of a graph. deba@1018: /// Its usage is quite simple, for example, you can count the number deba@1018: /// of outgoing arcs of a node \c n deba@1018: /// in a graph \c g of type \c %BpGraph as follows. deba@1018: ///\code deba@1018: /// int count=0; deba@1018: /// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count; deba@1018: ///\endcode deba@1018: class OutArcIt : public Arc { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the iterator to an undefined value. deba@1018: OutArcIt() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: OutArcIt(const OutArcIt& e) : Arc(e) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the iterator to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: OutArcIt(Invalid) { } deba@1018: /// Sets the iterator to the first outgoing arc. deba@1018: deba@1018: /// Sets the iterator to the first outgoing arc of the given node. deba@1018: /// deba@1018: OutArcIt(const BpGraph& n, const Node& g) { deba@1018: ignore_unused_variable_warning(n); deba@1018: ignore_unused_variable_warning(g); deba@1018: } deba@1018: /// Sets the iterator to the given arc. deba@1018: deba@1018: /// Sets the iterator to the given arc of the given graph. deba@1018: /// deba@1018: OutArcIt(const BpGraph&, const Arc&) { } deba@1018: /// Next outgoing arc deba@1018: deba@1018: /// Assign the iterator to the next deba@1018: /// outgoing arc of the corresponding node. deba@1018: OutArcIt& operator++() { return *this; } deba@1018: }; deba@1018: deba@1018: /// Iterator class for the incoming arcs of a node. deba@1018: deba@1018: /// This iterator goes trough the \e incoming directed arcs of a deba@1018: /// certain node of a graph. deba@1018: /// Its usage is quite simple, for example, you can count the number deba@1018: /// of incoming arcs of a node \c n deba@1018: /// in a graph \c g of type \c %BpGraph as follows. deba@1018: ///\code deba@1018: /// int count=0; deba@1018: /// for (Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count; deba@1018: ///\endcode deba@1018: class InArcIt : public Arc { deba@1018: public: deba@1018: /// Default constructor deba@1018: deba@1018: /// Default constructor. deba@1018: /// \warning It sets the iterator to an undefined value. deba@1018: InArcIt() { } deba@1018: /// Copy constructor. deba@1018: deba@1018: /// Copy constructor. deba@1018: /// deba@1018: InArcIt(const InArcIt& e) : Arc(e) { } deba@1018: /// %Invalid constructor \& conversion. deba@1018: deba@1018: /// Initializes the iterator to be invalid. deba@1018: /// \sa Invalid for more details. deba@1018: InArcIt(Invalid) { } deba@1018: /// Sets the iterator to the first incoming arc. deba@1018: deba@1018: /// Sets the iterator to the first incoming arc of the given node. deba@1018: /// deba@1018: InArcIt(const BpGraph& g, const Node& n) { deba@1018: ignore_unused_variable_warning(n); deba@1018: ignore_unused_variable_warning(g); deba@1018: } deba@1018: /// Sets the iterator to the given arc. deba@1018: deba@1018: /// Sets the iterator to the given arc of the given graph. deba@1018: /// deba@1018: InArcIt(const BpGraph&, const Arc&) { } deba@1018: /// Next incoming arc deba@1018: deba@1018: /// Assign the iterator to the next deba@1018: /// incoming arc of the corresponding node. deba@1018: InArcIt& operator++() { return *this; } deba@1018: }; deba@1018: deba@1018: /// \brief Standard graph map type for the nodes. deba@1018: /// deba@1018: /// Standard graph map type for the nodes. deba@1018: /// It conforms to the ReferenceMap concept. deba@1018: template deba@1018: class NodeMap : public ReferenceMap deba@1018: { deba@1018: public: deba@1018: deba@1018: /// Constructor deba@1018: explicit NodeMap(const BpGraph&) { } deba@1018: /// Constructor with given initial value deba@1018: NodeMap(const BpGraph&, T) { } deba@1018: deba@1018: private: deba@1018: ///Copy constructor deba@1018: NodeMap(const NodeMap& nm) : deba@1018: ReferenceMap(nm) { } deba@1018: ///Assignment operator deba@1018: template deba@1018: NodeMap& operator=(const CMap&) { deba@1018: checkConcept, CMap>(); deba@1018: return *this; deba@1018: } deba@1018: }; deba@1018: deba@1018: /// \brief Standard graph map type for the red nodes. deba@1018: /// deba@1018: /// Standard graph map type for the red nodes. deba@1018: /// It conforms to the ReferenceMap concept. deba@1018: template deba@1026: class RedNodeMap : public ReferenceMap deba@1018: { deba@1018: public: deba@1018: deba@1018: /// Constructor deba@1026: explicit RedNodeMap(const BpGraph&) { } deba@1018: /// Constructor with given initial value deba@1026: RedNodeMap(const BpGraph&, T) { } deba@1018: deba@1018: private: deba@1018: ///Copy constructor deba@1026: RedNodeMap(const RedNodeMap& nm) : deba@1018: ReferenceMap(nm) { } deba@1018: ///Assignment operator deba@1018: template deba@1026: RedNodeMap& operator=(const CMap&) { deba@1018: checkConcept, CMap>(); deba@1018: return *this; deba@1018: } deba@1018: }; deba@1018: deba@1018: /// \brief Standard graph map type for the blue nodes. deba@1018: /// deba@1018: /// Standard graph map type for the blue nodes. deba@1018: /// It conforms to the ReferenceMap concept. deba@1018: template deba@1026: class BlueNodeMap : public ReferenceMap deba@1018: { deba@1018: public: deba@1018: deba@1018: /// Constructor deba@1026: explicit BlueNodeMap(const BpGraph&) { } deba@1018: /// Constructor with given initial value deba@1026: BlueNodeMap(const BpGraph&, T) { } deba@1018: deba@1018: private: deba@1018: ///Copy constructor deba@1026: BlueNodeMap(const BlueNodeMap& nm) : deba@1018: ReferenceMap(nm) { } deba@1018: ///Assignment operator deba@1018: template deba@1026: BlueNodeMap& operator=(const CMap&) { deba@1018: checkConcept, CMap>(); deba@1018: return *this; deba@1018: } deba@1018: }; deba@1018: deba@1018: /// \brief Standard graph map type for the arcs. deba@1018: /// deba@1018: /// Standard graph map type for the arcs. deba@1018: /// It conforms to the ReferenceMap concept. deba@1018: template deba@1018: class ArcMap : public ReferenceMap deba@1018: { deba@1018: public: deba@1018: deba@1018: /// Constructor deba@1018: explicit ArcMap(const BpGraph&) { } deba@1018: /// Constructor with given initial value deba@1018: ArcMap(const BpGraph&, T) { } deba@1018: deba@1018: private: deba@1018: ///Copy constructor deba@1018: ArcMap(const ArcMap& em) : deba@1018: ReferenceMap(em) { } deba@1018: ///Assignment operator deba@1018: template deba@1018: ArcMap& operator=(const CMap&) { deba@1018: checkConcept, CMap>(); deba@1018: return *this; deba@1018: } deba@1018: }; deba@1018: deba@1018: /// \brief Standard graph map type for the edges. deba@1018: /// deba@1018: /// Standard graph map type for the edges. deba@1018: /// It conforms to the ReferenceMap concept. deba@1018: template deba@1018: class EdgeMap : public ReferenceMap deba@1018: { deba@1018: public: deba@1018: deba@1018: /// Constructor deba@1018: explicit EdgeMap(const BpGraph&) { } deba@1018: /// Constructor with given initial value deba@1018: EdgeMap(const BpGraph&, T) { } deba@1018: deba@1018: private: deba@1018: ///Copy constructor deba@1018: EdgeMap(const EdgeMap& em) : deba@1018: ReferenceMap(em) {} deba@1018: ///Assignment operator deba@1018: template deba@1018: EdgeMap& operator=(const CMap&) { deba@1018: checkConcept, CMap>(); deba@1018: return *this; deba@1018: } deba@1018: }; deba@1018: deba@1018: /// \brief Gives back %true for red nodes. deba@1018: /// deba@1018: /// Gives back %true for red nodes. deba@1018: bool red(const Node&) const { return true; } deba@1018: deba@1018: /// \brief Gives back %true for blue nodes. deba@1018: /// deba@1018: /// Gives back %true for blue nodes. deba@1018: bool blue(const Node&) const { return true; } deba@1018: deba@1025: /// \brief Converts the node to red node object. deba@1025: /// deba@1025: /// This class is converts unsafely the node to red node deba@1025: /// object. It should be called only if the node is from the red deba@1025: /// partition or INVALID. deba@1025: RedNode asRedNodeUnsafe(const Node&) const { return RedNode(); } deba@1025: deba@1025: /// \brief Converts the node to blue node object. deba@1025: /// deba@1025: /// This class is converts unsafely the node to blue node deba@1025: /// object. It should be called only if the node is from the red deba@1025: /// partition or INVALID. deba@1025: BlueNode asBlueNodeUnsafe(const Node&) const { return BlueNode(); } deba@1025: deba@1025: /// \brief Converts the node to red node object. deba@1025: /// deba@1025: /// This class is converts safely the node to red node deba@1025: /// object. If the node is not from the red partition, then it deba@1025: /// returns INVALID. deba@1025: RedNode asRedNode(const Node&) const { return RedNode(); } deba@1025: deba@1025: /// \brief Converts the node to blue node object. deba@1025: /// deba@1025: /// This class is converts unsafely the node to blue node deba@1025: /// object. If the node is not from the blue partition, then it deba@1025: /// returns INVALID. deba@1025: BlueNode asBlueNode(const Node&) const { return BlueNode(); } deba@1025: deba@1018: /// \brief Gives back the red end node of the edge. deba@1018: /// deba@1018: /// Gives back the red end node of the edge. deba@1025: RedNode redNode(const Edge&) const { return RedNode(); } deba@1018: deba@1018: /// \brief Gives back the blue end node of the edge. deba@1018: /// deba@1018: /// Gives back the blue end node of the edge. deba@1025: BlueNode blueNode(const Edge&) const { return BlueNode(); } deba@1018: deba@1018: /// \brief The first node of the edge. deba@1018: /// deba@1018: /// It is a synonim for the \c redNode(). deba@1018: Node u(Edge) const { return INVALID; } deba@1018: deba@1018: /// \brief The second node of the edge. deba@1018: /// deba@1018: /// It is a synonim for the \c blueNode(). deba@1018: Node v(Edge) const { return INVALID; } deba@1018: deba@1018: /// \brief The source node of the arc. deba@1018: /// deba@1018: /// Returns the source node of the given arc. deba@1018: Node source(Arc) const { return INVALID; } deba@1018: deba@1018: /// \brief The target node of the arc. deba@1018: /// deba@1018: /// Returns the target node of the given arc. deba@1018: Node target(Arc) const { return INVALID; } deba@1018: deba@1018: /// \brief The ID of the node. deba@1018: /// deba@1018: /// Returns the ID of the given node. deba@1018: int id(Node) const { return -1; } deba@1018: deba@1018: /// \brief The red ID of the node. deba@1018: /// deba@1018: /// Returns the red ID of the given node. deba@1018: int id(RedNode) const { return -1; } deba@1018: deba@1018: /// \brief The blue ID of the node. deba@1018: /// deba@1018: /// Returns the blue ID of the given node. deba@1018: int id(BlueNode) const { return -1; } deba@1018: deba@1018: /// \brief The ID of the edge. deba@1018: /// deba@1018: /// Returns the ID of the given edge. deba@1018: int id(Edge) const { return -1; } deba@1018: deba@1018: /// \brief The ID of the arc. deba@1018: /// deba@1018: /// Returns the ID of the given arc. deba@1018: int id(Arc) const { return -1; } deba@1018: deba@1018: /// \brief The node with the given ID. deba@1018: /// deba@1018: /// Returns the node with the given ID. deba@1018: /// \pre The argument should be a valid node ID in the graph. deba@1018: Node nodeFromId(int) const { return INVALID; } deba@1018: deba@1018: /// \brief The edge with the given ID. deba@1018: /// deba@1018: /// Returns the edge with the given ID. deba@1018: /// \pre The argument should be a valid edge ID in the graph. deba@1018: Edge edgeFromId(int) const { return INVALID; } deba@1018: deba@1018: /// \brief The arc with the given ID. deba@1018: /// deba@1018: /// Returns the arc with the given ID. deba@1018: /// \pre The argument should be a valid arc ID in the graph. deba@1018: Arc arcFromId(int) const { return INVALID; } deba@1018: deba@1018: /// \brief An upper bound on the node IDs. deba@1018: /// deba@1018: /// Returns an upper bound on the node IDs. deba@1018: int maxNodeId() const { return -1; } deba@1018: deba@1018: /// \brief An upper bound on the red IDs. deba@1018: /// deba@1018: /// Returns an upper bound on the red IDs. deba@1018: int maxRedId() const { return -1; } deba@1018: deba@1018: /// \brief An upper bound on the blue IDs. deba@1018: /// deba@1018: /// Returns an upper bound on the blue IDs. deba@1018: int maxBlueId() const { return -1; } deba@1018: deba@1018: /// \brief An upper bound on the edge IDs. deba@1018: /// deba@1018: /// Returns an upper bound on the edge IDs. deba@1018: int maxEdgeId() const { return -1; } deba@1018: deba@1018: /// \brief An upper bound on the arc IDs. deba@1018: /// deba@1018: /// Returns an upper bound on the arc IDs. deba@1018: int maxArcId() const { return -1; } deba@1018: deba@1018: /// \brief The direction of the arc. deba@1018: /// deba@1018: /// Returns \c true if the given arc goes from a red node to a blue node. deba@1018: bool direction(Arc) const { return true; } deba@1018: deba@1018: /// \brief Direct the edge. deba@1018: /// deba@1018: /// Direct the given edge. The returned arc deba@1018: /// represents the given edge and its direction comes deba@1018: /// from the bool parameter. If it is \c true, then the source of the node deba@1018: /// will be a red node. deba@1018: Arc direct(Edge, bool) const { deba@1018: return INVALID; deba@1018: } deba@1018: deba@1018: /// \brief Direct the edge. deba@1018: /// deba@1018: /// Direct the given edge. The returned arc represents the given deba@1018: /// edge and its source node is the given node. deba@1018: Arc direct(Edge, Node) const { deba@1018: return INVALID; deba@1018: } deba@1018: deba@1018: /// \brief The oppositely directed arc. deba@1018: /// deba@1018: /// Returns the oppositely directed arc representing the same edge. deba@1018: Arc oppositeArc(Arc) const { return INVALID; } deba@1018: deba@1018: /// \brief The opposite node on the edge. deba@1018: /// deba@1018: /// Returns the opposite node on the given edge. deba@1018: Node oppositeNode(Node, Edge) const { return INVALID; } deba@1018: deba@1018: void first(Node&) const {} deba@1018: void next(Node&) const {} deba@1018: deba@1025: void firstRed(RedNode&) const {} deba@1025: void nextRed(RedNode&) const {} deba@1018: deba@1025: void firstBlue(BlueNode&) const {} deba@1025: void nextBlue(BlueNode&) const {} deba@1018: deba@1018: void first(Edge&) const {} deba@1018: void next(Edge&) const {} deba@1018: deba@1018: void first(Arc&) const {} deba@1018: void next(Arc&) const {} deba@1018: deba@1018: void firstOut(Arc&, Node) const {} deba@1018: void nextOut(Arc&) const {} deba@1018: deba@1018: void firstIn(Arc&, Node) const {} deba@1018: void nextIn(Arc&) const {} deba@1018: deba@1018: void firstInc(Edge &, bool &, const Node &) const {} deba@1018: void nextInc(Edge &, bool &) const {} deba@1018: deba@1018: // The second parameter is dummy. deba@1018: Node fromId(int, Node) const { return INVALID; } deba@1018: // The second parameter is dummy. deba@1018: Edge fromId(int, Edge) const { return INVALID; } deba@1018: // The second parameter is dummy. deba@1018: Arc fromId(int, Arc) const { return INVALID; } deba@1018: deba@1018: // Dummy parameter. deba@1018: int maxId(Node) const { return -1; } deba@1018: // Dummy parameter. deba@1018: int maxId(RedNode) const { return -1; } deba@1018: // Dummy parameter. deba@1018: int maxId(BlueNode) const { return -1; } deba@1018: // Dummy parameter. deba@1018: int maxId(Edge) const { return -1; } deba@1018: // Dummy parameter. deba@1018: int maxId(Arc) const { return -1; } deba@1018: deba@1018: /// \brief The base node of the iterator. deba@1018: /// deba@1018: /// Returns the base node of the given incident edge iterator. deba@1018: Node baseNode(IncEdgeIt) const { return INVALID; } deba@1018: deba@1018: /// \brief The running node of the iterator. deba@1018: /// deba@1018: /// Returns the running node of the given incident edge iterator. deba@1018: Node runningNode(IncEdgeIt) const { return INVALID; } deba@1018: deba@1018: /// \brief The base node of the iterator. deba@1018: /// deba@1018: /// Returns the base node of the given outgoing arc iterator deba@1018: /// (i.e. the source node of the corresponding arc). deba@1018: Node baseNode(OutArcIt) const { return INVALID; } deba@1018: deba@1018: /// \brief The running node of the iterator. deba@1018: /// deba@1018: /// Returns the running node of the given outgoing arc iterator deba@1018: /// (i.e. the target node of the corresponding arc). deba@1018: Node runningNode(OutArcIt) const { return INVALID; } deba@1018: deba@1018: /// \brief The base node of the iterator. deba@1018: /// deba@1018: /// Returns the base node of the given incomming arc iterator deba@1018: /// (i.e. the target node of the corresponding arc). deba@1018: Node baseNode(InArcIt) const { return INVALID; } deba@1018: deba@1018: /// \brief The running node of the iterator. deba@1018: /// deba@1018: /// Returns the running node of the given incomming arc iterator deba@1018: /// (i.e. the source node of the corresponding arc). deba@1018: Node runningNode(InArcIt) const { return INVALID; } deba@1018: deba@1018: template deba@1018: struct Constraints { deba@1018: void constraints() { deba@1018: checkConcept(); deba@1018: checkConcept, _BpGraph>(); deba@1018: checkConcept, _BpGraph>(); deba@1018: checkConcept, _BpGraph>(); deba@1018: } deba@1018: }; deba@1018: deba@1018: }; deba@1018: deba@1018: } deba@1018: deba@1018: } deba@1018: deba@1018: #endif