diff -r ee5959aa4410 -r c280de819a73 src/work/marci/bfsit_vs_byhand.cc --- a/src/work/marci/bfsit_vs_byhand.cc Sun Apr 17 18:57:22 2005 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -// -*- c++ -*- -#include -#include - -//#include -#include -#include -#include -#include -//#include -#include -#include - -using namespace lemon; - -using std::cout; -using std::endl; - -int main() { - // typedef SageGraph Graph; - typedef SmartGraph Graph ; - //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; - readDimacs(std::cin, g); - NodeIt s(g); - - cout << g.nodeNum() << endl; - cout << g.edgeNum() << endl; - - Graph::NodeMap pred(g); - cout << "iteration time of bfs written by hand..." << endl; - Timer ts; - ts.reset(); - for (int i=0; i<100; ++i) - { - Graph::NodeMap reached(g); - reached.set(s, true); - pred.set(s, INVALID); - std::queue bfs_queue; - bfs_queue.push(s); - while (!bfs_queue.empty()) { - Node v=bfs_queue.front(); - bfs_queue.pop(); - for(OutEdgeIt e(g,v); e!=INVALID; ++e) { - Node w=g.target(e); - if (!reached[w]) { - bfs_queue.push(w); - reached.set(w, true); - pred.set(w, e); - } - } - } - } - std::cout << ts << std::endl; - - cout << "iteration time with bfs iterator..." << endl; - ts.reset(); - for (int i=0; i<100; ++i) - { - Graph::NodeMap reached(g); - marci::BfsIterator< Graph, Graph::NodeMap > bfs(g, reached); - bfs.pushAndSetReached(s); - pred.set(s, INVALID); - while (!bfs.finished()) { - ++bfs; - if (Graph::Edge(bfs)!=INVALID && bfs.isBNodeNewlyReached()) - pred.set(bfs.target(), Graph::Edge(bfs)); - } - } - std::cout << ts << std::endl; - - cout << "iteration time with bfs aplar..." << endl; - ts.reset(); - for (int i=0; i<100; ++i) - { - Bfs bfs(g); - bfs.setPredMap(pred); - bfs.run(s); - } - std::cout << ts << std::endl; - - - return 0; -}