[Lemon-commits] [lemon_svn] marci: r1041 - in hugo/branches/hugo++/src: hugo/skeletons test

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:42:54 CET 2006


Author: marci
Date: Wed Aug 25 18:25:29 2004
New Revision: 1041

Modified:
   hugo/branches/hugo++/src/hugo/skeletons/graph.h
   hugo/branches/hugo++/src/test/graph_test.cc

Log:
GraphSkeletons in hugo 0.2 style.



Modified: hugo/branches/hugo++/src/hugo/skeletons/graph.h
==============================================================================
--- hugo/branches/hugo++/src/hugo/skeletons/graph.h	(original)
+++ hugo/branches/hugo++/src/hugo/skeletons/graph.h	Wed Aug 25 18:25:29 2004
@@ -34,30 +34,32 @@
     {
     public:
       /// Defalult constructor.
-      StaticGraphSkeleton() {}
+      StaticGraphSkeleton() { }
       ///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?
-      StaticGraphSkeleton(const StaticGraphSkeleton &G) {}
+      StaticGraphSkeleton(const StaticGraphSkeleton& g) { }
 
-      /// The base type of the node iterators.
+      /// The base type of node iterators, 
+      /// or in other words, the trivial node iterator.
 
-      /// This is the base type of each node iterators,
-      /// thus each kind of node iterator will convert to this.
+      /// 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 have to be inherited 
+      /// from the trivial node iterator.
       class Node {
       public:
 	/// @warning The default constructor sets the iterator
 	/// to an undefined value.
-	Node() {}   //FIXME
+	Node() { }
+	/// Copy constructor.
+	Node(const Node&) { }
 	/// Invalid constructor \& conversion.
 
 	/// This constructor initializes the iterator to be invalid.
 	/// \sa Invalid for more details.
-
-	Node(Invalid) {}
-	//Node(const Node &) {}
-
+	Node(Invalid) { }
 	/// Two iterators are equal if and only if they point to the
 	/// same object or both are invalid.
 	bool operator==(Node) const { return true; }
@@ -73,26 +75,31 @@
 
       /// 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:
+      /// of nodes in graph \c g of type \c Graph like this:
       /// \code
-      ///int count=0;
-      ///for(Graph::NodeIt n(G);G.valid(n);G.next(n)) count++;
+      /// int count=0;
+      /// for (Graph::NodeIt n(g); g.valid(n); ++n) ++count;
       /// \endcode
       class NodeIt : public Node {
       public:
 	/// @warning The default constructor sets the iterator
 	/// to an undefined value.
-	NodeIt() {} //FIXME
+	NodeIt() { }
+	/// Copy constructor.
+	NodeIt(const NodeIt&) { }
 	/// Invalid constructor \& conversion.
 
-	/// Initialize the iterator to be invalid
+	/// Initialize the iterator to be invalid.
 	/// \sa Invalid for more details.
-	NodeIt(Invalid) {}
-	/// Sets the iterator to the first node of \c G.
-	NodeIt(const StaticGraphSkeleton &) {}
-	/// @warning The default constructor sets the iterator
-	/// to an undefined value.
-	NodeIt(const NodeIt &n) : Node(n) {}
+	NodeIt(Invalid) { }
+	/// Sets the iterator to the first node of \c g.
+	NodeIt(const StaticGraphSkeleton& g) { }
+	/// Sets the iterator to the node of \c g pointed by the trivial 
+	/// iterator n. This feature necessitates that each time we 
+	/// iterate the node-set, the iteration order is the same.
+	NodeIt(const StaticGraphSkeleton& g, const Node& n) { }
+	/// Assign the iterator to the next node.
+	NodeIt& operator++() { return *this; }
       };
     
     
@@ -101,9 +108,11 @@
       public:
 	/// @warning The default constructor sets the iterator
 	/// to an undefined value.
-	Edge() {}   //FIXME
-	/// Initialize the iterator to be invalid
-	Edge(Invalid) {}
+	Edge() { }
+	/// Copy constructor.
+	Edge(const Edge&) { }
+	/// Initialize the iterator to be invalid.
+	Edge(Invalid) { }
 	/// Two iterators are equal if and only if they point to the
 	/// same object or both are invalid.
 	bool operator==(Edge) const { return true; }
@@ -117,26 +126,34 @@
       /// 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.
+      /// in graph \c g of type \c Graph as follows.
       /// \code
-      ///int count=0;
-      ///for(Graph::OutEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
+      /// int count=0;
+      /// for (Graph::OutEdgeIt e(g, n); g.valid(e); ++e) ++count;
       /// \endcode
     
       class OutEdgeIt : public Edge {
       public:
 	/// @warning The default constructor sets the iterator
 	/// to an undefined value.
-	OutEdgeIt() {}
-	/// Initialize the iterator to be invalid
-	OutEdgeIt(Invalid) {}
+	OutEdgeIt() { }
+	/// Copy constructor.
+	OutEdgeIt(const OutEdgeIt&) { }
+	/// 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 StaticGraphSkeleton &, Node) {}
+	///@param g the graph
+	OutEdgeIt(const StaticGraphSkeleton& g, const Node& n) { }
+	/// 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 StaticGraphSkeleton& g, const Edge& e) { }
+	/// Assign the iterator to the next outedge of the corresponding node.
+	OutEdgeIt& operator++() { return *this; }
       };
 
       /// This iterator goes trough the incoming edges of a node.
@@ -145,20 +162,27 @@
       /// 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.
+      /// in graph \c g of type \c Graph as follows.
       /// \code
-      ///int count=0;
-      ///for(Graph::InEdgeIt e(G,n);G.valid(e);G.next(e)) count++;
+      /// int count=0;
+      /// for(Graph::InEdgeIt e(g, n); g.valid(e); ++) ++count;
       /// \endcode
 
       class InEdgeIt : public Edge {
       public:
 	/// @warning The default constructor sets the iterator
 	/// to an undefined value.
-	InEdgeIt() {}
-	/// Initialize the iterator to be invalid
-	InEdgeIt(Invalid) {}
-	InEdgeIt(const StaticGraphSkeleton &, Node) {}    
+	InEdgeIt() { }
+	/// Copy constructor.
+	InEdgeIt(const InEdgeIt&) { }
+	/// Initialize the iterator to be invalid.
+	InEdgeIt(Invalid) { }
+	/// .
+	InEdgeIt(const StaticGraphSkeleton&, const Node&) { }
+	/// .
+	InEdgeIt(const StaticGraphSkeleton&, const Edge&) { }
+	/// Assign the iterator to the next inedge of the corresponding node.
+	InEdgeIt& operator++() { return *this; }
       };
       //  class SymEdgeIt : public Edge {};
 
@@ -166,19 +190,25 @@
 
       /// 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:
+      /// of edges in a graph \c g of type \c Graph as follows:
       /// \code
-      ///int count=0;
-      ///for(Graph::EdgeIt e(G);G.valid(e);G.next(e)) count++;
+      /// int count=0;
+      /// for(Graph::EdgeIt e(g); g.valid(e); ++e) ++count;
       /// \endcode
       class EdgeIt : public Edge {
       public:
 	/// @warning The default constructor sets the iterator
 	/// to an undefined value.
-	EdgeIt() {}
-	/// Initialize the iterator to be invalid
-	EdgeIt(Invalid) {}
-	EdgeIt(const StaticGraphSkeleton &) {}
+	EdgeIt() { }
+	/// Copy constructor.
+	EdgeIt(const EdgeIt&) { }
+	/// Initialize the iterator to be invalid.
+	EdgeIt(Invalid) { }
+	/// .
+	EdgeIt(const StaticGraphSkeleton&) { }
+	/// .
+	EdgeIt(const StaticGraphSkeleton&, const Edge&) { } 
+	EdgeIt& operator++() { return *this; }
       };
 
       /// First node of the graph.
@@ -186,15 +216,15 @@
       /// \retval i the first node.
       /// \return the first node.
       ///
-      NodeIt &first(NodeIt &i) const { return i;}
+      NodeIt& first(NodeIt& i) const { return i; }
 
       /// The first incoming edge.
-      InEdgeIt &first(InEdgeIt &i, Node) const { return i;}
+      InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
       /// The first outgoing edge.
-      OutEdgeIt &first(OutEdgeIt &i, Node) const { return i;}
-      //  SymEdgeIt &first(SymEdgeIt &, Node) const { return i;}
+      OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
+      //  SymEdgeIt& first(SymEdgeIt&, Node) const { return i; }
       /// The first edge of the Graph.
-      EdgeIt &first(EdgeIt &i) const { return i;}
+      EdgeIt& first(EdgeIt& i) const { return i; }
 
       //     Node getNext(Node) const {}
       //     InEdgeIt getNext(InEdgeIt) const {}
@@ -203,14 +233,14 @@
       //     EdgeIt getNext(EdgeIt) const {}
 
       /// Go to the next node.
-      NodeIt &next(NodeIt &i) const { return i;}
+      NodeIt& next(NodeIt& i) const { return i; }
       /// Go to the next incoming edge.
-      InEdgeIt &next(InEdgeIt &i) const { return i;}
+      InEdgeIt& next(InEdgeIt& i) const { return i; }
       /// Go to the next outgoing edge.
-      OutEdgeIt &next(OutEdgeIt &i) const { return i;}
-      //SymEdgeIt &next(SymEdgeIt &) const {}
+      OutEdgeIt& next(OutEdgeIt& i) const { return i; }
+      //SymEdgeIt& next(SymEdgeIt&) const { }
       /// Go to the next edge.
-      EdgeIt &next(EdgeIt &i) const { return i;}
+      EdgeIt& next(EdgeIt& i) const { return i; }
 
       ///Gives back the head node of an edge.
       Node head(Edge) const { return INVALID; }
@@ -229,33 +259,32 @@
 
       ///\todo Maybe, it would be better if iterator converted to
       ///bool directly, as Jacint prefers.
-      bool valid(const Node&) const { return true;}
+      bool valid(const Node&) const { return true; }
       /// Checks if an edge iterator is valid
 
       ///\todo Maybe, it would be better if iterator converted to
       ///bool directly, as Jacint prefers.
-      bool valid(const Edge&) const { return true;}
+      bool valid(const Edge&) const { return true; }
 
       ///Gives back the \e id of a node.
 
       ///\warning Not all graph structures provide this feature.
       ///
-      int id(const Node&) const { return 0;}
+      int id(const Node&) const { return 0; }
       ///Gives back the \e id of an edge.
 
       ///\warning Not all graph structures provide this feature.
       ///
-      int id(const Edge&) const { return 0;}
+      int id(const Edge&) const { return 0; }
 
       /// Resets the graph.
 
       /// This function deletes all edges and nodes of the graph.
       /// It also frees the memory allocated to store them.
-      void clear() {}
-
-      int nodeNum() const { return 0;}
-      int edgeNum() const { return 0;}
+      void clear() { }
 
+      int nodeNum() const { return 0; }
+      int edgeNum() const { return 0; }
 
 
       ///Reference map of the nodes to type \c T.
@@ -272,14 +301,14 @@
 
 	class ReferenceMap<Node,T>;
 
-	NodeMap(const StaticGraphSkeleton &) {}
-	NodeMap(const StaticGraphSkeleton &, T) {}
+	NodeMap(const StaticGraphSkeleton&) { }
+	NodeMap(const StaticGraphSkeleton&, T) { }
 
 	///Copy constructor
-	template<typename TT> NodeMap(const NodeMap<TT> &) {}
+	template<typename TT> NodeMap(const NodeMap<TT>&) { }
 	///Assignment operator
-	template<typename TT> NodeMap &operator=(const NodeMap<TT> &)
-	{return *this;}
+	template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
+	{ return *this; }
       };
 
       ///Reference map of the edges to type \c T.
@@ -295,14 +324,14 @@
 	typedef T ValueType;
 	typedef Edge KeyType;
 
-	EdgeMap(const StaticGraphSkeleton &) {}
-	EdgeMap(const StaticGraphSkeleton &, T ) {}
+	EdgeMap(const StaticGraphSkeleton&) { }
+	EdgeMap(const StaticGraphSkeleton&, T) { }
     
 	///Copy constructor
-	template<typename TT> EdgeMap(const EdgeMap<TT> &) {}
+	template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
 	///Assignment operator
-	template<typename TT> EdgeMap &operator=(const EdgeMap<TT> &)
-	{return *this;}
+	template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
+	{ return *this; }
       };
     };
 
@@ -317,31 +346,31 @@
     {
     public:
       /// Defalult constructor.
-      GraphSkeleton() {}
+      GraphSkeleton() { }
       ///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?
-      GraphSkeleton(const GraphSkeleton &G) {}
+      GraphSkeleton(const GraphSkeleton&) { }
 
       ///Add a new node to the graph.
 
       /// \return the new node.
       ///
-      Node addNode() { return INVALID;}
+      Node addNode() { return INVALID; }
       ///Add a new edge to the graph.
 
       ///Add a new edge to the graph with tail node \c tail
       ///and head node \c head.
       ///\return the new edge.
-      Edge addEdge(Node, Node) { return INVALID;}
+      Edge addEdge(Node, Node) { 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 \c EraseableGraphSkeleton.
-      void clear() {}
+      void clear() { }
     };
 
     /// An empty eraseable graph class.
@@ -352,14 +381,14 @@
     {
     public:
       /// Deletes a node.
-      void erase(Node n) {}
+      void erase(Node n) { }
       /// Deletes an edge.
-      void erase(Edge e) {}
+      void erase(Edge e) { }
 
       /// Defalult constructor.
-      EraseableGraphSkeleton() {}
+      EraseableGraphSkeleton() { }
       ///Copy consructor.
-      EraseableGraphSkeleton(const GraphSkeleton &G) {}
+      EraseableGraphSkeleton(const GraphSkeleton&) { }
     };
 
     // @}

Modified: hugo/branches/hugo++/src/test/graph_test.cc
==============================================================================
--- hugo/branches/hugo++/src/test/graph_test.cc	(original)
+++ hugo/branches/hugo++/src/test/graph_test.cc	Wed Aug 25 18:25:29 2004
@@ -1,6 +1,6 @@
 #include<iostream>
 #include<hugo/smart_graph.h>
-//#include<hugo/skeletons/graph.h>
+#include<hugo/skeletons/graph.h>
 #include<hugo/list_graph.h>
 #include<hugo/full_graph.h>
 
@@ -18,7 +18,7 @@
 */
 
 using namespace hugo;
-//using namespace hugo::skeleton;
+using namespace hugo::skeleton;
 
 template<class Graph> void checkCompileStaticGraph(Graph &G) 
 {
@@ -177,7 +177,7 @@
   }
 
   //check findEdge
-  G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
+  //G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
   
 }
 
@@ -281,9 +281,9 @@
   }  
 }
 
-// template
-// void checkCompileStaticGraph<StaticGraphSkeleton>(StaticGraphSkeleton &);
-// template void checkCompile<GraphSkeleton>(GraphSkeleton &);
+template 
+void checkCompileStaticGraph<StaticGraphSkeleton>(StaticGraphSkeleton &);
+template void checkCompile<GraphSkeleton>(GraphSkeleton &);
 
 template void checkCompile<SmartGraph>(SmartGraph &);
 template void checkCompile<SymSmartGraph>(SymSmartGraph &);



More information about the Lemon-commits mailing list