work/marci/bfs_iterator.h BfsIterator5 -> BfsIterator, DfsIterator5 -> DfsIterator
5 #include <list_graph.h>
6 #include <smart_graph.h>
8 #include <time_measure.h>
9 #include <for_each_macros.h>
10 #include <bfs_iterator.h>
15 typedef ListGraph Graph;
16 typedef Graph::Node Node;
17 typedef Graph::NodeIt NodeIt;
18 typedef Graph::Edge Edge;
19 typedef Graph::EdgeIt EdgeIt;
20 typedef Graph::OutEdgeIt OutEdgeIt;
24 Graph::EdgeMap<int> cap(G);
25 readDimacsMaxFlow(std::cin, G, s, t, cap);
26 Graph::NodeMap<OutEdgeIt> pred(G);
30 Graph::NodeMap<bool> reached(G);
33 std::queue<Node> bfs_queue;
35 while (!bfs_queue.empty()) {
36 Node v=bfs_queue.front();
39 for(G.first(e,v); G.valid(e); G.next(e)) {
49 std::cout << ts << std::endl;
54 BfsIterator< Graph, Graph::NodeMap<bool> > bfs(G);
55 bfs.pushAndSetReached(s);
57 while (!bfs.finished()) {
59 if (G.valid(bfs) && bfs.isBNodeNewlyReached())
60 pred.set(bfs.bNode(), bfs);
62 std::cout << ts << std::endl;