# HG changeset patch # User alpar # Date 1130949149 0 # Node ID b1f441f24d08bc6891f02f51641e4ab3a473c560 # Parent bf267b301a5e1b26e290dc8f5995d95d85a6e292 GRAPH_TYPEDEFS and UNDIRGRAPH_TYPEDEFS macros added to graph_utils.h. diff -r bf267b301a5e -r b1f441f24d08 benchmark/bench_tools.h --- a/benchmark/bench_tools.h Wed Nov 02 15:28:37 2005 +0000 +++ b/benchmark/bench_tools.h Wed Nov 02 16:32:29 2005 +0000 @@ -5,26 +5,9 @@ #include #include +#include #include -///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 void addHyperCube(Graph &G,int dim,std::vector &nodes) { - GRAPH_TYPEDEF_FACTORY(Graph); + GRAPH_TYPEDEFS(typename Graph); std::vector bits(dim+1); bits[0]=1; @@ -109,7 +92,7 @@ template void addBiDirHyperCube(Graph &G,int dim,std::vector&nodes) { - GRAPH_TYPEDEF_FACTORY(Graph); + GRAPH_TYPEDEFS(typename Graph); std::vector bits(dim+1); bits[0]=1; diff -r bf267b301a5e -r b1f441f24d08 benchmark/bfs-bench.cc --- a/benchmark/bfs-bench.cc Wed Nov 02 15:28:37 2005 +0000 +++ b/benchmark/bfs-bench.cc Wed Nov 02 16:32:29 2005 +0000 @@ -31,7 +31,7 @@ template void bfsStlQueue(Graph &G,typename Graph::Node source) { - GRAPH_TYPEDEF_FACTORY(Graph); + GRAPH_TYPEDEFS(typename Graph); using namespace std; @@ -56,7 +56,7 @@ template void bfsOwnQueue(Graph &G,typename Graph::Node source) { - GRAPH_TYPEDEF_FACTORY(Graph); + GRAPH_TYPEDEFS(typename Graph); using namespace std; @@ -84,7 +84,7 @@ template 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; diff -r bf267b301a5e -r b1f441f24d08 benchmark/graph-bench.cc --- a/benchmark/graph-bench.cc Wed Nov 02 15:28:37 2005 +0000 +++ b/benchmark/graph-bench.cc Wed Nov 02 16:32:29 2005 +0000 @@ -14,7 +14,7 @@ template void makeFullGraph(int n, int rat, int p) { - GRAPH_TYPEDEF_FACTORY(Graph); + GRAPH_TYPEDEFS(typename Graph); Graph G; diff -r bf267b301a5e -r b1f441f24d08 benchmark/hcube.cc --- a/benchmark/hcube.cc Wed Nov 02 15:28:37 2005 +0000 +++ b/benchmark/hcube.cc Wed Nov 02 16:32:29 2005 +0000 @@ -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; diff -r bf267b301a5e -r b1f441f24d08 lemon/graph_utils.h --- a/lemon/graph_utils.h Wed Nov 02 15:28:37 2005 +0000 +++ b/lemon/graph_utils.h Wed Nov 02 16:32:29 2005 +0000 @@ -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.