[Lemon-commits] [lemon_svn] alpar: r2288 - in hugo/trunk: benchmark lemon

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


Author: alpar
Date: Wed Nov  2 17:32:29 2005
New Revision: 2288

Modified:
   hugo/trunk/benchmark/bench_tools.h
   hugo/trunk/benchmark/bfs-bench.cc
   hugo/trunk/benchmark/graph-bench.cc
   hugo/trunk/benchmark/hcube.cc
   hugo/trunk/lemon/graph_utils.h

Log:
GRAPH_TYPEDEFS and UNDIRGRAPH_TYPEDEFS macros added to graph_utils.h.

Modified: hugo/trunk/benchmark/bench_tools.h
==============================================================================
--- hugo/trunk/benchmark/bench_tools.h	(original)
+++ hugo/trunk/benchmark/bench_tools.h	Wed Nov  2 17:32:29 2005
@@ -5,26 +5,9 @@
 #include<vector>
 #include<iostream>
 
+#include<lemon/graph_utils.h>
 #include<lemon/time_measure.h>
 
-///An experimental typedef factory
-#define GRAPH_TYPEDEF_FACTORY(Graph) \
-   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;
-
-#define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \
-   typedef Graph::   Node      Node;\
-   typedef Graph::   NodeIt    NodeIt;\
-   typedef Graph::   Edge      Edge;\
-   typedef Graph::   EdgeIt    EdgeIt;\
-   typedef Graph:: InEdgeIt  InEdgeIt;\
-   typedef Graph::OutEdgeIt OutEdgeIt;
- 
-
 ///A primitive primtest
 
 ///\bug 2 is not a prime according to this function!
@@ -93,7 +76,7 @@
 template<class Graph>
 void addHyperCube(Graph &G,int dim,std::vector<typename Graph::Node> &nodes)
 {
-  GRAPH_TYPEDEF_FACTORY(Graph);
+  GRAPH_TYPEDEFS(typename Graph);
   
   std::vector<int> bits(dim+1);
   bits[0]=1;
@@ -109,7 +92,7 @@
 template<class Graph>
 void addBiDirHyperCube(Graph &G,int dim,std::vector<typename Graph::Node>&nodes)
 {
-  GRAPH_TYPEDEF_FACTORY(Graph);
+  GRAPH_TYPEDEFS(typename Graph);
   
   std::vector<int> bits(dim+1);
   bits[0]=1;

Modified: hugo/trunk/benchmark/bfs-bench.cc
==============================================================================
--- hugo/trunk/benchmark/bfs-bench.cc	(original)
+++ hugo/trunk/benchmark/bfs-bench.cc	Wed Nov  2 17:32:29 2005
@@ -31,7 +31,7 @@
 template<class Graph>
 void bfsStlQueue(Graph &G,typename Graph::Node source)
 {
-  GRAPH_TYPEDEF_FACTORY(Graph);
+  GRAPH_TYPEDEFS(typename Graph);
 
   using namespace std;
   
@@ -56,7 +56,7 @@
 template<class Graph>
 void bfsOwnQueue(Graph &G,typename Graph::Node source)
 {
-  GRAPH_TYPEDEF_FACTORY(Graph);
+  GRAPH_TYPEDEFS(typename Graph);
 
   using namespace std;
   
@@ -84,7 +84,7 @@
 template<class Graph>
 void iteratorBench(Graph &G)
 {
-  GRAPH_TYPEDEF_FACTORY(Graph);
+  GRAPH_TYPEDEFS(typename Graph);
 
   int i=0;
   
@@ -97,8 +97,7 @@
 {
   typedef SmartGraph Graph;
 
-  ///\bug GRAPH_TYPEDEF_FACTORY(Graph);
-  GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph);
+  GRAPH_TYPEDEFS(Graph);
 
   Graph G;
   

Modified: hugo/trunk/benchmark/graph-bench.cc
==============================================================================
--- hugo/trunk/benchmark/graph-bench.cc	(original)
+++ hugo/trunk/benchmark/graph-bench.cc	Wed Nov  2 17:32:29 2005
@@ -14,7 +14,7 @@
 template <class Graph>
 void makeFullGraph(int n, int rat, int p)
 {
-  GRAPH_TYPEDEF_FACTORY(Graph);
+  GRAPH_TYPEDEFS(typename Graph);
 
   Graph G;
   

Modified: hugo/trunk/benchmark/hcube.cc
==============================================================================
--- hugo/trunk/benchmark/hcube.cc	(original)
+++ hugo/trunk/benchmark/hcube.cc	Wed Nov  2 17:32:29 2005
@@ -36,8 +36,7 @@
   //  typedef ListGraph Graph;
   typedef SmartGraph Graph;
 
-  ///\bug GRAPH_TYPEDEF_FACTORY(Graph);
-  GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph);
+  GRAPH_TYPEDEFS(Graph);
 
   Graph G;
   

Modified: hugo/trunk/lemon/graph_utils.h
==============================================================================
--- hugo/trunk/lemon/graph_utils.h	(original)
+++ hugo/trunk/lemon/graph_utils.h	Wed Nov  2 17:32:29 2005
@@ -40,6 +40,46 @@
   /// \addtogroup gutils
   /// @{
 
+  ///Creates convenience typedefs for the graph types and iterators
+
+  ///This \c \#define creates convenience typedefs for the following types
+  ///of \c Graph: \c Node,  \c NodeIt, \c Edge, \c EdgeIt, \c InEdgeIt,
+  ///\c OutEdgeIt.
+  ///\note If \c G it a template parameter, it should be used in this way.
+  ///\code
+  ///  GRAPH_TYPEDEFS(typename G)
+  ///\endcode
+  ///
+  ///\warning There are no typedefs for the graph maps because of the lack of
+  ///template typedefs in C++.
+#define GRAPH_TYPEDEFS(Graph)			\
+  typedef Graph::     Node      Node;		\
+    typedef Graph::   NodeIt    NodeIt;		\
+    typedef Graph::   Edge      Edge;		\
+    typedef Graph::   EdgeIt    EdgeIt;		\
+    typedef Graph:: InEdgeIt  InEdgeIt;		\
+    typedef Graph::OutEdgeIt OutEdgeIt;
+  
+  ///Creates convenience typedefs for the undirected graph types and iterators
+
+  ///This \c \#define creates the same convenience typedefs as defined by
+  ///\ref GRAPH_TYPEDEFS(Graph) and three more, namely it creates
+  ///\c UndirEdge, \c UndirEdgeIt, \c IncEdgeIt,
+  ///
+  ///\note If \c G it a template parameter, it should be used in this way.
+  ///\code
+  ///  UNDIRGRAPH_TYPEDEFS(typename G)
+  ///\endcode
+  ///
+  ///\warning There are no typedefs for the graph maps because of the lack of
+  ///template typedefs in C++.
+#define UNDIRGRAPH_TYPEDEFS(Graph)			\
+  GRAPH_TYPEDEFS(Graph)					\
+    typedef Graph:: UndirEdge   UndirEdge;		\
+    typedef Graph:: UndirEdgeIt UndirEdgeIt;		\
+    typedef Graph:: IncEdgeIt   IncEdgeIt;
+
+
   /// \brief Function to count the items in the graph.
   ///
   /// This function counts the items (nodes, edges etc) in the graph.



More information about the Lemon-commits mailing list