A generic map with value type [0, N) where N is a small integer.
Can enumerate keys with a given value.
5 #include <list_graph.h>
6 #include <smart_graph.h>
8 #include <edmonds_karp.h>
9 #include <time_measure.h>
10 //#include <graph_wrapper.h>
12 #include <for_each_macros.h>
16 // Use a DIMACS max flow file as stdin.
17 // read_dimacs_demo < dimacs_max_flow_file
27 // template <typename B>
35 int main(int, char **) {
37 typedef ListGraph MutableGraph;
39 // typedef SmartGraph Graph;
40 typedef ListGraph Graph;
41 typedef Graph::Node Node;
42 typedef Graph::EdgeIt EdgeIt;
48 // typedef Mize Tize[0];
50 // std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl;
51 // std::cout << sizeof(bize) << std::endl;
55 // std::cout << sizeof(k) << std::endl;
63 // std::cout << sizeof(Bumm) << std::endl;
68 Graph::EdgeMap<int> cap(G);
69 readDimacsMaxFlow(std::cin, G, s, t, cap);
71 Graph::EdgeMap<int> flow(G); //0 flow
72 Preflow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
73 pre_flow_test(G, s, t, cap, flow);
74 MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
75 max_flow_test(G, s, t, cap, flow);
78 std::cout << "preflow ..." << std::endl;
81 std::cout << "elapsed time: " << ts << std::endl;
82 std::cout << "flow value: "<< pre_flow_test.flowValue() << std::endl;
86 std::cout << "physical blocking flow augmentation ..." << std::endl;
87 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
90 while (max_flow_test.augmentOnBlockingFlow<MutableGraph>()) { ++i; }
91 std::cout << "elapsed time: " << ts << std::endl;
92 std::cout << "number of augmentation phases: " << i << std::endl;
93 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
97 std::cout << "faster physical blocking flow augmentation ..." << std::endl;
98 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
101 while (max_flow_test.augmentOnBlockingFlow1<MutableGraph>()) { ++i; }
102 std::cout << "elapsed time: " << ts << std::endl;
103 std::cout << "number of augmentation phases: " << i << std::endl;
104 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
108 std::cout << "on-the-fly blocking flow augmentation ..." << std::endl;
109 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
112 while (max_flow_test.augmentOnBlockingFlow2()) { ++i; }
113 std::cout << "elapsed time: " << ts << std::endl;
114 std::cout << "number of augmentation phases: " << i << std::endl;
115 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
119 std::cout << "on-the-fly shortest path augmentation ..." << std::endl;
120 FOR_EACH_LOC(Graph::EdgeIt, e, G) flow.set(e, 0);
123 while (max_flow_test.augmentOnShortestPath()) { ++i; }
124 std::cout << "elapsed time: " << ts << std::endl;
125 std::cout << "number of augmentation phases: " << i << std::endl;
126 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;