# HG changeset patch # User marci # Date 1082559042 0 # Node ID caf183989ec48f7b119480be090445be3d31eb17 # Parent 5165a1c8633eb5fc99116e3efff54234e0d47357 time comparison for bfs iterator and iterator by hand diff -r 5165a1c8633e -r caf183989ec4 src/work/marci/bfsit_vs_byhand.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/work/marci/bfsit_vs_byhand.cc Wed Apr 21 14:50:42 2004 +0000 @@ -0,0 +1,67 @@ +// -*- c++ -*- +#include +#include + +#include +#include +#include +#include +#include +#include + +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 cap(G); + readDimacsMaxFlow(std::cin, G, s, t, cap); + Graph::NodeMap pred(G); + Timer ts; + { + ts.reset(); + Graph::NodeMap reached(G); + /*Reverse_bfs from t, to find the starting level.*/ + reached.set(s, true); + pred.set(s, INVALID); + std::queue 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 > 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; +} diff -r 5165a1c8633e -r caf183989ec4 src/work/marci/makefile --- a/src/work/marci/makefile Wed Apr 21 12:36:53 2004 +0000 +++ b/src/work/marci/makefile Wed Apr 21 14:50:42 2004 +0000 @@ -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)