[Lemon-commits] Balazs Dezso: Renamings in the graph_utils.h + g...

Lemon HG hg at lemon.cs.elte.hu
Tue Apr 22 18:39:46 CEST 2008


details:   http://lemon.cs.elte.hu/hg/lemon/rev/701c529ba737
changeset: 139:701c529ba737
user:      Balazs Dezso <deba [at] inf.elte.hu>
date:      Tue Apr 22 15:04:00 2008 +0200
description:
	Renamings in the graph_utils.h + graph_utils_test added

diffstat:

8 files changed, 787 insertions(+), 1024 deletions(-)
lemon/bits/traits.h      |   12 
lemon/graph_utils.h      | 1566 ++++++++++++++++------------------------------
lemon/lgf_reader.h       |    2 
lemon/lgf_writer.h       |    2 
lemon/smart_graph.h      |    2 
test/Makefile.am         |    3 
test/graph_utils_test.cc |  141 ++++
test/graph_utils_test.h  |   83 ++

diffs (truncated from 2950 to 300 lines):

diff -r a0f755a30cf1 -r 701c529ba737 lemon/bits/traits.h
--- a/lemon/bits/traits.h	Mon Apr 21 17:35:12 2008 +0200
+++ b/lemon/bits/traits.h	Tue Apr 22 15:04:00 2008 +0200
@@ -216,27 +216,27 @@
   };
 
   template <typename Graph, typename Enable = void>
-  struct ArcNumTagIndicator {
+  struct EdgeNumTagIndicator {
     static const bool value = false;
   };
 
   template <typename Graph>
-  struct ArcNumTagIndicator<
+  struct EdgeNumTagIndicator<
     Graph, 
-    typename enable_if<typename Graph::ArcNumTag, void>::type
+    typename enable_if<typename Graph::EdgeNumTag, void>::type
   > {
     static const bool value = true;
   };
 
   template <typename Graph, typename Enable = void>
-  struct FindArcTagIndicator {
+  struct FindEdgeTagIndicator {
     static const bool value = false;
   };
 
   template <typename Graph>
-  struct FindArcTagIndicator<
+  struct FindEdgeTagIndicator<
     Graph, 
-    typename enable_if<typename Graph::FindArcTag, void>::type
+    typename enable_if<typename Graph::FindEdgeTag, void>::type
   > {
     static const bool value = true;
   };
diff -r a0f755a30cf1 -r 701c529ba737 lemon/graph_utils.h
--- a/lemon/graph_utils.h	Mon Apr 21 17:35:12 2008 +0200
+++ b/lemon/graph_utils.h	Tue Apr 22 15:04:00 2008 +0200
@@ -35,7 +35,7 @@
 
 ///\ingroup gutils
 ///\file
-///\brief Digraph utilities.
+///\brief Graph utilities.
 
 namespace lemon {
 
@@ -46,71 +46,36 @@
 
   ///This \c \#define creates convenience typedefs for the following types
   ///of \c Digraph: \c Node,  \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,
-  ///\c OutArcIt
-  ///\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 digraph maps because of the lack of
-  ///template typedefs in C++.
-#define GRAPH_TYPEDEFS(Digraph)				\
-  typedef Digraph::     Node      Node;			\
-    typedef Digraph::   NodeIt    NodeIt;			\
-    typedef Digraph::   Arc      Arc;			\
-    typedef Digraph::   ArcIt    ArcIt;			\
-    typedef Digraph:: InArcIt  InArcIt;			\
-    typedef Digraph::OutArcIt OutArcIt
+  ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap, 
+  ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap. 
+#define DIGRAPH_TYPEDEFS(Digraph)					\
+  typedef Digraph::Node Node;						\
+  typedef Digraph::NodeIt NodeIt;					\
+  typedef Digraph::Arc Arc;						\
+  typedef Digraph::ArcIt ArcIt;						\
+  typedef Digraph::InArcIt InArcIt;					\
+  typedef Digraph::OutArcIt OutArcIt
 
   ///Creates convenience typedefs for the graph types and iterators
 
-  ///This \c \#define creates the same convenience typedefs as defined by
-  ///\ref GRAPH_TYPEDEFS(Digraph) and three more, namely it creates
-  ///\c Edge, \c EdgeIt, \c IncArcIt,
+  ///This \c \#define creates the same convenience typedefs as defined
+  ///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates
+  ///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap,
+  ///\c DoubleEdgeMap.
+#define GRAPH_TYPEDEFS(Graph)						\
+  DIGRAPH_TYPEDEFS(Graph);						\
+  typedef Graph::Edge Edge;						\
+  typedef Graph::EdgeIt EdgeIt;						\
+  typedef Graph::IncEdgeIt IncEdgeIt
+
+  /// \brief Function to count the items in the graph.
   ///
-  ///\note If \c G it a template parameter, it should be used in this way.
-  ///\code
-  ///  UGRAPH_TYPEDEFS(typename G);
-  ///\endcode
-  ///
-  ///\warning There are no typedefs for the digraph maps because of the lack of
-  ///template typedefs in C++.
-#define UGRAPH_TYPEDEFS(Digraph)				\
-  GRAPH_TYPEDEFS(Digraph);				\
-    typedef Digraph:: Edge   Edge;			\
-    typedef Digraph:: EdgeIt EdgeIt;			\
-    typedef Digraph:: IncArcIt   IncArcIt
-
-  ///\brief Creates convenience typedefs for the bipartite digraph 
-  ///types and iterators
-
-  ///This \c \#define creates the same convenience typedefs as defined by
-  ///\ref UGRAPH_TYPEDEFS(Digraph) and two more, namely it creates
-  ///\c RedIt, \c BlueIt, 
-  ///
-  ///\note If \c G it a template parameter, it should be used in this way.
-  ///\code
-  ///  BPUGRAPH_TYPEDEFS(typename G);
-  ///\endcode
-  ///
-  ///\warning There are no typedefs for the digraph maps because of the lack of
-  ///template typedefs in C++.
-#define BPUGRAPH_TYPEDEFS(Digraph)            \
-  UGRAPH_TYPEDEFS(Digraph);		    \
-    typedef Digraph::Red Red;             \
-    typedef Digraph::Blue Blue;             \
-    typedef Digraph::RedIt RedIt;	    \
-    typedef Digraph::BlueIt BlueIt
-
-  /// \brief Function to count the items in the digraph.
-  ///
-  /// This function counts the items (nodes, arcs etc) in the digraph.
+  /// This function counts the items (nodes, arcs etc) in the graph.
   /// The complexity of the function is O(n) because
   /// it iterates on all of the items.
-
-  template <typename Digraph, typename Item>
-  inline int countItems(const Digraph& g) {
-    typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
+  template <typename Graph, typename Item>
+  inline int countItems(const Graph& g) {
+    typedef typename ItemSetTraits<Graph, Item>::ItemIt ItemIt;
     int num = 0;
     for (ItemIt it(g); it != INVALID; ++it) {
       ++num;
@@ -120,184 +85,115 @@
 
   // Node counting:
 
-  namespace _digraph_utils_bits {
+  namespace _graph_utils_bits {
     
-    template <typename Digraph, typename Enable = void>
+    template <typename Graph, typename Enable = void>
     struct CountNodesSelector {
-      static int count(const Digraph &g) {
-        return countItems<Digraph, typename Digraph::Node>(g);
+      static int count(const Graph &g) {
+        return countItems<Graph, typename Graph::Node>(g);
       }
     };
 
-    template <typename Digraph>
+    template <typename Graph>
     struct CountNodesSelector<
-      Digraph, typename 
-      enable_if<typename Digraph::NodeNumTag, void>::type> 
+      Graph, typename 
+      enable_if<typename Graph::NodeNumTag, void>::type> 
     {
-      static int count(const Digraph &g) {
+      static int count(const Graph &g) {
         return g.nodeNum();
       }
     };    
   }
 
-  /// \brief Function to count the nodes in the digraph.
+  /// \brief Function to count the nodes in the graph.
   ///
-  /// This function counts the nodes in the digraph.
+  /// This function counts the nodes in the graph.
   /// The complexity of the function is O(n) but for some
-  /// digraph structures it is specialized to run in O(1).
+  /// graph structures it is specialized to run in O(1).
   ///
-  /// If the digraph contains a \e nodeNum() member function and a 
+  /// If the graph contains a \e nodeNum() member function and a 
   /// \e NodeNumTag tag then this function calls directly the member
   /// function to query the cardinality of the node set.
-  template <typename Digraph>
-  inline int countNodes(const Digraph& g) {
-    return _digraph_utils_bits::CountNodesSelector<Digraph>::count(g);
+  template <typename Graph>
+  inline int countNodes(const Graph& g) {
+    return _graph_utils_bits::CountNodesSelector<Graph>::count(g);
   }
 
-  namespace _digraph_utils_bits {
+  // Arc counting:
+
+  namespace _graph_utils_bits {
     
-    template <typename Digraph, typename Enable = void>
-    struct CountRedsSelector {
-      static int count(const Digraph &g) {
-        return countItems<Digraph, typename Digraph::Red>(g);
+    template <typename Graph, typename Enable = void>
+    struct CountArcsSelector {
+      static int count(const Graph &g) {
+        return countItems<Graph, typename Graph::Arc>(g);
       }
     };
 
-    template <typename Digraph>
-    struct CountRedsSelector<
-      Digraph, typename 
-      enable_if<typename Digraph::NodeNumTag, void>::type> 
+    template <typename Graph>
+    struct CountArcsSelector<
+      Graph, 
+      typename enable_if<typename Graph::ArcNumTag, void>::type> 
     {
-      static int count(const Digraph &g) {
-        return g.redNum();
-      }
-    };    
-  }
-
-  /// \brief Function to count the reds in the digraph.
-  ///
-  /// This function counts the reds in the digraph.
-  /// The complexity of the function is O(an) but for some
-  /// digraph structures it is specialized to run in O(1).
-  ///
-  /// If the digraph contains an \e redNum() member function and a 
-  /// \e NodeNumTag tag then this function calls directly the member
-  /// function to query the cardinality of the A-node set.
-  template <typename Digraph>
-  inline int countReds(const Digraph& g) {
-    return _digraph_utils_bits::CountRedsSelector<Digraph>::count(g);
-  }
-
-  namespace _digraph_utils_bits {
-    
-    template <typename Digraph, typename Enable = void>
-    struct CountBluesSelector {
-      static int count(const Digraph &g) {
-        return countItems<Digraph, typename Digraph::Blue>(g);
-      }
-    };
-
-    template <typename Digraph>
-    struct CountBluesSelector<
-      Digraph, typename 
-      enable_if<typename Digraph::NodeNumTag, void>::type> 
-    {
-      static int count(const Digraph &g) {
-        return g.blueNum();
-      }
-    };    
-  }
-
-  /// \brief Function to count the blues in the digraph.
-  ///
-  /// This function counts the blues in the digraph.
-  /// The complexity of the function is O(bn) but for some
-  /// digraph structures it is specialized to run in O(1).
-  ///
-  /// If the digraph contains a \e blueNum() member function and a 
-  /// \e NodeNumTag tag then this function calls directly the member
-  /// function to query the cardinality of the B-node set.
-  template <typename Digraph>
-  inline int countBlues(const Digraph& g) {
-    return _digraph_utils_bits::CountBluesSelector<Digraph>::count(g);
-  }
-
-
-  // Arc counting:
-
-  namespace _digraph_utils_bits {
-    
-    template <typename Digraph, typename Enable = void>
-    struct CountArcsSelector {
-      static int count(const Digraph &g) {
-        return countItems<Digraph, typename Digraph::Arc>(g);
-      }
-    };
-
-    template <typename Digraph>
-    struct CountArcsSelector<
-      Digraph, 
-      typename enable_if<typename Digraph::ArcNumTag, void>::type> 
-    {
-      static int count(const Digraph &g) {
+      static int count(const Graph &g) {
         return g.arcNum();
       }
     };    
   }



More information about the Lemon-commits mailing list