GRAPH_TYPEDEFS and UNDIRGRAPH_TYPEDEFS macros added to graph_utils.h.
authoralpar
Wed, 02 Nov 2005 16:32:29 +0000
changeset 1756b1f441f24d08
parent 1755 bf267b301a5e
child 1757 bd4199049036
GRAPH_TYPEDEFS and UNDIRGRAPH_TYPEDEFS macros added to graph_utils.h.
benchmark/bench_tools.h
benchmark/bfs-bench.cc
benchmark/graph-bench.cc
benchmark/hcube.cc
lemon/graph_utils.h
     1.1 --- a/benchmark/bench_tools.h	Wed Nov 02 15:28:37 2005 +0000
     1.2 +++ b/benchmark/bench_tools.h	Wed Nov 02 16:32:29 2005 +0000
     1.3 @@ -5,26 +5,9 @@
     1.4  #include<vector>
     1.5  #include<iostream>
     1.6  
     1.7 +#include<lemon/graph_utils.h>
     1.8  #include<lemon/time_measure.h>
     1.9  
    1.10 -///An experimental typedef factory
    1.11 -#define GRAPH_TYPEDEF_FACTORY(Graph) \
    1.12 -   typedef typename Graph::   Node      Node;\
    1.13 -   typedef typename Graph::   NodeIt    NodeIt;\
    1.14 -   typedef typename Graph::   Edge      Edge;\
    1.15 -   typedef typename Graph::   EdgeIt    EdgeIt;\
    1.16 -   typedef typename Graph:: InEdgeIt  InEdgeIt;\
    1.17 -   typedef typename Graph::OutEdgeIt OutEdgeIt;
    1.18 -
    1.19 -#define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \
    1.20 -   typedef Graph::   Node      Node;\
    1.21 -   typedef Graph::   NodeIt    NodeIt;\
    1.22 -   typedef Graph::   Edge      Edge;\
    1.23 -   typedef Graph::   EdgeIt    EdgeIt;\
    1.24 -   typedef Graph:: InEdgeIt  InEdgeIt;\
    1.25 -   typedef Graph::OutEdgeIt OutEdgeIt;
    1.26 - 
    1.27 -
    1.28  ///A primitive primtest
    1.29  
    1.30  ///\bug 2 is not a prime according to this function!
    1.31 @@ -93,7 +76,7 @@
    1.32  template<class Graph>
    1.33  void addHyperCube(Graph &G,int dim,std::vector<typename Graph::Node> &nodes)
    1.34  {
    1.35 -  GRAPH_TYPEDEF_FACTORY(Graph);
    1.36 +  GRAPH_TYPEDEFS(typename Graph);
    1.37    
    1.38    std::vector<int> bits(dim+1);
    1.39    bits[0]=1;
    1.40 @@ -109,7 +92,7 @@
    1.41  template<class Graph>
    1.42  void addBiDirHyperCube(Graph &G,int dim,std::vector<typename Graph::Node>&nodes)
    1.43  {
    1.44 -  GRAPH_TYPEDEF_FACTORY(Graph);
    1.45 +  GRAPH_TYPEDEFS(typename Graph);
    1.46    
    1.47    std::vector<int> bits(dim+1);
    1.48    bits[0]=1;
     2.1 --- a/benchmark/bfs-bench.cc	Wed Nov 02 15:28:37 2005 +0000
     2.2 +++ b/benchmark/bfs-bench.cc	Wed Nov 02 16:32:29 2005 +0000
     2.3 @@ -31,7 +31,7 @@
     2.4  template<class Graph>
     2.5  void bfsStlQueue(Graph &G,typename Graph::Node source)
     2.6  {
     2.7 -  GRAPH_TYPEDEF_FACTORY(Graph);
     2.8 +  GRAPH_TYPEDEFS(typename Graph);
     2.9  
    2.10    using namespace std;
    2.11    
    2.12 @@ -56,7 +56,7 @@
    2.13  template<class Graph>
    2.14  void bfsOwnQueue(Graph &G,typename Graph::Node source)
    2.15  {
    2.16 -  GRAPH_TYPEDEF_FACTORY(Graph);
    2.17 +  GRAPH_TYPEDEFS(typename Graph);
    2.18  
    2.19    using namespace std;
    2.20    
    2.21 @@ -84,7 +84,7 @@
    2.22  template<class Graph>
    2.23  void iteratorBench(Graph &G)
    2.24  {
    2.25 -  GRAPH_TYPEDEF_FACTORY(Graph);
    2.26 +  GRAPH_TYPEDEFS(typename Graph);
    2.27  
    2.28    int i=0;
    2.29    
    2.30 @@ -97,8 +97,7 @@
    2.31  {
    2.32    typedef SmartGraph Graph;
    2.33  
    2.34 -  ///\bug GRAPH_TYPEDEF_FACTORY(Graph);
    2.35 -  GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph);
    2.36 +  GRAPH_TYPEDEFS(Graph);
    2.37  
    2.38    Graph G;
    2.39    
     3.1 --- a/benchmark/graph-bench.cc	Wed Nov 02 15:28:37 2005 +0000
     3.2 +++ b/benchmark/graph-bench.cc	Wed Nov 02 16:32:29 2005 +0000
     3.3 @@ -14,7 +14,7 @@
     3.4  template <class Graph>
     3.5  void makeFullGraph(int n, int rat, int p)
     3.6  {
     3.7 -  GRAPH_TYPEDEF_FACTORY(Graph);
     3.8 +  GRAPH_TYPEDEFS(typename Graph);
     3.9  
    3.10    Graph G;
    3.11    
     4.1 --- a/benchmark/hcube.cc	Wed Nov 02 15:28:37 2005 +0000
     4.2 +++ b/benchmark/hcube.cc	Wed Nov 02 16:32:29 2005 +0000
     4.3 @@ -36,8 +36,7 @@
     4.4    //  typedef ListGraph Graph;
     4.5    typedef SmartGraph Graph;
     4.6  
     4.7 -  ///\bug GRAPH_TYPEDEF_FACTORY(Graph);
     4.8 -  GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph);
     4.9 +  GRAPH_TYPEDEFS(Graph);
    4.10  
    4.11    Graph G;
    4.12    
     5.1 --- a/lemon/graph_utils.h	Wed Nov 02 15:28:37 2005 +0000
     5.2 +++ b/lemon/graph_utils.h	Wed Nov 02 16:32:29 2005 +0000
     5.3 @@ -40,6 +40,46 @@
     5.4    /// \addtogroup gutils
     5.5    /// @{
     5.6  
     5.7 +  ///Creates convenience typedefs for the graph types and iterators
     5.8 +
     5.9 +  ///This \c \#define creates convenience typedefs for the following types
    5.10 +  ///of \c Graph: \c Node,  \c NodeIt, \c Edge, \c EdgeIt, \c InEdgeIt,
    5.11 +  ///\c OutEdgeIt.
    5.12 +  ///\note If \c G it a template parameter, it should be used in this way.
    5.13 +  ///\code
    5.14 +  ///  GRAPH_TYPEDEFS(typename G)
    5.15 +  ///\endcode
    5.16 +  ///
    5.17 +  ///\warning There are no typedefs for the graph maps because of the lack of
    5.18 +  ///template typedefs in C++.
    5.19 +#define GRAPH_TYPEDEFS(Graph)			\
    5.20 +  typedef Graph::     Node      Node;		\
    5.21 +    typedef Graph::   NodeIt    NodeIt;		\
    5.22 +    typedef Graph::   Edge      Edge;		\
    5.23 +    typedef Graph::   EdgeIt    EdgeIt;		\
    5.24 +    typedef Graph:: InEdgeIt  InEdgeIt;		\
    5.25 +    typedef Graph::OutEdgeIt OutEdgeIt;
    5.26 +  
    5.27 +  ///Creates convenience typedefs for the undirected graph types and iterators
    5.28 +
    5.29 +  ///This \c \#define creates the same convenience typedefs as defined by
    5.30 +  ///\ref GRAPH_TYPEDEFS(Graph) and three more, namely it creates
    5.31 +  ///\c UndirEdge, \c UndirEdgeIt, \c IncEdgeIt,
    5.32 +  ///
    5.33 +  ///\note If \c G it a template parameter, it should be used in this way.
    5.34 +  ///\code
    5.35 +  ///  UNDIRGRAPH_TYPEDEFS(typename G)
    5.36 +  ///\endcode
    5.37 +  ///
    5.38 +  ///\warning There are no typedefs for the graph maps because of the lack of
    5.39 +  ///template typedefs in C++.
    5.40 +#define UNDIRGRAPH_TYPEDEFS(Graph)			\
    5.41 +  GRAPH_TYPEDEFS(Graph)					\
    5.42 +    typedef Graph:: UndirEdge   UndirEdge;		\
    5.43 +    typedef Graph:: UndirEdgeIt UndirEdgeIt;		\
    5.44 +    typedef Graph:: IncEdgeIt   IncEdgeIt;
    5.45 +
    5.46 +
    5.47    /// \brief Function to count the items in the graph.
    5.48    ///
    5.49    /// This function counts the items (nodes, edges etc) in the graph.