src/work/marci/bfsit_vs_byhand.cc
changeset 1246 925002e098e7
parent 944 4f064aff855e
equal deleted inserted replaced
13:289dc5c7c075 14:9bc707768d24
    46     bfs_queue.push(s);
    46     bfs_queue.push(s);
    47     while (!bfs_queue.empty()) {
    47     while (!bfs_queue.empty()) {
    48       Node v=bfs_queue.front();	
    48       Node v=bfs_queue.front();	
    49       bfs_queue.pop();
    49       bfs_queue.pop();
    50       for(OutEdgeIt e(g,v); e!=INVALID; ++e) {
    50       for(OutEdgeIt e(g,v); e!=INVALID; ++e) {
    51 	Node w=g.head(e);
    51 	Node w=g.target(e);
    52 	if (!reached[w]) {
    52 	if (!reached[w]) {
    53 	  bfs_queue.push(w);
    53 	  bfs_queue.push(w);
    54 	  reached.set(w, true);
    54 	  reached.set(w, true);
    55 	  pred.set(w, e);
    55 	  pred.set(w, e);
    56 	}
    56 	}
    68     bfs.pushAndSetReached(s);
    68     bfs.pushAndSetReached(s);
    69     pred.set(s, INVALID);
    69     pred.set(s, INVALID);
    70     while (!bfs.finished()) { 
    70     while (!bfs.finished()) { 
    71       ++bfs; 
    71       ++bfs; 
    72       if (Graph::Edge(bfs)!=INVALID && bfs.isBNodeNewlyReached()) 
    72       if (Graph::Edge(bfs)!=INVALID && bfs.isBNodeNewlyReached()) 
    73 	pred.set(bfs.head(), Graph::Edge(bfs));
    73 	pred.set(bfs.target(), Graph::Edge(bfs));
    74     }
    74     }
    75   }
    75   }
    76   std::cout << ts << std::endl;
    76   std::cout << ts << std::endl;
    77 
    77 
    78   cout << "iteration time with bfs aplar..." << endl;
    78   cout << "iteration time with bfs aplar..." << endl;