klao@962: /* -*- C++ -*-
klao@962:  *
alpar@1956:  * This file is a part of LEMON, a generic C++ optimization library
klao@962:  *
alpar@1956:  * Copyright (C) 2003-2006
alpar@1956:  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@1956:  * (Egervary Research Group on Combinatorial Optimization, EGRES).
klao@962:  *
klao@962:  * Permission to use, modify and distribute this software is granted
klao@962:  * provided that this copyright notice appears in all copies. For
klao@962:  * precise terms see the accompanying LICENSE file.
klao@962:  *
klao@962:  * This software is provided "AS IS" with no warranty of any kind,
klao@962:  * express or implied, and with no claim as to its suitability for any
klao@962:  * purpose.
klao@962:  *
klao@962:  */
klao@962: 
klao@1030: ///\ingroup graph_concepts
klao@962: ///\file
deba@2111: ///\brief The concept of the undirected graphs.
klao@962: 
klao@962: 
deba@1910: #ifndef LEMON_CONCEPT_UGRAPH_H
deba@1910: #define LEMON_CONCEPT_UGRAPH_H
klao@962: 
deba@2126: #include <lemon/concept/graph_components.h>
alpar@1620: #include <lemon/concept/graph.h>
deba@1993: #include <lemon/bits/utility.h>
klao@962: 
klao@962: namespace lemon {
klao@962:   namespace concept {
klao@962: 
alpar@1620:     /// \addtogroup graph_concepts
alpar@1620:     /// @{
alpar@1620: 
alpar@1620: 
deba@2163:     /// \brief Class describing the concept of Undirected Graphs.
deba@2163:     ///
klao@1030:     /// This class describes the common interface of all Undirected
klao@1030:     /// Graphs.
klao@1030:     ///
klao@1030:     /// As all concept describing classes it provides only interface
klao@1030:     /// without any sensible implementation. So any algorithm for
klao@1030:     /// undirected graph should compile with this class, but it will not
deba@2163:     /// run properly, of course.
klao@1030:     ///
deba@2163:     /// The LEMON undirected graphs also fulfill the concept of
deba@2163:     /// directed graphs (\ref lemon::concept::Graph "Graph
deba@2163:     /// Concept"). Each undirected edges can be seen as two opposite
deba@2163:     /// directed edge and consequently the undirected graph can be
deba@2163:     /// seen as the direceted graph of these directed edges. The
deba@2163:     /// UGraph has the UEdge inner class for the undirected edges and
deba@2163:     /// the Edge type for the directed edges. The Edge type is
deba@2163:     /// convertible to UEdge or inherited from it so from a directed
deba@2163:     /// edge we can get the represented undirected edge.
deba@1627:     ///
deba@2163:     /// In the sense of the LEMON each undirected edge has a default
deba@2163:     /// direction (it should be in every computer implementation,
deba@2163:     /// because the order of undirected edge's nodes defines an
deba@2163:     /// orientation). With the default orientation we can define that
deba@2163:     /// the directed edge is forward or backward directed. With the \c
deba@2163:     /// direction() and \c direct() function we can get the direction
deba@2163:     /// of the directed edge and we can direct an undirected edge.
deba@2163:     ///
deba@2163:     /// The UEdgeIt is an iterator for the undirected edges. We can use
deba@2163:     /// the UEdgeMap to map values for the undirected edges. The InEdgeIt and
deba@2163:     /// OutEdgeIt iterates on the same undirected edges but with opposite
deba@2163:     /// direction. The IncEdgeIt iterates also on the same undirected edges
deba@2163:     /// as the OutEdgeIt and InEdgeIt but it is not convertible to Edge just
deba@2163:     /// to UEdge.  
klao@1909:     class UGraph {
klao@1022:     public:
deba@2163:       /// \brief The undirected graph should be tagged by the
deba@2163:       /// UndirectedTag.
alpar@1448:       ///
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;
klao@1022: 
deba@1669:       /// \brief The base type of node iterators, 
deba@1627:       /// or in other words, the trivial node iterator.
deba@1669:       ///
deba@1627:       /// This is the base type of each node iterator,
deba@1627:       /// thus each kind of node iterator converts to this.
deba@1627:       /// More precisely each kind of node iterator should be inherited 
deba@1627:       /// from the trivial node iterator.
deba@1627:       class Node {
deba@1627:       public:
deba@1627:         /// Default constructor
deba@1627: 
deba@1627:         /// @warning The default constructor sets the iterator
deba@1627:         /// to an undefined value.
deba@1627:         Node() { }
deba@1627:         /// Copy constructor.
deba@1627: 
deba@1627:         /// Copy constructor.
deba@1627:         ///
deba@1627:         Node(const Node&) { }
deba@1627: 
deba@1627:         /// Invalid constructor \& conversion.
deba@1627: 
deba@1627:         /// This constructor initializes the iterator to be invalid.
deba@1627:         /// \sa Invalid for more details.
deba@1627:         Node(Invalid) { }
deba@1627:         /// Equality operator
deba@1627: 
deba@1627:         /// Two iterators are equal if and only if they point to the
deba@1627:         /// same object or both are invalid.
deba@1627:         bool operator==(Node) const { return true; }
deba@1627: 
deba@1627:         /// Inequality operator
deba@1627:         
deba@1627:         /// \sa operator==(Node n)
deba@1627:         ///
deba@1627:         bool operator!=(Node) const { return true; }
deba@1627: 
deba@1627: 	/// Artificial ordering operator.
deba@1627: 	
deba@1627: 	/// To allow the use of graph descriptors as key type in std::map or
deba@1627: 	/// similar associative container we require this.
deba@1627: 	///
deba@1627: 	/// \note This operator only have to define some strict ordering of
deba@1627: 	/// the items; this order has nothing to do with the iteration
deba@1627: 	/// ordering of the items.
deba@1627: 	bool operator<(Node) const { return false; }
deba@1627: 
deba@1627:       };
deba@1627:     
deba@1627:       /// This iterator goes through each node.
deba@1627: 
deba@1627:       /// This iterator goes through each node.
deba@1627:       /// Its usage is quite simple, for example you can count the number
deba@1627:       /// of nodes in graph \c g of type \c Graph like this:
alpar@1946:       ///\code
deba@1627:       /// int count=0;
deba@1627:       /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
alpar@1946:       ///\endcode
deba@1627:       class NodeIt : public Node {
deba@1627:       public:
deba@1627:         /// Default constructor
deba@1627: 
deba@1627:         /// @warning The default constructor sets the iterator
deba@1627:         /// to an undefined value.
deba@1627:         NodeIt() { }
deba@1627:         /// Copy constructor.
deba@1627:         
deba@1627:         /// Copy constructor.
deba@1627:         ///
deba@1627:         NodeIt(const NodeIt& n) : Node(n) { }
deba@1627:         /// Invalid constructor \& conversion.
deba@1627: 
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627:         /// \sa Invalid for more details.
deba@1627:         NodeIt(Invalid) { }
deba@1627:         /// Sets the iterator to the first node.
deba@1627: 
deba@1627:         /// Sets the iterator to the first node of \c g.
deba@1627:         ///
klao@1909:         NodeIt(const UGraph&) { }
deba@1627:         /// Node -> NodeIt conversion.
deba@1627: 
deba@1627:         /// Sets the iterator to the node of \c the graph pointed by 
deba@1627: 	/// the trivial iterator.
deba@1627:         /// This feature necessitates that each time we 
deba@1627:         /// iterate the edge-set, the iteration order is the same.
klao@1909:         NodeIt(const UGraph&, const Node&) { }
deba@1627:         /// Next node.
deba@1627: 
deba@1627:         /// Assign the iterator to the next node.
deba@1627:         ///
deba@1627:         NodeIt& operator++() { return *this; }
deba@1627:       };
deba@1627:     
deba@1627:     
alpar@1620:       /// The base type of the undirected edge iterators.
deba@1627: 
alpar@1620:       /// The base type of the undirected edge iterators.
alpar@1620:       ///
klao@1909:       class UEdge {
alpar@1620:       public:
alpar@1620:         /// Default constructor
klao@1030: 
alpar@1620:         /// @warning The default constructor sets the iterator
alpar@1620:         /// to an undefined value.
klao@1909:         UEdge() { }
alpar@1620:         /// Copy constructor.
klao@1030: 
alpar@1620:         /// Copy constructor.
alpar@1620:         ///
klao@1909:         UEdge(const UEdge&) { }
alpar@1620:         /// Initialize the iterator to be invalid.
klao@1030: 
alpar@1620:         /// Initialize the iterator to be invalid.
alpar@1620:         ///
klao@1909:         UEdge(Invalid) { }
alpar@1620:         /// Equality operator
klao@1030: 
alpar@1620:         /// Two iterators are equal if and only if they point to the
alpar@1620:         /// same object or both are invalid.
klao@1909:         bool operator==(UEdge) const { return true; }
alpar@1620:         /// Inequality operator
klao@1030: 
klao@1909:         /// \sa operator==(UEdge n)
alpar@1620:         ///
klao@1909:         bool operator!=(UEdge) const { return true; }
klao@1030: 
deba@1627: 	/// Artificial ordering operator.
deba@1627: 	
deba@1627: 	/// To allow the use of graph descriptors as key type in std::map or
deba@1627: 	/// similar associative container we require this.
deba@1627: 	///
deba@1627: 	/// \note This operator only have to define some strict ordering of
deba@1627: 	/// the items; this order has nothing to do with the iteration
deba@1627: 	/// ordering of the items.
klao@1909: 	bool operator<(UEdge) const { return false; }
deba@1627:       };
klao@1030: 
alpar@1620:       /// This iterator goes through each undirected edge.
klao@1030: 
alpar@1620:       /// This iterator goes through each undirected edge of a graph.
alpar@1620:       /// Its usage is quite simple, for example you can count the number
deba@1627:       /// of undirected edges in a graph \c g of type \c Graph as follows:
alpar@1946:       ///\code
alpar@1620:       /// int count=0;
klao@1909:       /// for(Graph::UEdgeIt e(g); e!=INVALID; ++e) ++count;
alpar@1946:       ///\endcode
klao@1909:       class UEdgeIt : public UEdge {
alpar@1620:       public:
alpar@1620:         /// Default constructor
deba@1627: 
alpar@1620:         /// @warning The default constructor sets the iterator
alpar@1620:         /// to an undefined value.
klao@1909:         UEdgeIt() { }
alpar@1620:         /// Copy constructor.
deba@1627: 
alpar@1620:         /// Copy constructor.
alpar@1620:         ///
klao@1909:         UEdgeIt(const UEdgeIt& e) : UEdge(e) { }
alpar@1620:         /// Initialize the iterator to be invalid.
klao@1030: 
alpar@1620:         /// Initialize the iterator to be invalid.
alpar@1620:         ///
klao@1909:         UEdgeIt(Invalid) { }
deba@1627:         /// This constructor sets the iterator to the first undirected edge.
alpar@1620:     
deba@1627:         /// This constructor sets the iterator to the first undirected edge.
klao@1909:         UEdgeIt(const UGraph&) { }
klao@1909:         /// UEdge -> UEdgeIt conversion
klao@1030: 
deba@1627:         /// Sets the iterator to the value of the trivial iterator.
deba@1627:         /// This feature necessitates that each time we
deba@1627:         /// iterate the undirected edge-set, the iteration order is the 
deba@1627: 	/// same.
klao@1909:         UEdgeIt(const UGraph&, const UEdge&) { } 
deba@1627:         /// Next undirected edge
alpar@1620:         
deba@1627:         /// Assign the iterator to the next undirected edge.
klao@1909:         UEdgeIt& operator++() { return *this; }
alpar@1620:       };
klao@1030: 
deba@1627:       /// \brief This iterator goes trough the incident undirected 
deba@1627:       /// edges of a node.
deba@1627:       ///
alpar@1620:       /// This iterator goes trough the incident undirected edges
deba@2021:       /// of a certain node of a graph. You should assume that the 
deba@2021:       /// loop edges will be iterated twice.
deba@2021:       /// 
alpar@1620:       /// Its usage is quite simple, for example you can compute the
deba@2021:       /// degree (i.e. count the number of incident edges of a node \c n
deba@2021:       /// in graph \c g of type \c Graph as follows. 
deba@2021:       ///
alpar@1946:       ///\code
alpar@1620:       /// int count=0;
alpar@1620:       /// for(Graph::IncEdgeIt e(g, n); e!=INVALID; ++e) ++count;
alpar@1946:       ///\endcode
klao@1909:       class IncEdgeIt : public UEdge {
alpar@1620:       public:
alpar@1620:         /// Default constructor
klao@1030: 
alpar@1620:         /// @warning The default constructor sets the iterator
alpar@1620:         /// to an undefined value.
alpar@1620:         IncEdgeIt() { }
alpar@1620:         /// Copy constructor.
alpar@1620: 
alpar@1620:         /// Copy constructor.
alpar@1620:         ///
klao@1909:         IncEdgeIt(const IncEdgeIt& e) : UEdge(e) { }
alpar@1620:         /// Initialize the iterator to be invalid.
alpar@1620: 
alpar@1620:         /// Initialize the iterator to be invalid.
alpar@1620:         ///
alpar@1620:         IncEdgeIt(Invalid) { }
alpar@1620:         /// This constructor sets the iterator to first incident edge.
alpar@1620:     
alpar@1620:         /// This constructor set the iterator to the first incident edge of
alpar@1620:         /// the node.
klao@1909:         IncEdgeIt(const UGraph&, const Node&) { }
klao@1909:         /// UEdge -> IncEdgeIt conversion
alpar@1620: 
alpar@1620:         /// Sets the iterator to the value of the trivial iterator \c e.
alpar@1620:         /// This feature necessitates that each time we 
alpar@1620:         /// iterate the edge-set, the iteration order is the same.
klao@1909:         IncEdgeIt(const UGraph&, const UEdge&) { }
alpar@1620:         /// Next incident edge
alpar@1620: 
alpar@1620:         /// Assign the iterator to the next incident edge
alpar@1620: 	/// of the corresponding node.
alpar@1620:         IncEdgeIt& operator++() { return *this; }
alpar@1620:       };
alpar@1620: 
deba@1627:       /// The directed edge type.
deba@1627: 
deba@1627:       /// The directed edge type. It can be converted to the
deba@2163:       /// undirected edge or it should be inherited from the undirected
deba@2163:       /// edge.
klao@1909:       class Edge : public UEdge {
deba@1627:       public:
deba@1627:         /// Default constructor
deba@1627: 
deba@1627:         /// @warning The default constructor sets the iterator
deba@1627:         /// to an undefined value.
deba@1627:         Edge() { }
deba@1627:         /// Copy constructor.
deba@1627: 
deba@1627:         /// Copy constructor.
deba@1627:         ///
klao@1909:         Edge(const Edge& e) : UEdge(e) { }
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627: 
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627:         ///
deba@1627:         Edge(Invalid) { }
deba@1627:         /// Equality operator
deba@1627: 
deba@1627:         /// Two iterators are equal if and only if they point to the
deba@1627:         /// same object or both are invalid.
deba@1627:         bool operator==(Edge) const { return true; }
deba@1627:         /// Inequality operator
deba@1627: 
deba@1627:         /// \sa operator==(Edge n)
deba@1627:         ///
deba@1627:         bool operator!=(Edge) const { return true; }
deba@1627: 
deba@1627: 	/// Artificial ordering operator.
deba@1627: 	
deba@1627: 	/// To allow the use of graph descriptors as key type in std::map or
deba@1627: 	/// similar associative container we require this.
deba@1627: 	///
deba@1627: 	/// \note This operator only have to define some strict ordering of
deba@1627: 	/// the items; this order has nothing to do with the iteration
deba@1627: 	/// ordering of the items.
deba@1627: 	bool operator<(Edge) const { return false; }
deba@1627: 	
deba@1627:       }; 
deba@1627:       /// This iterator goes through each directed edge.
deba@1627: 
deba@1627:       /// This iterator goes through each edge of a graph.
deba@1627:       /// Its usage is quite simple, for example you can count the number
deba@1627:       /// of edges in a graph \c g of type \c Graph as follows:
alpar@1946:       ///\code
deba@1627:       /// int count=0;
deba@1627:       /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
alpar@1946:       ///\endcode
deba@1627:       class EdgeIt : public Edge {
deba@1627:       public:
deba@1627:         /// Default constructor
deba@1627: 
deba@1627:         /// @warning The default constructor sets the iterator
deba@1627:         /// to an undefined value.
deba@1627:         EdgeIt() { }
deba@1627:         /// Copy constructor.
deba@1627: 
deba@1627:         /// Copy constructor.
deba@1627:         ///
deba@1627:         EdgeIt(const EdgeIt& e) : Edge(e) { }
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627: 
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627:         ///
deba@1627:         EdgeIt(Invalid) { }
deba@1627:         /// This constructor sets the iterator to the first edge.
deba@1627:     
deba@1627:         /// This constructor sets the iterator to the first edge of \c g.
deba@1627:         ///@param g the graph
klao@1909:         EdgeIt(const UGraph &g) { ignore_unused_variable_warning(g); }
deba@1627:         /// Edge -> EdgeIt conversion
deba@1627: 
deba@1627:         /// Sets the iterator to the value of the trivial iterator \c e.
deba@1627:         /// This feature necessitates that each time we 
deba@1627:         /// iterate the edge-set, the iteration order is the same.
klao@1909:         EdgeIt(const UGraph&, const Edge&) { } 
deba@1627:         ///Next edge
deba@1627:         
deba@1627:         /// Assign the iterator to the next edge.
deba@1627:         EdgeIt& operator++() { return *this; }
deba@1627:       };
deba@1627:    
deba@1627:       /// This iterator goes trough the outgoing directed edges of a node.
deba@1627: 
deba@1627:       /// This iterator goes trough the \e outgoing edges of a certain node
deba@1627:       /// of a graph.
deba@1627:       /// Its usage is quite simple, for example you can count the number
deba@1627:       /// of outgoing edges of a node \c n
deba@1627:       /// in graph \c g of type \c Graph as follows.
alpar@1946:       ///\code
deba@1627:       /// int count=0;
deba@1627:       /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
alpar@1946:       ///\endcode
deba@1627:     
deba@1627:       class OutEdgeIt : public Edge {
deba@1627:       public:
deba@1627:         /// Default constructor
deba@1627: 
deba@1627:         /// @warning The default constructor sets the iterator
deba@1627:         /// to an undefined value.
deba@1627:         OutEdgeIt() { }
deba@1627:         /// Copy constructor.
deba@1627: 
deba@1627:         /// Copy constructor.
deba@1627:         ///
deba@1627:         OutEdgeIt(const OutEdgeIt& e) : Edge(e) { }
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627: 
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627:         ///
deba@1627:         OutEdgeIt(Invalid) { }
deba@1627:         /// This constructor sets the iterator to the first outgoing edge.
deba@1627:     
deba@1627:         /// This constructor sets the iterator to the first outgoing edge of
deba@1627:         /// the node.
deba@1627:         ///@param n the node
deba@1627:         ///@param g the graph
klao@1909:         OutEdgeIt(const UGraph& n, const Node& g) {
alpar@1643: 	  ignore_unused_variable_warning(n);
alpar@1643: 	  ignore_unused_variable_warning(g);
alpar@1643: 	}
deba@1627:         /// Edge -> OutEdgeIt conversion
deba@1627: 
deba@1627:         /// Sets the iterator to the value of the trivial iterator.
deba@1627: 	/// This feature necessitates that each time we 
deba@1627:         /// iterate the edge-set, the iteration order is the same.
klao@1909:         OutEdgeIt(const UGraph&, const Edge&) { }
deba@1627:         ///Next outgoing edge
deba@1627:         
deba@1627:         /// Assign the iterator to the next 
deba@1627:         /// outgoing edge of the corresponding node.
deba@1627:         OutEdgeIt& operator++() { return *this; }
deba@1627:       };
deba@1627: 
deba@1627:       /// This iterator goes trough the incoming directed edges of a node.
deba@1627: 
deba@1627:       /// This iterator goes trough the \e incoming edges of a certain node
deba@1627:       /// of a graph.
deba@1627:       /// Its usage is quite simple, for example you can count the number
deba@1627:       /// of outgoing edges of a node \c n
deba@1627:       /// in graph \c g of type \c Graph as follows.
alpar@1946:       ///\code
deba@1627:       /// int count=0;
deba@1627:       /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
alpar@1946:       ///\endcode
deba@1627: 
deba@1627:       class InEdgeIt : public Edge {
deba@1627:       public:
deba@1627:         /// Default constructor
deba@1627: 
deba@1627:         /// @warning The default constructor sets the iterator
deba@1627:         /// to an undefined value.
deba@1627:         InEdgeIt() { }
deba@1627:         /// Copy constructor.
deba@1627: 
deba@1627:         /// Copy constructor.
deba@1627:         ///
deba@1627:         InEdgeIt(const InEdgeIt& e) : Edge(e) { }
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627: 
deba@1627:         /// Initialize the iterator to be invalid.
deba@1627:         ///
deba@1627:         InEdgeIt(Invalid) { }
deba@1627:         /// This constructor sets the iterator to first incoming edge.
deba@1627:     
deba@1627:         /// This constructor set the iterator to the first incoming edge of
deba@1627:         /// the node.
deba@1627:         ///@param n the node
deba@1627:         ///@param g the graph
klao@1909:         InEdgeIt(const UGraph& g, const Node& n) { 
alpar@1643: 	  ignore_unused_variable_warning(n);
alpar@1643: 	  ignore_unused_variable_warning(g);
alpar@1643: 	}
deba@1627:         /// Edge -> InEdgeIt conversion
deba@1627: 
deba@1627:         /// Sets the iterator to the value of the trivial iterator \c e.
deba@1627:         /// This feature necessitates that each time we 
deba@1627:         /// iterate the edge-set, the iteration order is the same.
klao@1909:         InEdgeIt(const UGraph&, const Edge&) { }
deba@1627:         /// Next incoming edge
deba@1627: 
deba@1627:         /// Assign the iterator to the next inedge of the corresponding node.
deba@1627:         ///
deba@1627:         InEdgeIt& operator++() { return *this; }
deba@1627:       };
deba@1627: 
deba@1627:       /// \brief Read write map of the nodes to type \c T.
deba@1627:       /// 
deba@1627:       /// ReadWrite map of the nodes to type \c T.
deba@1627:       /// \sa Reference
deba@1627:       /// \warning Making maps that can handle bool type (NodeMap<bool>)
deba@1627:       /// needs some extra attention!
deba@1627:       template<class T> 
deba@1627:       class NodeMap : public ReadWriteMap< Node, T >
deba@1627:       {
deba@1627:       public:
deba@1627: 
deba@1627:         ///\e
klao@1909:         NodeMap(const UGraph&) { }
deba@1627:         ///\e
klao@1909:         NodeMap(const UGraph&, T) { }
deba@1627: 
deba@1627:         ///Copy constructor
deba@1627:         NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
deba@1627:         ///Assignment operator
deba@2121:         template <typename CMap>
deba@2121:         NodeMap& operator=(const CMap&) { 
deba@2121:           checkConcept<ReadMap<Node, T>, CMap>();
deba@2121:           return *this; 
deba@2121:         }
deba@1627:       };
deba@1627: 
deba@1627:       /// \brief Read write map of the directed edges to type \c T.
deba@1627:       ///
deba@1627:       /// Reference map of the directed edges to type \c T.
deba@1627:       /// \sa Reference
deba@1627:       /// \warning Making maps that can handle bool type (EdgeMap<bool>)
deba@1627:       /// needs some extra attention!
deba@1627:       template<class T> 
deba@1627:       class EdgeMap : public ReadWriteMap<Edge,T>
deba@1627:       {
deba@1627:       public:
deba@1627: 
deba@1627:         ///\e
klao@1909:         EdgeMap(const UGraph&) { }
deba@1627:         ///\e
klao@1909:         EdgeMap(const UGraph&, T) { }
deba@1627:         ///Copy constructor
deba@1627:         EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) { }
deba@1627:         ///Assignment operator
deba@2121:         template <typename CMap>
deba@2121:         EdgeMap& operator=(const CMap&) { 
deba@2121:           checkConcept<ReadMap<Edge, T>, CMap>();
deba@2121:           return *this; 
deba@2121:         }
deba@1627:       };
deba@1627: 
alpar@1620:       /// Read write map of the undirected edges to type \c T.
alpar@1620: 
alpar@1620:       /// Reference map of the edges to type \c T.
alpar@1620:       /// \sa Reference
klao@1909:       /// \warning Making maps that can handle bool type (UEdgeMap<bool>)
alpar@1620:       /// needs some extra attention!
alpar@1620:       template<class T> 
klao@1909:       class UEdgeMap : public ReadWriteMap<UEdge,T>
alpar@1620:       {
klao@1030:       public:
klao@1030: 
alpar@1620:         ///\e
klao@1909:         UEdgeMap(const UGraph&) { }
alpar@1620:         ///\e
klao@1909:         UEdgeMap(const UGraph&, T) { }
alpar@1620:         ///Copy constructor
klao@1909:         UEdgeMap(const UEdgeMap& em) : ReadWriteMap<UEdge,T>(em) {}
alpar@1620:         ///Assignment operator
deba@2121:         template <typename CMap>
deba@2121:         UEdgeMap& operator=(const CMap&) { 
deba@2121:           checkConcept<ReadMap<UEdge, T>, CMap>();
deba@2121:           return *this; 
deba@2121:         }
klao@1030:       };
klao@1030: 
deba@1627:       /// \brief Direct the given undirected edge.
deba@1627:       ///
deba@1627:       /// Direct the given undirected edge. The returned edge source
deba@2163:       /// will be the given node.
klao@1909:       Edge direct(const UEdge&, const Node&) const {
deba@1627: 	return INVALID;
deba@1627:       }
klao@1030: 
deba@1627:       /// \brief Direct the given undirected edge.
deba@1627:       ///
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.
klao@1909:       Edge direct(const UEdge&, bool) const {
deba@1627: 	return INVALID;
deba@1627:       }
deba@1627: 
deba@1627:       /// \brief Returns true if the edge has default orientation.
deba@1627:       ///
klao@1030:       /// Returns whether the given directed edge is same orientation as
deba@2163:       /// the corresponding undirected edge's default orientation.
deba@1627:       bool direction(Edge) const { return true; }
deba@1627: 
deba@1627:       /// \brief Returns the opposite directed edge.
klao@1030:       ///
deba@1627:       /// Returns the opposite directed edge.
deba@1627:       Edge oppositeEdge(Edge) const { return INVALID; }
klao@1030: 
deba@1627:       /// \brief Opposite node on an edge
deba@1627:       ///
deba@2163:       /// \return the opposite of the given Node on the given UEdge
klao@1909:       Node oppositeNode(Node, UEdge) const { return INVALID; }
klao@1030: 
deba@1627:       /// \brief First node of the undirected edge.
deba@1627:       ///
klao@1909:       /// \return the first node of the given UEdge.
klao@1030:       ///
deba@2163:       /// Naturally undirected edges don't have direction and thus
klao@1030:       /// don't have source and target node. But we use these two methods
deba@2163:       /// to query the two nodes of the edge. The direction of the edge
klao@1030:       /// which arises this way is called the inherent direction of the
deba@1627:       /// undirected edge, and is used to define the "default" direction
klao@1030:       /// of the directed versions of the edges.
deba@1627:       /// \sa direction
klao@1909:       Node source(UEdge) const { return INVALID; }
klao@1030: 
deba@1627:       /// \brief Second node of the undirected edge.
klao@1909:       Node target(UEdge) const { return INVALID; }
klao@1030: 
deba@1627:       /// \brief Source node of the directed edge.
klao@1030:       Node source(Edge) const { return INVALID; }
klao@1030: 
deba@1627:       /// \brief Target node of the directed edge.
klao@1030:       Node target(Edge) const { return INVALID; }
klao@1030: 
klao@1030:       void first(Node&) const {}
klao@1030:       void next(Node&) const {}
klao@1030: 
klao@1909:       void first(UEdge&) const {}
klao@1909:       void next(UEdge&) const {}
klao@1030: 
klao@1030:       void first(Edge&) const {}
klao@1030:       void next(Edge&) const {}
klao@1030: 
klao@1030:       void firstOut(Edge&, Node) const {}
klao@1030:       void nextOut(Edge&) const {}
klao@1030: 
klao@1030:       void firstIn(Edge&, Node) const {}
klao@1030:       void nextIn(Edge&) const {}
klao@1030: 
klao@1030: 
deba@1980:       void firstInc(UEdge &, bool &, const Node &) const {}
deba@1980:       void nextInc(UEdge &, bool &) const {}
deba@1980: 
deba@1627:       /// \brief Base node of the iterator
klao@1158:       ///
klao@1158:       /// Returns the base node (the source in this case) of the iterator
klao@1158:       Node baseNode(OutEdgeIt e) const {
klao@1158: 	return source(e);
klao@1158:       }
deba@1627:       /// \brief Running node of the iterator
klao@1158:       ///
klao@1158:       /// Returns the running node (the target in this case) of the
klao@1158:       /// iterator
klao@1158:       Node runningNode(OutEdgeIt e) const {
klao@1158: 	return target(e);
klao@1158:       }
klao@1158: 
deba@1627:       /// \brief Base node of the iterator
klao@1158:       ///
klao@1158:       /// Returns the base node (the target in this case) of the iterator
klao@1158:       Node baseNode(InEdgeIt e) const {
klao@1158: 	return target(e);
klao@1158:       }
deba@1627:       /// \brief Running node of the iterator
klao@1158:       ///
klao@1158:       /// Returns the running node (the source in this case) of the
klao@1158:       /// iterator
klao@1158:       Node runningNode(InEdgeIt e) const {
klao@1158: 	return source(e);
klao@1158:       }
klao@1158: 
deba@1627:       /// \brief Base node of the iterator
klao@1158:       ///
klao@1158:       /// Returns the base node of the iterator
alpar@1367:       Node baseNode(IncEdgeIt) const {
klao@1158: 	return INVALID;
klao@1158:       }
deba@1627:       
deba@1627:       /// \brief Running node of the iterator
klao@1158:       ///
klao@1158:       /// Returns the running node of the iterator
alpar@1367:       Node runningNode(IncEdgeIt) const {
klao@1158: 	return INVALID;
klao@1158:       }
klao@1158: 
klao@1022:       template <typename Graph>
klao@1022:       struct Constraints {
klao@1022: 	void constraints() {
deba@2121: 	  checkConcept<BaseIterableUGraphComponent<>, Graph>();
deba@2121: 	  checkConcept<IterableUGraphComponent<>, Graph>();
deba@2121: 	  checkConcept<MappableUGraphComponent<>, Graph>();
klao@1022: 	}
klao@1022:       };
klao@1022: 
klao@1022:     };
klao@1022: 
klao@1030:     /// @}
klao@1030: 
klao@962:   }
klao@962: 
klao@962: }
klao@962: 
klao@962: #endif