[Lemon-commits] [lemon_svn] deba: r1301 - hugo/branches/graph_factory/src/lemon

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


Author: deba
Date: Thu Oct 21 18:15:49 2004
New Revision: 1301

Added:
   hugo/branches/graph_factory/src/lemon/graph_utils.h
Modified:
   hugo/branches/graph_factory/src/lemon/Makefile.am
   hugo/branches/graph_factory/src/lemon/bfs.h
   hugo/branches/graph_factory/src/lemon/dfs.h
   hugo/branches/graph_factory/src/lemon/full_graph.h
   hugo/branches/graph_factory/src/lemon/smart_graph.h

Log:
Dfs and Bfs are fixed.
New global function to count items.



Modified: hugo/branches/graph_factory/src/lemon/Makefile.am
==============================================================================
--- hugo/branches/graph_factory/src/lemon/Makefile.am	(original)
+++ hugo/branches/graph_factory/src/lemon/Makefile.am	Thu Oct 21 18:15:49 2004
@@ -10,6 +10,7 @@
 	fib_heap.h							\
 	full_graph.h							\
 	graph_wrapper.h							\
+	graph_utils.h							\
 	invalid.h							\
 	kruskal.h							\
 	list_graph.h							\

Modified: hugo/branches/graph_factory/src/lemon/bfs.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/bfs.h	(original)
+++ hugo/branches/graph_factory/src/lemon/bfs.h	Thu Oct 21 18:15:49 2004
@@ -195,7 +195,7 @@
 	pred_node->set(u,INVALID);
       }
       
-      int N=G->nodeNum();
+      int N= nodeNum(*G);
       std::vector<typename Graph::Node> Q(N);
       int Qh=0;
       int Qt=0;

Modified: hugo/branches/graph_factory/src/lemon/dfs.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/dfs.h	(original)
+++ hugo/branches/graph_factory/src/lemon/dfs.h	Thu Oct 21 18:15:49 2004
@@ -23,7 +23,7 @@
 ///
 ///\todo Revise Manual.
 
-#include <lemon/bin_heap.h>
+#include <lemon/graph_utils.h>
 #include <lemon/invalid.h>
 
 namespace lemon {
@@ -193,7 +193,7 @@
 	pred_node->set(u,INVALID);
       }
       
-      int N = G->nodeNum();
+      int N = nodeNum(*G);
       std::vector<typename Graph::OutEdgeIt> Q(N);
 
       int Qh=0;

Modified: hugo/branches/graph_factory/src/lemon/full_graph.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/full_graph.h	(original)
+++ hugo/branches/graph_factory/src/lemon/full_graph.h	Thu Oct 21 18:15:49 2004
@@ -205,6 +205,17 @@
 
     FullGraph(int n) { construct(n); }
   };
+
+  template <>
+  int nodeNum<FullGraph>(const FullGraph& graph) {
+    return graph.nodeNum();
+  }
+
+  template <>
+  int edgeNum<FullGraph>(const FullGraph& graph) {
+    return graph.edgeNum();
+  }
+
   /// @}  
 
 } //namespace lemon

Added: hugo/branches/graph_factory/src/lemon/graph_utils.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/graph_utils.h	Thu Oct 21 18:15:49 2004
@@ -0,0 +1,55 @@
+/* -*- C++ -*-
+ * src/lemon/graph_utils.h - Part of LEMON, a generic C++ optimization library
+ *
+ * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
+ * (Egervary Combinatorial Optimization Research Group, EGRES).
+ *
+ * Permission to use, modify and distribute this software is granted
+ * provided that this copyright notice appears in all copies. For
+ * precise terms see the accompanying LICENSE file.
+ *
+ * This software is provided "AS IS" with no warranty of any kind,
+ * express or implied, and with no claim as to its suitability for any
+ * purpose.
+ *
+ */
+
+#ifndef LEMON_GRAPH_UTILS_H
+#define LEMON_GRAPH_UTILS_H
+
+///\ingroup utils
+///\file
+///\brief Graph utils.
+///
+
+#include <lemon/invalid.h>
+
+namespace lemon {
+
+  template <typename Graph, typename ItemIt>
+  inline int itemNum(const Graph& graph) {
+    int num = 0;
+    for (ItemIt it(graph); it != INVALID; ++it) {
+      ++num;
+    }
+    return num;
+  }
+
+  template <typename Graph>
+  inline int nodeNum(const Graph& graph) {
+    return itemNum<Graph, typename Graph::NodeIt>(graph);
+  }
+
+  template <typename Graph>
+  inline int edgeNum(const Graph& graph) {
+    return itemNum<Graph, typename Graph::EdgeIt>(graph);
+  }
+
+  template <typename Graph>
+  inline int symEdgeNum(const Graph& graph) {
+    return itemNum<Graph, typename Graph::SymEdgeIt>(graph);
+  }
+
+}
+
+#endif

Modified: hugo/branches/graph_factory/src/lemon/smart_graph.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/smart_graph.h	(original)
+++ hugo/branches/graph_factory/src/lemon/smart_graph.h	Thu Oct 21 18:15:49 2004
@@ -37,6 +37,9 @@
 #include <lemon/vector_map.h>
 
 
+#include <lemon/graph_utils.h>
+
+
 namespace lemon {
 
   /// \addtogroup graphs
@@ -239,8 +242,6 @@
 
   };
 
-
-
   typedef AlterableGraphExtender<SmartGraphBase> AlterableSmartGraphBase;
   typedef IterableGraphExtender<AlterableSmartGraphBase> IterableSmartGraphBase;
   typedef IdMappableGraphExtender<IterableSmartGraphBase> IdMappableSmartGraphBase;
@@ -250,6 +251,17 @@
 
   typedef ClearableSmartGraphBase SmartGraph;
 
+
+  template <>
+  int nodeNum<SmartGraph>(const SmartGraph& graph) {
+    return graph.nodeNum();
+  }
+
+  template <>
+  int edgeNum<SmartGraph>(const SmartGraph& graph) {
+    return graph.edgeNum();
+  }
+
   /// @}  
 } //namespace lemon
 



More information about the Lemon-commits mailing list