[Lemon-commits] [lemon_svn] marci: r485 - hugo/trunk/src/work/marci

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


Author: marci
Date: Wed Apr 21 16:50:42 2004
New Revision: 485

Added:
   hugo/trunk/src/work/marci/bfsit_vs_byhand.cc
Modified:
   hugo/trunk/src/work/marci/makefile

Log:
time comparison for bfs iterator and iterator by hand


Added: hugo/trunk/src/work/marci/bfsit_vs_byhand.cc
==============================================================================
--- (empty file)
+++ hugo/trunk/src/work/marci/bfsit_vs_byhand.cc	Wed Apr 21 16:50:42 2004
@@ -0,0 +1,67 @@
+// -*- c++ -*-
+#include <iostream>
+#include <fstream>
+
+#include <list_graph.h>
+#include <smart_graph.h>
+#include <dimacs.h>
+#include <time_measure.h>
+#include <for_each_macros.h>
+#include <bfs_iterator.h>
+
+using namespace hugo;
+
+int main() {
+  typedef ListGraph Graph; 
+  typedef Graph::Node Node;
+  typedef Graph::NodeIt NodeIt;
+  typedef Graph::Edge Edge;
+  typedef Graph::EdgeIt EdgeIt;
+  typedef Graph::OutEdgeIt OutEdgeIt;
+
+  Graph G;
+  Node s, t;
+  Graph::EdgeMap<int> cap(G);
+  readDimacsMaxFlow(std::cin, G, s, t, cap);
+  Graph::NodeMap<OutEdgeIt> pred(G);
+  Timer ts;
+  {
+    ts.reset();
+    Graph::NodeMap<bool> reached(G);
+    /*Reverse_bfs from t, to find the starting level.*/
+    reached.set(s, true);
+    pred.set(s, INVALID);
+    std::queue<Node> bfs_queue;
+    bfs_queue.push(t);
+    while (!bfs_queue.empty()) {
+      Node v=bfs_queue.front();	
+      bfs_queue.pop();
+      OutEdgeIt e;
+      for(G.first(e,v); G.valid(e); G.next(e)) {
+	Node w=G.head(e);
+	if (!reached[w]) {
+	  bfs_queue.push(w);
+	  reached.set(w, true);
+	  pred.set(w, e);
+	}
+      }
+    }
+
+    std::cout << ts << std::endl;
+  }
+
+  {
+    ts.reset();      
+    BfsIterator5< Graph, Graph::NodeMap<bool> > bfs(G);
+    bfs.pushAndSetReached(s);
+    pred.set(s, INVALID);
+    while (!bfs.finished()) { 
+      ++bfs; 
+      if (G.valid(bfs) && bfs.isBNodeNewlyReached()) 
+	pred.set(bfs.bNode(), bfs);
+    }
+    std::cout << ts << std::endl;
+  }
+
+  return 0;
+}

Modified: hugo/trunk/src/work/marci/makefile
==============================================================================
--- hugo/trunk/src/work/marci/makefile	(original)
+++ hugo/trunk/src/work/marci/makefile	Wed Apr 21 16:50:42 2004
@@ -12,7 +12,7 @@
 CXXFLAGS = -g -O -W -Wall $(INCLUDEDIRS) -ansi -pedantic -ftemplate-depth-30
 
 LEDABINARIES = leda_graph_demo leda_bfs_dfs max_bipartite_matching_demo
-BINARIES = edmonds_karp_demo iterator_bfs_demo macro_test lg_vs_sg
+BINARIES = edmonds_karp_demo iterator_bfs_demo macro_test lg_vs_sg bfsit_vs_byhand
 #gw_vs_not preflow_demo_boost edmonds_karp_demo_boost preflow_demo_jacint preflow_demo_athos edmonds_karp_demo_alpar preflow_demo_leda
 
 all: $(BINARIES)



More information about the Lemon-commits mailing list