[Lemon-commits] [lemon_svn] deba: r1300 - in hugo/branches/graph_factory/src: lemon lemon/skeletons test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:44:28 CET 2006
Author: deba
Date: Thu Oct 21 17:46:38 2004
New Revision: 1300
Modified:
hugo/branches/graph_factory/src/lemon/dfs.h
hugo/branches/graph_factory/src/lemon/iterable_graph_extender.h
hugo/branches/graph_factory/src/lemon/skeletons/graph.h
hugo/branches/graph_factory/src/lemon/skeletons/graph_component.h
hugo/branches/graph_factory/src/lemon/suurballe.h
hugo/branches/graph_factory/src/test/extended_graph_test.cc
hugo/branches/graph_factory/src/test/graph_wrapper_test.cc
Log:
Renewed graphs with VectorMaps are ready to use.
Concept check is also ready.
Still to solve:
\todo comment the code
\todo dfs and bfs fail the test because the new graph concept no longer supports the
nodeNum member function
\todo GraphWrappers maps make conform to GraphMap concept: ReferenceType
\todo Make complete the other mapstructures
Modified: hugo/branches/graph_factory/src/lemon/dfs.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/dfs.h (original)
+++ hugo/branches/graph_factory/src/lemon/dfs.h Thu Oct 21 17:46:38 2004
@@ -193,12 +193,12 @@
pred_node->set(u,INVALID);
}
- int N=G->nodeNum();
+ int N = G->nodeNum();
std::vector<typename Graph::OutEdgeIt> Q(N);
int Qh=0;
- G->first(Q[Qh],s);
+ Q[Qh] = OutEdgeIt(*G, s);
distance->set(s, 0);
Node n=s;
@@ -209,7 +209,7 @@
if((m=G->head(e))!=s && (*predecessor)[m=G->head(e)]==INVALID) {
predecessor->set(m,e);
pred_node->set(m,n);
- G->first(Q[++Qh],m);
+ Q[++Qh] = OutEdgeIt(*G, m);
distance->set(m,Qh);
n=m;
}
Modified: hugo/branches/graph_factory/src/lemon/iterable_graph_extender.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/iterable_graph_extender.h (original)
+++ hugo/branches/graph_factory/src/lemon/iterable_graph_extender.h Thu Oct 21 17:46:38 2004
@@ -106,7 +106,7 @@
graph->firstIn(*this, node);
}
- InEdgeIt(const Graph& _g, const Edge& edge) :
+ InEdgeIt(const Graph& _graph, const Edge& edge) :
Edge(edge), graph(&_graph) {}
InEdgeIt& operator++() {
Modified: hugo/branches/graph_factory/src/lemon/skeletons/graph.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/skeletons/graph.h (original)
+++ hugo/branches/graph_factory/src/lemon/skeletons/graph.h Thu Oct 21 17:46:38 2004
@@ -23,6 +23,8 @@
#include <lemon/invalid.h>
#include <lemon/skeletons/maps.h>
+#include <lemon/concept_check.h>
+#include <lemon/skeletons/graph_component.h>
namespace lemon {
namespace skeleton {
@@ -30,739 +32,742 @@
/// \addtogroup skeletons
/// @{
- /// An empty static graph class.
+// /// An empty static graph class.
- /// This class provides all the common features of a graph structure,
- /// however completely without implementations and real data structures
- /// behind the interface.
- /// All graph algorithms should compile with this class, but it will not
- /// run properly, of course.
- ///
- /// It can be used for checking the interface compatibility,
- /// or it can serve as a skeleton of a new graph structure.
- ///
- /// Also, you will find here the full documentation of a certain graph
- /// feature, the documentation of a real graph imlementation
- /// like @ref ListGraph or
- /// @ref SmartGraph will just refer to this structure.
- ///
- /// \todo A pages describing the concept of concept description would
- /// be nice.
- class StaticGraph
- {
- public:
- /// Defalult constructor.
-
- /// Defalult constructor.
- ///
- StaticGraph() { }
- ///Copy consructor.
-
-// ///\todo It is not clear, what we expect from a copy constructor.
-// ///E.g. How to assign the nodes/edges to each other? What about maps?
-// StaticGraph(const StaticGraph& g) { }
-
- /// The base type of node iterators,
- /// or in other words, the trivial node iterator.
-
- /// This is the base type of each node iterator,
- /// thus each kind of node iterator converts to this.
- /// More precisely each kind of node iterator should be inherited
- /// from the trivial node iterator.
- class Node {
- public:
- /// Default constructor
-
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- Node() { }
- /// Copy constructor.
-
- /// Copy constructor.
- ///
- Node(const Node&) { }
-
- /// Invalid constructor \& conversion.
-
- /// This constructor initializes the iterator to be invalid.
- /// \sa Invalid for more details.
- Node(Invalid) { }
- /// Equality operator
-
- /// Two iterators are equal if and only if they point to the
- /// same object or both are invalid.
- bool operator==(Node) const { return true; }
+// /// This class provides all the common features of a graph structure,
+// /// however completely without implementations and real data structures
+// /// behind the interface.
+// /// All graph algorithms should compile with this class, but it will not
+// /// run properly, of course.
+// ///
+// /// It can be used for checking the interface compatibility,
+// /// or it can serve as a skeleton of a new graph structure.
+// ///
+// /// Also, you will find here the full documentation of a certain graph
+// /// feature, the documentation of a real graph imlementation
+// /// like @ref ListGraph or
+// /// @ref SmartGraph will just refer to this structure.
+// ///
+// /// \todo A pages describing the concept of concept description would
+// /// be nice.
+// class StaticGraph
+// {
+// public:
+// /// Defalult constructor.
+
+// /// Defalult constructor.
+// ///
+// StaticGraph() { }
+// ///Copy consructor.
+
+// // ///\todo It is not clear, what we expect from a copy constructor.
+// // ///E.g. How to assign the nodes/edges to each other? What about maps?
+// // StaticGraph(const StaticGraph& g) { }
+
+// /// The base type of node iterators,
+// /// or in other words, the trivial node iterator.
+
+// /// This is the base type of each node iterator,
+// /// thus each kind of node iterator converts to this.
+// /// More precisely each kind of node iterator should be inherited
+// /// from the trivial node iterator.
+// class Node {
+// public:
+// /// Default constructor
+
+// /// @warning The default constructor sets the iterator
+// /// to an undefined value.
+// Node() { }
+// /// Copy constructor.
+
+// /// Copy constructor.
+// ///
+// Node(const Node&) { }
+
+// /// Invalid constructor \& conversion.
+
+// /// This constructor initializes the iterator to be invalid.
+// /// \sa Invalid for more details.
+// Node(Invalid) { }
+// /// Equality operator
+
+// /// Two iterators are equal if and only if they point to the
+// /// same object or both are invalid.
+// bool operator==(Node) const { return true; }
- /// Inequality operator
+// /// Inequality operator
- /// \sa operator==(Node n)
- ///
- bool operator!=(Node) const { return true; }
-
- ///Comparison operator.
-
- ///This is a strict ordering between the nodes.
- ///
- ///This ordering can be different from the order in which NodeIt
- ///goes through the nodes.
- ///\todo Possibly we don't need it.
- bool operator<(Node) const { return true; }
- };
-
- /// This iterator goes through each node.
-
- /// This iterator goes through each node.
- /// Its usage is quite simple, for example you can count the number
- /// of nodes in graph \c g of type \c Graph like this:
- /// \code
- /// int count=0;
- /// for (Graph::NodeIt n(g); n!=INVALID ++n) ++count;
- /// \endcode
- class NodeIt : public Node {
- public:
- /// Default constructor
-
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- NodeIt() { }
- /// Copy constructor.
+// /// \sa operator==(Node n)
+// ///
+// bool operator!=(Node) const { return true; }
+
+// ///Comparison operator.
+
+// ///This is a strict ordering between the nodes.
+// ///
+// ///This ordering can be different from the order in which NodeIt
+// ///goes through the nodes.
+// ///\todo Possibly we don't need it.
+// bool operator<(Node) const { return true; }
+// };
+
+// /// This iterator goes through each node.
+
+// /// This iterator goes through each node.
+// /// Its usage is quite simple, for example you can count the number
+// /// of nodes in graph \c g of type \c Graph like this:
+// /// \code
+// /// int count=0;
+// /// for (Graph::NodeIt n(g); n!=INVALID ++n) ++count;
+// /// \endcode
+// class NodeIt : public Node {
+// public:
+// /// Default constructor
+
+// /// @warning The default constructor sets the iterator
+// /// to an undefined value.
+// NodeIt() { }
+// /// Copy constructor.
- /// Copy constructor.
- ///
- NodeIt(const NodeIt&) { }
- /// Invalid constructor \& conversion.
-
- /// Initialize the iterator to be invalid.
- /// \sa Invalid for more details.
- NodeIt(Invalid) { }
- /// Sets the iterator to the first node.
-
- /// Sets the iterator to the first node of \c g.
- ///
- NodeIt(const StaticGraph& g) { }
- /// Node -> NodeIt conversion.
-
- /// Sets the iterator to the node of \c g pointed by the trivial
- /// iterator n.
- /// This feature necessitates that each time we
- /// iterate the edge-set, the iteration order is the same.
- NodeIt(const StaticGraph& g, const Node& n) { }
- /// Next node.
-
- /// Assign the iterator to the next node.
- ///
- NodeIt& operator++() { return *this; }
- };
-
-
- /// The base type of the edge iterators.
-
- /// The base type of the edge iterators.
- ///
- class Edge {
- public:
- /// Default constructor
-
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- Edge() { }
- /// Copy constructor.
-
- /// Copy constructor.
- ///
- Edge(const Edge&) { }
- /// Initialize the iterator to be invalid.
-
- /// Initialize the iterator to be invalid.
- ///
- Edge(Invalid) { }
- /// Equality operator
-
- /// Two iterators are equal if and only if they point to the
- /// same object or both are invalid.
- bool operator==(Edge) const { return true; }
- /// Inequality operator
-
- /// \sa operator==(Node n)
- ///
- bool operator!=(Edge) const { return true; }
- ///Comparison operator.
-
- ///This is a strict ordering between the nodes.
- ///
- ///This ordering can be different from the order in which NodeIt
- ///goes through the nodes.
- ///\todo Possibly we don't need it.
- bool operator<(Edge) const { return true; }
- };
-
- /// This iterator goes trough the outgoing edges of a node.
-
- /// This iterator goes trough the \e outgoing edges of a certain node
- /// of a graph.
- /// Its usage is quite simple, for example you can count the number
- /// of outgoing edges of a node \c n
- /// in graph \c g of type \c Graph as follows.
- /// \code
- /// int count=0;
- /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
- /// \endcode
-
- class OutEdgeIt : public Edge {
- public:
- /// Default constructor
-
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- OutEdgeIt() { }
- /// Copy constructor.
-
- /// Copy constructor.
- ///
- OutEdgeIt(const OutEdgeIt&) { }
- /// Initialize the iterator to be invalid.
-
- /// Initialize the iterator to be invalid.
- ///
- OutEdgeIt(Invalid) { }
- /// This constructor sets the iterator to first outgoing edge.
-
- /// This constructor set the iterator to the first outgoing edge of
- /// node
- ///@param n the node
- ///@param g the graph
- OutEdgeIt(const StaticGraph& g, const Node& n) { }
- /// Edge -> OutEdgeIt conversion
-
- /// Sets the iterator to the value of the trivial iterator \c e.
- /// This feature necessitates that each time we
- /// iterate the edge-set, the iteration order is the same.
- OutEdgeIt(const StaticGraph& g, const Edge& e) { }
- ///Next outgoing edge
+// /// Copy constructor.
+// ///
+// NodeIt(const NodeIt&) { }
+// /// Invalid constructor \& conversion.
+
+// /// Initialize the iterator to be invalid.
+// /// \sa Invalid for more details.
+// NodeIt(Invalid) { }
+// /// Sets the iterator to the first node.
+
+// /// Sets the iterator to the first node of \c g.
+// ///
+// NodeIt(const StaticGraph& g) { }
+// /// Node -> NodeIt conversion.
+
+// /// Sets the iterator to the node of \c g pointed by the trivial
+// /// iterator n.
+// /// This feature necessitates that each time we
+// /// iterate the edge-set, the iteration order is the same.
+// NodeIt(const StaticGraph& g, const Node& n) { }
+// /// Next node.
+
+// /// Assign the iterator to the next node.
+// ///
+// NodeIt& operator++() { return *this; }
+// };
+
+
+// /// The base type of the edge iterators.
+
+// /// The base type of the edge iterators.
+// ///
+// class Edge {
+// public:
+// /// Default constructor
+
+// /// @warning The default constructor sets the iterator
+// /// to an undefined value.
+// Edge() { }
+// /// Copy constructor.
+
+// /// Copy constructor.
+// ///
+// Edge(const Edge&) { }
+// /// Initialize the iterator to be invalid.
+
+// /// Initialize the iterator to be invalid.
+// ///
+// Edge(Invalid) { }
+// /// Equality operator
+
+// /// Two iterators are equal if and only if they point to the
+// /// same object or both are invalid.
+// bool operator==(Edge) const { return true; }
+// /// Inequality operator
+
+// /// \sa operator==(Node n)
+// ///
+// bool operator!=(Edge) const { return true; }
+// ///Comparison operator.
+
+// ///This is a strict ordering between the nodes.
+// ///
+// ///This ordering can be different from the order in which NodeIt
+// ///goes through the nodes.
+// ///\todo Possibly we don't need it.
+// bool operator<(Edge) const { return true; }
+// };
+
+// /// This iterator goes trough the outgoing edges of a node.
+
+// /// This iterator goes trough the \e outgoing edges of a certain node
+// /// of a graph.
+// /// Its usage is quite simple, for example you can count the number
+// /// of outgoing edges of a node \c n
+// /// in graph \c g of type \c Graph as follows.
+// /// \code
+// /// int count=0;
+// /// for (Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) ++count;
+// /// \endcode
+
+// class OutEdgeIt : public Edge {
+// public:
+// /// Default constructor
+
+// /// @warning The default constructor sets the iterator
+// /// to an undefined value.
+// OutEdgeIt() { }
+// /// Copy constructor.
+
+// /// Copy constructor.
+// ///
+// OutEdgeIt(const OutEdgeIt&) { }
+// /// Initialize the iterator to be invalid.
+
+// /// Initialize the iterator to be invalid.
+// ///
+// OutEdgeIt(Invalid) { }
+// /// This constructor sets the iterator to first outgoing edge.
+
+// /// This constructor set the iterator to the first outgoing edge of
+// /// node
+// ///@param n the node
+// ///@param g the graph
+// OutEdgeIt(const StaticGraph& g, const Node& n) { }
+// /// Edge -> OutEdgeIt conversion
+
+// /// Sets the iterator to the value of the trivial iterator \c e.
+// /// This feature necessitates that each time we
+// /// iterate the edge-set, the iteration order is the same.
+// OutEdgeIt(const StaticGraph& g, const Edge& e) { }
+// ///Next outgoing edge
- /// Assign the iterator to the next
- /// outgoing edge of the corresponding node.
- OutEdgeIt& operator++() { return *this; }
- };
-
- /// This iterator goes trough the incoming edges of a node.
-
- /// This iterator goes trough the \e incoming edges of a certain node
- /// of a graph.
- /// Its usage is quite simple, for example you can count the number
- /// of outgoing edges of a node \c n
- /// in graph \c g of type \c Graph as follows.
- /// \code
- /// int count=0;
- /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
- /// \endcode
-
- class InEdgeIt : public Edge {
- public:
- /// Default constructor
-
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- InEdgeIt() { }
- /// Copy constructor.
-
- /// Copy constructor.
- ///
- InEdgeIt(const InEdgeIt&) { }
- /// Initialize the iterator to be invalid.
-
- /// Initialize the iterator to be invalid.
- ///
- InEdgeIt(Invalid) { }
- /// This constructor sets the iterator to first incoming edge.
-
- /// This constructor set the iterator to the first incoming edge of
- /// node
- ///@param n the node
- ///@param g the graph
- InEdgeIt(const StaticGraph& g, const Node& n) { }
- /// Edge -> InEdgeIt conversion
-
- /// Sets the iterator to the value of the trivial iterator \c e.
- /// This feature necessitates that each time we
- /// iterate the edge-set, the iteration order is the same.
- InEdgeIt(const StaticGraph& g, const Edge& n) { }
- /// Next incoming edge
-
- /// Assign the iterator to the next inedge of the corresponding node.
- ///
- InEdgeIt& operator++() { return *this; }
- };
- /// This iterator goes through each edge.
-
- /// This iterator goes through each edge of a graph.
- /// Its usage is quite simple, for example you can count the number
- /// of edges in a graph \c g of type \c Graph as follows:
- /// \code
- /// int count=0;
- /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
- /// \endcode
- class EdgeIt : public Edge {
- public:
- /// Default constructor
-
- /// @warning The default constructor sets the iterator
- /// to an undefined value.
- EdgeIt() { }
- /// Copy constructor.
-
- /// Copy constructor.
- ///
- EdgeIt(const EdgeIt&) { }
- /// Initialize the iterator to be invalid.
-
- /// Initialize the iterator to be invalid.
- ///
- EdgeIt(Invalid) { }
- /// This constructor sets the iterator to first edge.
-
- /// This constructor set the iterator to the first edge of
- /// node
- ///@param g the graph
- EdgeIt(const StaticGraph& g) { }
- /// Edge -> EdgeIt conversion
-
- /// Sets the iterator to the value of the trivial iterator \c e.
- /// This feature necessitates that each time we
- /// iterate the edge-set, the iteration order is the same.
- EdgeIt(const StaticGraph&, const Edge&) { }
- ///Next edge
+// /// Assign the iterator to the next
+// /// outgoing edge of the corresponding node.
+// OutEdgeIt& operator++() { return *this; }
+// };
+
+// /// This iterator goes trough the incoming edges of a node.
+
+// /// This iterator goes trough the \e incoming edges of a certain node
+// /// of a graph.
+// /// Its usage is quite simple, for example you can count the number
+// /// of outgoing edges of a node \c n
+// /// in graph \c g of type \c Graph as follows.
+// /// \code
+// /// int count=0;
+// /// for(Graph::InEdgeIt e(g, n); e!=INVALID; ++e) ++count;
+// /// \endcode
+
+// class InEdgeIt : public Edge {
+// public:
+// /// Default constructor
+
+// /// @warning The default constructor sets the iterator
+// /// to an undefined value.
+// InEdgeIt() { }
+// /// Copy constructor.
+
+// /// Copy constructor.
+// ///
+// InEdgeIt(const InEdgeIt&) { }
+// /// Initialize the iterator to be invalid.
+
+// /// Initialize the iterator to be invalid.
+// ///
+// InEdgeIt(Invalid) { }
+// /// This constructor sets the iterator to first incoming edge.
+
+// /// This constructor set the iterator to the first incoming edge of
+// /// node
+// ///@param n the node
+// ///@param g the graph
+// InEdgeIt(const StaticGraph& g, const Node& n) { }
+// /// Edge -> InEdgeIt conversion
+
+// /// Sets the iterator to the value of the trivial iterator \c e.
+// /// This feature necessitates that each time we
+// /// iterate the edge-set, the iteration order is the same.
+// InEdgeIt(const StaticGraph& g, const Edge& n) { }
+// /// Next incoming edge
+
+// /// Assign the iterator to the next inedge of the corresponding node.
+// ///
+// InEdgeIt& operator++() { return *this; }
+// };
+// /// This iterator goes through each edge.
+
+// /// This iterator goes through each edge of a graph.
+// /// Its usage is quite simple, for example you can count the number
+// /// of edges in a graph \c g of type \c Graph as follows:
+// /// \code
+// /// int count=0;
+// /// for(Graph::EdgeIt e(g); e!=INVALID; ++e) ++count;
+// /// \endcode
+// class EdgeIt : public Edge {
+// public:
+// /// Default constructor
+
+// /// @warning The default constructor sets the iterator
+// /// to an undefined value.
+// EdgeIt() { }
+// /// Copy constructor.
+
+// /// Copy constructor.
+// ///
+// EdgeIt(const EdgeIt&) { }
+// /// Initialize the iterator to be invalid.
+
+// /// Initialize the iterator to be invalid.
+// ///
+// EdgeIt(Invalid) { }
+// /// This constructor sets the iterator to first edge.
+
+// /// This constructor set the iterator to the first edge of
+// /// node
+// ///@param g the graph
+// EdgeIt(const StaticGraph& g) { }
+// /// Edge -> EdgeIt conversion
+
+// /// Sets the iterator to the value of the trivial iterator \c e.
+// /// This feature necessitates that each time we
+// /// iterate the edge-set, the iteration order is the same.
+// EdgeIt(const StaticGraph&, const Edge&) { }
+// ///Next edge
- /// Assign the iterator to the next
- /// edge of the corresponding node.
- EdgeIt& operator++() { return *this; }
- };
-
- /// First node of the graph.
-
- /// \retval i the first node.
- /// \return the first node.
- ///
- NodeIt& first(NodeIt& i) const { return i; }
-
- /// The first incoming edge.
-
- /// The first incoming edge.
- ///
- InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
- /// The first outgoing edge.
-
- /// The first outgoing edge.
- ///
- OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
- /// The first edge of the Graph.
-
- /// The first edge of the Graph.
- ///
- EdgeIt& first(EdgeIt& i) const { return i; }
-
- ///Gives back the head node of an edge.
-
- ///Gives back the head node of an edge.
- ///
- Node head(Edge) const { return INVALID; }
- ///Gives back the tail node of an edge.
-
- ///Gives back the tail node of an edge.
- ///
- Node tail(Edge) const { return INVALID; }
+// /// Assign the iterator to the next
+// /// edge of the corresponding node.
+// EdgeIt& operator++() { return *this; }
+// };
+
+// /// First node of the graph.
+
+// /// \retval i the first node.
+// /// \return the first node.
+// ///
+// NodeIt& first(NodeIt& i) const { return i; }
+
+// /// The first incoming edge.
+
+// /// The first incoming edge.
+// ///
+// InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
+// /// The first outgoing edge.
+
+// /// The first outgoing edge.
+// ///
+// OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
+// /// The first edge of the Graph.
+
+// /// The first edge of the Graph.
+// ///
+// EdgeIt& first(EdgeIt& i) const { return i; }
+
+// ///Gives back the head node of an edge.
+
+// ///Gives back the head node of an edge.
+// ///
+// Node head(Edge) const { return INVALID; }
+// ///Gives back the tail node of an edge.
+
+// ///Gives back the tail node of an edge.
+// ///
+// Node tail(Edge) const { return INVALID; }
- ///Gives back the \e id of a node.
+// ///Gives back the \e id of a node.
- ///\warning Not all graph structures provide this feature.
- ///
- ///\todo Should each graph provide \c id?
- int id(const Node&) const { return 0; }
- ///Gives back the \e id of an edge.
-
- ///\warning Not all graph structures provide this feature.
- ///
- ///\todo Should each graph provide \c id?
- int id(const Edge&) const { return 0; }
+// ///\warning Not all graph structures provide this feature.
+// ///
+// ///\todo Should each graph provide \c id?
+// int id(const Node&) const { return 0; }
+// ///Gives back the \e id of an edge.
+
+// ///\warning Not all graph structures provide this feature.
+// ///
+// ///\todo Should each graph provide \c id?
+// int id(const Edge&) const { return 0; }
- ///\e
+// ///\e
- ///\todo Should it be in the concept?
- ///
- int nodeNum() const { return 0; }
- ///\e
-
- ///\todo Should it be in the concept?
- ///
- int edgeNum() const { return 0; }
-
-
- ///Reference map of the nodes to type \c T.
-
- /// \ingroup skeletons
- ///Reference map of the nodes to type \c T.
- /// \sa Reference
- /// \warning Making maps that can handle bool type (NodeMap<bool>)
- /// needs some extra attention!
- template<class T> class NodeMap : public ReferenceMap< Node, T >
- {
- public:
-
- ///\e
- NodeMap(const StaticGraph&) { }
- ///\e
- NodeMap(const StaticGraph&, T) { }
-
- ///Copy constructor
- template<typename TT> NodeMap(const NodeMap<TT>&) { }
- ///Assignment operator
- template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
- { return *this; }
- };
-
- ///Reference map of the edges to type \c T.
-
- /// \ingroup skeletons
- ///Reference map of the edges to type \c T.
- /// \sa Reference
- /// \warning Making maps that can handle bool type (EdgeMap<bool>)
- /// needs some extra attention!
- template<class T> class EdgeMap
- : public ReferenceMap<Edge,T>
- {
- public:
-
- ///\e
- EdgeMap(const StaticGraph&) { }
- ///\e
- EdgeMap(const StaticGraph&, T) { }
-
- ///Copy constructor
- template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
- ///Assignment operator
- template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
- { return *this; }
- };
- };
-
- struct DummyType {
- int value;
- DummyType() {}
- DummyType(int p) : value(p) {}
- DummyType& operator=(int p) { value = p; return *this;}
- };
-
- ///\brief Checks whether \c G meets the
- ///\ref lemon::skeleton::StaticGraph "StaticGraph" concept
- template<class Graph> void checkCompileStaticGraph(Graph &G)
- {
- typedef typename Graph::Node Node;
- typedef typename Graph::NodeIt NodeIt;
- typedef typename Graph::Edge Edge;
- typedef typename Graph::EdgeIt EdgeIt;
- typedef typename Graph::InEdgeIt InEdgeIt;
- typedef typename Graph::OutEdgeIt OutEdgeIt;
+// ///\todo Should it be in the concept?
+// ///
+// int nodeNum() const { return 0; }
+// ///\e
+
+// ///\todo Should it be in the concept?
+// ///
+// int edgeNum() const { return 0; }
+
+
+// ///Reference map of the nodes to type \c T.
+
+// /// \ingroup skeletons
+// ///Reference map of the nodes to type \c T.
+// /// \sa Reference
+// /// \warning Making maps that can handle bool type (NodeMap<bool>)
+// /// needs some extra attention!
+// template<class T> class NodeMap : public ReferenceMap< Node, T >
+// {
+// public:
+
+// ///\e
+// NodeMap(const StaticGraph&) { }
+// ///\e
+// NodeMap(const StaticGraph&, T) { }
+
+// ///Copy constructor
+// template<typename TT> NodeMap(const NodeMap<TT>&) { }
+// ///Assignment operator
+// template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
+// { return *this; }
+// };
+
+// ///Reference map of the edges to type \c T.
+
+// /// \ingroup skeletons
+// ///Reference map of the edges to type \c T.
+// /// \sa Reference
+// /// \warning Making maps that can handle bool type (EdgeMap<bool>)
+// /// needs some extra attention!
+// template<class T> class EdgeMap
+// : public ReferenceMap<Edge,T>
+// {
+// public:
+
+// ///\e
+// EdgeMap(const StaticGraph&) { }
+// ///\e
+// EdgeMap(const StaticGraph&, T) { }
+
+// ///Copy constructor
+// template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
+// ///Assignment operator
+// template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
+// { return *this; }
+// };
+// };
+
+// struct DummyType {
+// int value;
+// DummyType() {}
+// DummyType(int p) : value(p) {}
+// DummyType& operator=(int p) { value = p; return *this;}
+// };
+
+// ///\brief Checks whether \c G meets the
+// ///\ref lemon::skeleton::StaticGraph "StaticGraph" concept
+// template<class Graph> void checkCompileStaticGraph(Graph &G)
+// {
+// typedef typename Graph::Node Node;
+// typedef typename Graph::NodeIt NodeIt;
+// typedef typename Graph::Edge Edge;
+// typedef typename Graph::EdgeIt EdgeIt;
+// typedef typename Graph::InEdgeIt InEdgeIt;
+// typedef typename Graph::OutEdgeIt OutEdgeIt;
- {
- Node i; Node j(i); Node k(INVALID);
- i=j;
- bool b; b=true;
- b=(i==INVALID); b=(i!=INVALID);
- b=(i==j); b=(i!=j); b=(i<j);
- }
- {
- NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
- i=j;
- j=G.first(i);
- j=++i;
- bool b; b=true;
- b=(i==INVALID); b=(i!=INVALID);
- Node n(i);
- n=i;
- b=(i==j); b=(i!=j); b=(i<j);
- //Node ->NodeIt conversion
- NodeIt ni(G,n);
- }
- {
- Edge i; Edge j(i); Edge k(INVALID);
- i=j;
- bool b; b=true;
- b=(i==INVALID); b=(i!=INVALID);
- b=(i==j); b=(i!=j); b=(i<j);
- }
- {
- EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
- i=j;
- j=G.first(i);
- j=++i;
- bool b; b=true;
- b=(i==INVALID); b=(i!=INVALID);
- Edge e(i);
- e=i;
- b=(i==j); b=(i!=j); b=(i<j);
- //Edge ->EdgeIt conversion
- EdgeIt ei(G,e);
- }
- {
- Node n;
- InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
- i=j;
- j=G.first(i,n);
- j=++i;
- bool b; b=true;
- b=(i==INVALID); b=(i!=INVALID);
- Edge e(i);
- e=i;
- b=(i==j); b=(i!=j); b=(i<j);
- //Edge ->InEdgeIt conversion
- InEdgeIt ei(G,e);
- }
- {
- Node n;
- OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
- i=j;
- j=G.first(i,n);
- j=++i;
- bool b; b=true;
- b=(i==INVALID); b=(i!=INVALID);
- Edge e(i);
- e=i;
- b=(i==j); b=(i!=j); b=(i<j);
- //Edge ->OutEdgeIt conversion
- OutEdgeIt ei(G,e);
- }
- {
- Node n,m;
- n=m=INVALID;
- Edge e;
- e=INVALID;
- n=G.tail(e);
- n=G.head(e);
- }
- // id tests
- { Node n; int i=G.id(n); i=i; }
- { Edge e; int i=G.id(e); i=i; }
- //NodeMap tests
- {
- Node k;
- typename Graph::template NodeMap<int> m(G);
- //Const map
- typename Graph::template NodeMap<int> const &cm = m;
- //Inicialize with default value
- typename Graph::template NodeMap<int> mdef(G,12);
- //Copy
- typename Graph::template NodeMap<int> mm(cm);
- //Copy from another type
- typename Graph::template NodeMap<double> dm(cm);
- //Copy to more complex type
- typename Graph::template NodeMap<DummyType> em(cm);
- int v;
- v=m[k]; m[k]=v; m.set(k,v);
- v=cm[k];
-
- m=cm;
- dm=cm; //Copy from another type
- em=cm; //Copy to more complex type
- {
- //Check the typedef's
- typename Graph::template NodeMap<int>::ValueType val;
- val=1;
- typename Graph::template NodeMap<int>::KeyType key;
- key = typename Graph::NodeIt(G);
- }
- }
- { //bool NodeMap
- Node k;
- typename Graph::template NodeMap<bool> m(G);
- typename Graph::template NodeMap<bool> const &cm = m; //Const map
- //Inicialize with default value
- typename Graph::template NodeMap<bool> mdef(G,12);
- typename Graph::template NodeMap<bool> mm(cm); //Copy
- typename Graph::template NodeMap<int> dm(cm); //Copy from another type
- bool v;
- v=m[k]; m[k]=v; m.set(k,v);
- v=cm[k];
-
- m=cm;
- dm=cm; //Copy from another type
- m=dm; //Copy to another type
-
- {
- //Check the typedef's
- typename Graph::template NodeMap<bool>::ValueType val;
- val=true;
- typename Graph::template NodeMap<bool>::KeyType key;
- key= typename Graph::NodeIt(G);
- }
- }
- //EdgeMap tests
- {
- Edge k;
- typename Graph::template EdgeMap<int> m(G);
- typename Graph::template EdgeMap<int> const &cm = m; //Const map
- //Inicialize with default value
- typename Graph::template EdgeMap<int> mdef(G,12);
- typename Graph::template EdgeMap<int> mm(cm); //Copy
- typename Graph::template EdgeMap<double> dm(cm);//Copy from another type
- int v;
- v=m[k]; m[k]=v; m.set(k,v);
- v=cm[k];
-
- m=cm;
- dm=cm; //Copy from another type
- {
- //Check the typedef's
- typename Graph::template EdgeMap<int>::ValueType val;
- val=1;
- typename Graph::template EdgeMap<int>::KeyType key;
- key= typename Graph::EdgeIt(G);
- }
- }
- { //bool EdgeMap
- Edge k;
- typename Graph::template EdgeMap<bool> m(G);
- typename Graph::template EdgeMap<bool> const &cm = m; //Const map
- //Inicialize with default value
- typename Graph::template EdgeMap<bool> mdef(G,12);
- typename Graph::template EdgeMap<bool> mm(cm); //Copy
- typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
- bool v;
- v=m[k]; m[k]=v; m.set(k,v);
- v=cm[k];
-
- m=cm;
- dm=cm; //Copy from another type
- m=dm; //Copy to another type
- {
- //Check the typedef's
- typename Graph::template EdgeMap<bool>::ValueType val;
- val=true;
- typename Graph::template EdgeMap<bool>::KeyType key;
- key= typename Graph::EdgeIt(G);
- }
- }
- }
-
- /// An empty non-static graph class.
-
- /// This class provides everything that \ref StaticGraph
- /// with additional functionality which enables to build a
- /// graph from scratch.
- class ExtendableGraph : public StaticGraph
- {
- public:
- /// Defalult constructor.
-
- /// Defalult constructor.
- ///
- ExtendableGraph() { }
- ///Add a new node to the graph.
-
- /// \return the new node.
- ///
- Node addNode() { return INVALID; }
- ///Add a new edge to the graph.
-
- ///Add a new edge to the graph with tail node \c t
- ///and head node \c h.
- ///\return the new edge.
- Edge addEdge(Node h, Node t) { return INVALID; }
-
- /// Resets the graph.
-
- /// This function deletes all edges and nodes of the graph.
- /// It also frees the memory allocated to store them.
- /// \todo It might belong to \ref ErasableGraph.
- void clear() { }
- };
-
-
- ///\brief Checks whether \c G meets the
- ///\ref lemon::skeleton::ExtendableGraph "ExtendableGraph" concept
- template<class Graph> void checkCompileExtendableGraph(Graph &G)
- {
- checkCompileStaticGraph(G);
-
- typedef typename Graph::Node Node;
- typedef typename Graph::NodeIt NodeIt;
- typedef typename Graph::Edge Edge;
- typedef typename Graph::EdgeIt EdgeIt;
- typedef typename Graph::InEdgeIt InEdgeIt;
- typedef typename Graph::OutEdgeIt OutEdgeIt;
+// {
+// Node i; Node j(i); Node k(INVALID);
+// i=j;
+// bool b; b=true;
+// b=(i==INVALID); b=(i!=INVALID);
+// b=(i==j); b=(i!=j); b=(i<j);
+// }
+// {
+// NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
+// i=j;
+// j=G.first(i);
+// j=++i;
+// bool b; b=true;
+// b=(i==INVALID); b=(i!=INVALID);
+// Node n(i);
+// n=i;
+// b=(i==j); b=(i!=j); b=(i<j);
+// //Node ->NodeIt conversion
+// NodeIt ni(G,n);
+// }
+// {
+// Edge i; Edge j(i); Edge k(INVALID);
+// i=j;
+// bool b; b=true;
+// b=(i==INVALID); b=(i!=INVALID);
+// b=(i==j); b=(i!=j); b=(i<j);
+// }
+// {
+// EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
+// i=j;
+// j=G.first(i);
+// j=++i;
+// bool b; b=true;
+// b=(i==INVALID); b=(i!=INVALID);
+// Edge e(i);
+// e=i;
+// b=(i==j); b=(i!=j); b=(i<j);
+// //Edge ->EdgeIt conversion
+// EdgeIt ei(G,e);
+// }
+// {
+// Node n;
+// InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
+// i=j;
+// j=G.first(i,n);
+// j=++i;
+// bool b; b=true;
+// b=(i==INVALID); b=(i!=INVALID);
+// Edge e(i);
+// e=i;
+// b=(i==j); b=(i!=j); b=(i<j);
+// //Edge ->InEdgeIt conversion
+// InEdgeIt ei(G,e);
+// }
+// {
+// Node n;
+// OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
+// i=j;
+// j=G.first(i,n);
+// j=++i;
+// bool b; b=true;
+// b=(i==INVALID); b=(i!=INVALID);
+// Edge e(i);
+// e=i;
+// b=(i==j); b=(i!=j); b=(i<j);
+// //Edge ->OutEdgeIt conversion
+// OutEdgeIt ei(G,e);
+// }
+// {
+// Node n,m;
+// n=m=INVALID;
+// Edge e;
+// e=INVALID;
+// n=G.tail(e);
+// n=G.head(e);
+// }
+// // id tests
+// { Node n; int i=G.id(n); i=i; }
+// { Edge e; int i=G.id(e); i=i; }
+// //NodeMap tests
+// {
+// Node k;
+// typename Graph::template NodeMap<int> m(G);
+// //Const map
+// typename Graph::template NodeMap<int> const &cm = m;
+// //Inicialize with default value
+// typename Graph::template NodeMap<int> mdef(G,12);
+// //Copy
+// typename Graph::template NodeMap<int> mm(cm);
+// //Copy from another type
+// typename Graph::template NodeMap<double> dm(cm);
+// //Copy to more complex type
+// typename Graph::template NodeMap<DummyType> em(cm);
+// int v;
+// v=m[k]; m[k]=v; m.set(k,v);
+// v=cm[k];
+
+// m=cm;
+// dm=cm; //Copy from another type
+// em=cm; //Copy to more complex type
+// {
+// //Check the typedef's
+// typename Graph::template NodeMap<int>::ValueType val;
+// val=1;
+// typename Graph::template NodeMap<int>::KeyType key;
+// key = typename Graph::NodeIt(G);
+// }
+// }
+// { //bool NodeMap
+// Node k;
+// typename Graph::template NodeMap<bool> m(G);
+// typename Graph::template NodeMap<bool> const &cm = m; //Const map
+// //Inicialize with default value
+// typename Graph::template NodeMap<bool> mdef(G,12);
+// typename Graph::template NodeMap<bool> mm(cm); //Copy
+// typename Graph::template NodeMap<int> dm(cm); //Copy from another type
+// bool v;
+// v=m[k]; m[k]=v; m.set(k,v);
+// v=cm[k];
+
+// m=cm;
+// dm=cm; //Copy from another type
+// m=dm; //Copy to another type
+
+// {
+// //Check the typedef's
+// typename Graph::template NodeMap<bool>::ValueType val;
+// val=true;
+// typename Graph::template NodeMap<bool>::KeyType key;
+// key= typename Graph::NodeIt(G);
+// }
+// }
+// //EdgeMap tests
+// {
+// Edge k;
+// typename Graph::template EdgeMap<int> m(G);
+// typename Graph::template EdgeMap<int> const &cm = m; //Const map
+// //Inicialize with default value
+// typename Graph::template EdgeMap<int> mdef(G,12);
+// typename Graph::template EdgeMap<int> mm(cm); //Copy
+// typename Graph::template EdgeMap<double> dm(cm);//Copy from another type
+// int v;
+// v=m[k]; m[k]=v; m.set(k,v);
+// v=cm[k];
+
+// m=cm;
+// dm=cm; //Copy from another type
+// {
+// //Check the typedef's
+// typename Graph::template EdgeMap<int>::ValueType val;
+// val=1;
+// typename Graph::template EdgeMap<int>::KeyType key;
+// key= typename Graph::EdgeIt(G);
+// }
+// }
+// { //bool EdgeMap
+// Edge k;
+// typename Graph::template EdgeMap<bool> m(G);
+// typename Graph::template EdgeMap<bool> const &cm = m; //Const map
+// //Inicialize with default value
+// typename Graph::template EdgeMap<bool> mdef(G,12);
+// typename Graph::template EdgeMap<bool> mm(cm); //Copy
+// typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
+// bool v;
+// v=m[k]; m[k]=v; m.set(k,v);
+// v=cm[k];
+
+// m=cm;
+// dm=cm; //Copy from another type
+// m=dm; //Copy to another type
+// {
+// //Check the typedef's
+// typename Graph::template EdgeMap<bool>::ValueType val;
+// val=true;
+// typename Graph::template EdgeMap<bool>::KeyType key;
+// key= typename Graph::EdgeIt(G);
+// }
+// }
+// }
+
+// /// An empty non-static graph class.
+
+// /// This class provides everything that \ref StaticGraph
+// /// with additional functionality which enables to build a
+// /// graph from scratch.
+// class ExtendableGraph : public StaticGraph
+// {
+// public:
+// /// Defalult constructor.
+
+// /// Defalult constructor.
+// ///
+// ExtendableGraph() { }
+// ///Add a new node to the graph.
+
+// /// \return the new node.
+// ///
+// Node addNode() { return INVALID; }
+// ///Add a new edge to the graph.
+
+// ///Add a new edge to the graph with tail node \c t
+// ///and head node \c h.
+// ///\return the new edge.
+// Edge addEdge(Node h, Node t) { return INVALID; }
+
+// /// Resets the graph.
+
+// /// This function deletes all edges and nodes of the graph.
+// /// It also frees the memory allocated to store them.
+// /// \todo It might belong to \ref ErasableGraph.
+// void clear() { }
+// };
+
+
+// ///\brief Checks whether \c G meets the
+// ///\ref lemon::skeleton::ExtendableGraph "ExtendableGraph" concept
+// template<class Graph> void checkCompileExtendableGraph(Graph &G)
+// {
+// checkCompileStaticGraph(G);
+
+// typedef typename Graph::Node Node;
+// typedef typename Graph::NodeIt NodeIt;
+// typedef typename Graph::Edge Edge;
+// typedef typename Graph::EdgeIt EdgeIt;
+// typedef typename Graph::InEdgeIt InEdgeIt;
+// typedef typename Graph::OutEdgeIt OutEdgeIt;
- Node n,m;
- n=G.addNode();
- m=G.addNode();
- Edge e;
- e=G.addEdge(n,m);
+// Node n,m;
+// n=G.addNode();
+// m=G.addNode();
+// Edge e;
+// e=G.addEdge(n,m);
- // G.clear();
- }
+// // G.clear();
+// }
- /// An empty erasable graph class.
+// /// An empty erasable graph class.
- /// This class is an extension of \ref ExtendableGraph. It also makes it
- /// possible to erase edges or nodes.
- class ErasableGraph : public ExtendableGraph
- {
- public:
- /// Defalult constructor.
-
- /// Defalult constructor.
- ///
- ErasableGraph() { }
- /// Deletes a node.
-
- /// Deletes node \c n node.
- ///
- void erase(Node n) { }
- /// Deletes an edge.
-
- /// Deletes edge \c e edge.
- ///
- void erase(Edge e) { }
- };
-
- template<class Graph> void checkCompileGraphEraseEdge(Graph &G)
- {
- typename Graph::Edge e;
- G.erase(e);
- }
-
- template<class Graph> void checkCompileGraphEraseNode(Graph &G)
- {
- typename Graph::Node n;
- G.erase(n);
- }
-
- ///\brief Checks whether \c G meets the
- ///\ref lemon::skeleton::EresableGraph "EresableGraph" concept
- template<class Graph> void checkCompileErasableGraph(Graph &G)
- {
- checkCompileExtendableGraph(G);
- checkCompileGraphEraseNode(G);
- checkCompileGraphEraseEdge(G);
- }
-
- ///Checks whether a graph has findEdge() member function.
-
- ///\todo findEdge() might be a global function.
- ///
- template<class Graph> void checkCompileGraphFindEdge(Graph &G)
- {
- typedef typename Graph::NodeIt Node;
- typedef typename Graph::NodeIt NodeIt;
-
- G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
- G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));
- }
+// /// This class is an extension of \ref ExtendableGraph. It also makes it
+// /// possible to erase edges or nodes.
+// class ErasableGraph : public ExtendableGraph
+// {
+// public:
+// /// Defalult constructor.
+
+// /// Defalult constructor.
+// ///
+// ErasableGraph() { }
+// /// Deletes a node.
+
+// /// Deletes node \c n node.
+// ///
+// void erase(Node n) { }
+// /// Deletes an edge.
+
+// /// Deletes edge \c e edge.
+// ///
+// void erase(Edge e) { }
+// };
+
+// template<class Graph> void checkCompileGraphEraseEdge(Graph &G)
+// {
+// typename Graph::Edge e;
+// G.erase(e);
+// }
+
+// template<class Graph> void checkCompileGraphEraseNode(Graph &G)
+// {
+// typename Graph::Node n;
+// G.erase(n);
+// }
+
+// ///\brief Checks whether \c G meets the
+// ///\ref lemon::skeleton::EresableGraph "EresableGraph" concept
+// template<class Graph> void checkCompileErasableGraph(Graph &G)
+// {
+// checkCompileExtendableGraph(G);
+// checkCompileGraphEraseNode(G);
+// checkCompileGraphEraseEdge(G);
+// }
+
+// ///Checks whether a graph has findEdge() member function.
+
+// ///\todo findEdge() might be a global function.
+// ///
+// template<class Graph> void checkCompileGraphFindEdge(Graph &G)
+// {
+// typedef typename Graph::NodeIt Node;
+// typedef typename Graph::NodeIt NodeIt;
+
+// G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
+// G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));
+// }
/************* New GraphBase stuff **************/
+ /// \bug The nodes and edges are not allowed to inherit from the
+ /// same baseclass.
+
class BaseGraphItem {
public:
BaseGraphItem() {}
@@ -817,6 +822,9 @@
public:
GraphBase() {}
+
+
+ /// \bug Nodes and Edges are comparable each other
class Node : public BaseGraphItem {};
class Edge : public BaseGraphItem {};
@@ -878,6 +886,58 @@
}
};
+
+
+ class StaticGraph
+ : virtual public BaseGraphComponent, public IterableGraphComponent, public MappableGraphComponent {
+ public:
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
+ };
+
+ template <typename Graph>
+ struct StaticGraphConcept {
+ void constraints() {
+ function_requires<BaseGraphComponentConcept<Graph> >();
+ function_requires<IterableGraphComponentConcept<Graph> >();
+ function_requires<MappableGraphComponentConcept<Graph> >();
+ }
+ Graph& graph;
+ };
+
+ class ExtendableGraph
+ : virtual public BaseGraphComponent, public StaticGraph, public ExtendableGraphComponent, public ClearableGraphComponent {
+ public:
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
+ };
+
+ template <typename Graph>
+ struct ExtendableGraphConcept {
+ void constraints() {
+ function_requires<StaticGraphConcept<Graph> >();
+ function_requires<ExtendableGraphComponentConcept<Graph> >();
+ function_requires<ClearableGraphComponentConcept<Graph> >();
+ }
+ Graph& graph;
+ };
+
+ class ErasableGraph
+ : virtual public BaseGraphComponent, public ExtendableGraph, public ErasableGraphComponent {
+ public:
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
+ };
+
+ template <typename Graph>
+ struct ErasableGraphConcept {
+ void constraints() {
+ function_requires<ExtendableGraphConcept<Graph> >();
+ function_requires<ErasableGraphComponentConcept<Graph> >();
+ }
+ Graph& graph;
+ };
+
// @}
} //namespace skeleton
} //namespace lemon
Modified: hugo/branches/graph_factory/src/lemon/skeletons/graph_component.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/skeletons/graph_component.h (original)
+++ hugo/branches/graph_factory/src/lemon/skeletons/graph_component.h Thu Oct 21 17:46:38 2004
@@ -16,19 +16,18 @@
///\ingroup skeletons
///\file
-///\brief BaseGraph, IterableBaseGraph, IdableBaseGraph, MaxIdableBaseGraph
-/// ExtendableBaseGraph, ClearableBaseGraph, ErasableBaseGraph classes.
+///\brief The graph components.
+
#ifndef LEMON_SKELETON_BASE_GRAPH_H
#define LEMON_SKELETON_BASE_GRAPH_H
#include <lemon/invalid.h>
+#include <lemon/skeletons/maps.h>
namespace lemon {
namespace skeleton {
-
-
/// An empty base graph class.
/// This class provides the most minimal features of a graph structure.
@@ -199,11 +198,11 @@
/// core iterable interface for the graph structure.
/// The most of the base graphs should be conform to this concept.
- class BaseIterableGraphComponent : public BaseGraphComponent {
+ class BaseIterableGraphComponent : virtual public BaseGraphComponent {
public:
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
/// Gives back the first Node in the iterating order.
@@ -295,11 +294,11 @@
/// The most of the base graphs should be conform to this concept.
/// The id's are unique and immutable.
- class IDableGraphComponent : public BaseGraphComponent {
+ class IDableGraphComponent : virtual public BaseGraphComponent {
public:
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
/// Gives back an unique integer id for the Node.
@@ -326,8 +325,10 @@
const Graph& const_graph = graph;
typename Graph::Node node;
int nid = const_graph.id(node);
+ nid = const_graph.id(node);
typename Graph::Edge edge;
int eid = const_graph.id(edge);
+ eid = const_graph.id(edge);
}
Graph& graph;
@@ -340,7 +341,7 @@
/// core max id functions for the graph structure.
/// The most of the base graphs should be conform to this concept.
/// The id's are unique and immutable.
- class MaxIDableGraphComponent : public BaseGraphComponent {
+ class MaxIDableGraphComponent : virtual public BaseGraphComponent {
public:
/// Gives back an integer greater or equal to the maximum Node id.
@@ -377,11 +378,11 @@
/// This class provides beside the core graph features
/// core graph extend interface for the graph structure.
/// The most of the base graphs should be conform to this concept.
- class BaseExtendableGraphComponent : public BaseGraphComponent {
+ class BaseExtendableGraphComponent : virtual public BaseGraphComponent {
public:
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
/// Adds a new Node to the graph.
@@ -422,11 +423,11 @@
/// This class provides beside the core graph features
/// core erase functions for the graph structure.
/// The most of the base graphs should be conform to this concept.
- class BaseErasableGraphComponent : public BaseGraphComponent {
+ class BaseErasableGraphComponent : virtual public BaseGraphComponent {
public:
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
/// Erase a Node from the graph.
@@ -463,7 +464,7 @@
/// This class provides beside the core graph features
/// core clear functions for the graph structure.
/// The most of the base graphs should be conform to this concept.
- class BaseClearableGraphComponent : public BaseGraphComponent {
+ class BaseClearableGraphComponent : virtual public BaseGraphComponent {
public:
/// Erase all the Nodes and Edges from the graph.
@@ -486,31 +487,15 @@
Graph& graph;
};
- }
-}
-
-#endif
-// -*- c++ -*-
-#ifndef LEMON_SKELETON_EXTENDED_GRAPH_H
-#define LEMON_SKELETON_EXTENDED_GRAPH_H
-
-#include <lemon/skeletons/base_graph.h>
-#include <lemon/skeletons/maps.h>
-#include <lemon/invalid.h>
-
-namespace lemon {
-
- namespace skeleton {
-
- class IterableGraphComponent : public BaseGraphComponent {
+ class IterableGraphComponent : virtual public BaseGraphComponent {
public:
typedef IterableGraphComponent Graph;
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
class NodeIt : public Node {
public:
@@ -645,12 +630,12 @@
};
- class IdMappableGraphComponent : public BaseGraphComponent {
+ class IdMappableGraphComponent : virtual public BaseGraphComponent {
typedef IdMappableGraphComponent Graph;
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
public:
@@ -688,13 +673,13 @@
};
- class MappableGraphComponent : public BaseGraphComponent {
+ class MappableGraphComponent : virtual public BaseGraphComponent {
public:
typedef MappableGraphComponent Graph;
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
template <typename Value>
class NodeMap : public ReferenceMap<Node, Value> {
@@ -732,16 +717,16 @@
void constraints() {
{ // int map test
typedef typename Graph::template NodeMap<int> IntNodeMap;
- function_requires<ReferenceMap<IntNodeMap> >();
+ function_requires<ReferenceMapConcept<IntNodeMap> >();
const Graph& cgraph = graph;
IntNodeMap igm(cgraph);
IntNodeMap const &ccigm = igm;
- IntNodeMap igvm(graph,12);
+ IntNodeMap igvm(graph, 42);
IntNodeMap cigm(igm);
cigm=igm;
} { // bool map test
typedef typename Graph::template NodeMap<bool> BoolNodeMap;
- function_requires<ReferenceMap<BoolNodeMap> >();
+ function_requires<ReferenceMapConcept<BoolNodeMap> >();
const Graph& cgraph = graph;
BoolNodeMap igm(cgraph);
BoolNodeMap const &ccigm = igm;
@@ -750,27 +735,27 @@
cigm=igm;
} { // Type map test
typedef typename Graph::template NodeMap<Type> TypeNodeMap;
- function_requires<ReferenceMap<TypeNodeMap> >();
+ function_requires<ReferenceMapConcept<TypeNodeMap> >();
const Graph& cgraph = graph;
TypeNodeMap igm(cgraph);
TypeNodeMap const &ccigm = igm;
- TypeNodeMap igvm(graph,12);
+ TypeNodeMap igvm(graph, Type(42));
TypeNodeMap cigm(igm);
cigm=igm;
}
{ // int map test
typedef typename Graph::template EdgeMap<int> IntEdgeMap;
- function_requires<ReferenceMap<IntEdgeMap> >();
+ function_requires<ReferenceMapConcept<IntEdgeMap> >();
const Graph& cgraph = graph;
IntEdgeMap igm(cgraph);
IntEdgeMap const &ccigm = igm;
- IntEdgeMap igvm(graph,12);
+ IntEdgeMap igvm(graph, 42);
IntEdgeMap cigm(igm);
cigm=igm;
} { // bool map test
typedef typename Graph::template EdgeMap<bool> BoolEdgeMap;
- function_requires<ReferenceMap<BoolEdgeMap> >();
+ function_requires<ReferenceMapConcept<BoolEdgeMap> >();
const Graph& cgraph = graph;
BoolEdgeMap igm(cgraph);
BoolEdgeMap const &ccigm = igm;
@@ -779,11 +764,11 @@
cigm=igm;
} { // Type map test
typedef typename Graph::template EdgeMap<Type> TypeEdgeMap;
- function_requires<ReferenceMap<TypeEdgeMap> >();
+ function_requires<ReferenceMapConcept<TypeEdgeMap> >();
const Graph& cgraph = graph;
TypeEdgeMap igm(cgraph);
TypeEdgeMap const &ccigm = igm;
- TypeEdgeMap igvm(graph,12);
+ TypeEdgeMap igvm(graph, Type(42));
TypeEdgeMap cigm(igm);
cigm=igm;
}
@@ -793,13 +778,13 @@
};
- class ExtendableGraphComponent : public BaseGraphComponent {
+ class ExtendableGraphComponent : virtual public BaseGraphComponent {
public:
- typedef ExtendableExtendedGraph Graph;
+ typedef ExtendableGraphComponent Graph;
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
Node addNode() {
return INVALID;
@@ -822,13 +807,13 @@
Graph graph;
};
- class ErasableGraphComponent : public BaseGraphComponent {
+ class ErasableGraphComponent : virtual public BaseGraphComponent {
public:
typedef ErasableGraphComponent Graph;
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
void erase(const Node&) {}
void erase(const Edge&) {}
@@ -845,15 +830,15 @@
}
Graph graph;
- }
+ };
- class ClearableGraphComponent : public BaseGraphComponent {
+ class ClearableGraphComponent : virtual public BaseGraphComponent {
public:
typedef ClearableGraphComponent Graph;
- typedef BaseGraph::Node Node;
- typedef BaseGraph::Edge Edge;
+ typedef BaseGraphComponent::Node Node;
+ typedef BaseGraphComponent::Edge Edge;
void clear() {}
Modified: hugo/branches/graph_factory/src/lemon/suurballe.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/suurballe.h (original)
+++ hugo/branches/graph_factory/src/lemon/suurballe.h Thu Oct 21 17:46:38 2004
@@ -122,12 +122,10 @@
paths.resize(k);
for (int j=0; j<i; ++j){
Node n=s;
- OutEdgeIt e;
while (n!=t){
-
- G.first(e,n);
+ OutEdgeIt e(G, n);
while (!reversed[e]){
++e;
Modified: hugo/branches/graph_factory/src/test/extended_graph_test.cc
==============================================================================
--- hugo/branches/graph_factory/src/test/extended_graph_test.cc (original)
+++ hugo/branches/graph_factory/src/test/extended_graph_test.cc Thu Oct 21 17:46:38 2004
@@ -3,7 +3,7 @@
#include <iostream>
#include <vector>
-#include <lemon/skeletons/extended_graph.h>
+#include <lemon/skeletons/graph.h>
#include <lemon/list_graph.h>
#include <lemon/smart_graph.h>
#include <lemon/full_graph.h>
@@ -13,73 +13,8 @@
using namespace lemon;
+using namespace lemon::skeleton;
-template void lemon::skeleton::checkIterableExtendedGraph
-<skeleton::IterableExtendedGraph>(skeleton::IterableExtendedGraph &);
-
-template void lemon::skeleton::checkIdMappableExtendedGraph
-<skeleton::IdMappableExtendedGraph>(skeleton::IdMappableExtendedGraph &);
-
-template void lemon::skeleton::checkMappableExtendedGraph
-<skeleton::MappableExtendedGraph>(skeleton::MappableExtendedGraph &);
-
-template void lemon::skeleton::checkExtendableExtendedGraph
-<skeleton::ExtendableExtendedGraph>(skeleton::ExtendableExtendedGraph &);
-
-template void lemon::skeleton::checkErasableExtendedGraph
-<skeleton::ErasableExtendedGraph>(skeleton::ErasableExtendedGraph &);
-
-template void lemon::skeleton::checkClearableExtendedGraph
-<skeleton::ClearableExtendedGraph>(skeleton::ClearableExtendedGraph &);
-
-
-
-template void lemon::skeleton::checkIterableExtendedGraph
-<ListGraph>(ListGraph &);
-
-template void lemon::skeleton::checkIdMappableExtendedGraph
-<ListGraph>(ListGraph &);
-
-template void lemon::skeleton::checkMappableExtendedGraph
-<ListGraph>(ListGraph &);
-
-template void lemon::skeleton::checkExtendableExtendedGraph
-<ListGraph>(ListGraph &);
-
-template void lemon::skeleton::checkErasableExtendedGraph
-<ListGraph>(ListGraph &);
-
-template void lemon::skeleton::checkClearableExtendedGraph
-<ListGraph>(ListGraph &);
-
-
-
-
-template void lemon::skeleton::checkIterableExtendedGraph
-<SmartGraph>(SmartGraph &);
-
-template void lemon::skeleton::checkIdMappableExtendedGraph
-<SmartGraph>(SmartGraph &);
-
-template void lemon::skeleton::checkMappableExtendedGraph
-<SmartGraph>(SmartGraph &);
-
-template void lemon::skeleton::checkExtendableExtendedGraph
-<SmartGraph>(SmartGraph &);
-
-template void lemon::skeleton::checkClearableExtendedGraph
-<SmartGraph>(SmartGraph &);
-
-
-
-template void lemon::skeleton::checkIterableExtendedGraph
-<FullGraph>(FullGraph &);
-
-template void lemon::skeleton::checkIdMappableExtendedGraph
-<FullGraph>(FullGraph &);
-
-template void lemon::skeleton::checkMappableExtendedGraph
-<FullGraph>(FullGraph &);
template<class Graph> void bidirPetersen(Graph &G)
@@ -116,19 +51,51 @@
int main() {
///\file
- {
+ { // checking graph components
+ function_requires<BaseGraphComponentConcept<BaseGraphComponent> >();
+
+ function_requires<BaseIterableGraphComponentConcept<BaseIterableGraphComponent> >();
+
+ function_requires<IDableGraphComponentConcept<IDableGraphComponent> >();
+ function_requires<MaxIDableGraphComponentConcept<MaxIDableGraphComponent> >();
+
+ function_requires<BaseExtendableGraphComponentConcept<BaseExtendableGraphComponent> >();
+ function_requires<BaseErasableGraphComponentConcept<BaseErasableGraphComponent> >();
+ function_requires<BaseClearableGraphComponentConcept<BaseClearableGraphComponent> >();
+
+ function_requires<IterableGraphComponentConcept<IterableGraphComponent> >();
+
+ function_requires<IdMappableGraphComponentConcept<IdMappableGraphComponent> >();
+ function_requires<MappableGraphComponentConcept<MappableGraphComponent> >();
+
+ function_requires<ExtendableGraphComponentConcept<ExtendableGraphComponent> >();
+ function_requires<ErasableGraphComponentConcept<ErasableGraphComponent> >();
+ function_requires<ClearableGraphComponentConcept<ClearableGraphComponent> >();
+ }
+ { // checking skeleton graphs
+ function_requires<StaticGraphConcept<StaticGraph> >();
+ function_requires<ExtendableGraphConcept<ExtendableGraph> >();
+ function_requires<ErasableGraphConcept<ErasableGraph> >();
+ }
+ { // checking list graph
+ function_requires<ErasableGraphConcept<ListGraph> >();
+
ListGraph G;
addPetersen(G);
bidirPetersen(G);
checkPetersen(G);
}
+ { // checking smart graph
+ function_requires<ExtendableGraphConcept<SmartGraph> >();
- {
SmartGraph G;
addPetersen(G);
bidirPetersen(G);
checkPetersen(G);
}
+ { // checking full graph
+ function_requires<StaticGraphConcept<FullGraph> >();
+ }
std::cout << __FILE__ ": All tests passed.\n";
Modified: hugo/branches/graph_factory/src/test/graph_wrapper_test.cc
==============================================================================
--- hugo/branches/graph_factory/src/test/graph_wrapper_test.cc (original)
+++ hugo/branches/graph_factory/src/test/graph_wrapper_test.cc Thu Oct 21 17:46:38 2004
@@ -15,8 +15,11 @@
*/
#include<iostream>
+#include<lemon/concept_check.h>
+
#include<lemon/smart_graph.h>
#include<lemon/skeletons/graph.h>
+
#include<lemon/list_graph.h>
#include<lemon/full_graph.h>
#include<lemon/graph_wrapper.h>
@@ -32,66 +35,31 @@
*/
using namespace lemon;
+using namespace lemon::skeleton;
typedef SmartGraph Graph;
-//Compile GraphWrapper
-typedef GraphWrapper<Graph> GW;
-template void lemon::skeleton::checkCompileStaticGraph<GW>(GW &);
-
-//Compile RevGraphWrapper
-typedef RevGraphWrapper<Graph> RevGW;
-template void lemon::skeleton::checkCompileStaticGraph<RevGW>(RevGW &);
-
-//Compile SubGraphWrapper
-typedef SubGraphWrapper<Graph, Graph::NodeMap<bool>,
- Graph::EdgeMap<bool> > SubGW;
-template void lemon::skeleton::checkCompileStaticGraph<SubGW>(SubGW &);
-
-//Compile NodeSubGraphWrapper
-typedef NodeSubGraphWrapper<Graph, Graph::NodeMap<bool> > NodeSubGW;
-template void lemon::skeleton::checkCompileStaticGraph<NodeSubGW>(NodeSubGW &);
-
-//Compile EdgeSubGraphWrapper
-typedef EdgeSubGraphWrapper<Graph, Graph::EdgeMap<bool> > EdgeSubGW;
-template void lemon::skeleton::checkCompileStaticGraph<EdgeSubGW>(EdgeSubGW &);
-
-//Compile UndirGraphWrapper
-/// \bug UndirGraphWrapper cannot pass the StaticGraph test
-//typedef UndirGraphWrapper<Graph> UndirGW;
-//template void checkCompileStaticGraph<UndirGW>(UndirGW &);
-
-//Compile UndirGraph
-//typedef UndirGraph<Graph> UndirG;
-//template void checkCompileStaticGraph<UndirG>(UndirG &);
-
-//Compile SubBidirGraphWrapper
-typedef SubBidirGraphWrapper<Graph, Graph::EdgeMap<bool>,
- Graph::EdgeMap<bool> > SubBDGW;
-template void lemon::skeleton::checkCompileStaticGraph<SubBDGW>(SubBDGW &);
-
-//Compile BidirGraphWrapper
-typedef BidirGraphWrapper<Graph> BidirGW;
-template void lemon::skeleton::checkCompileStaticGraph<BidirGW>(BidirGW &);
-
-//Compile BidirGraph
-typedef BidirGraph<Graph> BidirG;
-template void lemon::skeleton::checkCompileStaticGraph<BidirG>(BidirG &);
-
-//Compile ResGraphWrapper
-typedef ResGraphWrapper<Graph, int, Graph::EdgeMap<int>,
- Graph::EdgeMap<int> > ResGW;
-template void lemon::skeleton::checkCompileStaticGraph<ResGW>(ResGW &);
-
-//Compile ErasingFirstGraphWrapper
-typedef ErasingFirstGraphWrapper<Graph, Graph::NodeMap<Graph::Edge> > ErasingFirstGW;
-template
-void lemon::skeleton::checkCompileStaticGraph<ErasingFirstGW>(ErasingFirstGW &);
-
int main()
{
+ {
+ function_requires<StaticGraphConcept<GraphWrapper<Graph> > >();
+
+ function_requires<StaticGraphConcept<RevGraphWrapper<Graph> > >();
+
+ function_requires<StaticGraphConcept<SubGraphWrapper<Graph, Graph::NodeMap<bool> , Graph::NodeMap<bool> > > > >();
+ function_requires<StaticGraphConcept<NodeSubGraphWrapper<Graph, Graph::NodeMap<bool> > > >();
+ function_requires<StaticGraphConcept<EdgeSubGraphWrapper<Graph, Graph::EdgeMap<bool> > > >();
+
+ function_requires<StaticGraphConcept<SubBidirGraphWrapper<Graph, Graph::EdgeMap<bool>, Graph::EdgeMap<bool> > > > ();
+
+ function_requires<StaticGraphConcept<BidirGraph<Graph> > >();
+
+ function_requires<StaticGraphConcept<ResGraphWrapper<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > > >();
+
+ function_requires<StaticGraphConcept<ErasingFirstGraphWrapper<Graph, Graph::NodeMap<Graph::Edge> > > >();
+ }
std::cout << __FILE__ ": All tests passed.\n";
return 0;
More information about the Lemon-commits
mailing list