setInvalid() functions added.
4 #include <list_graph.hh>
6 #include <preflow_hl4.h>
7 #include <time_measure.h>
11 //Note, that preflow_hl4.h has a member NodeMap<bool> cut,
12 //the construction of which slowing the running time by 1-10%.
14 // Use a DIMACS max flow file as stdin.
15 // read_dimacs_demo < dimacs_max_flow_file
16 int main(int, char **) {
17 typedef ListGraph::NodeIt NodeIt;
18 typedef ListGraph::EachEdgeIt EachEdgeIt;
22 ListGraph::EdgeMap<int> cap(G);
23 readDimacsMaxFlow(std::cin, G, s, t, cap);
25 std::cout << "preflow_hl4 demo ..." << std::endl;
27 double mintime=1000000;
29 for ( int i=1; i!=11; ++i ) {
30 double pre_time=currTime();
31 preflow_hl4<ListGraph, int> max_flow_test(G, s, t, cap);
32 double post_time=currTime();
33 if ( mintime > post_time-pre_time ) mintime = post_time-pre_time;
36 double pre_time=currTime();
37 preflow_hl4<ListGraph, int> max_flow_test(G, s, t, cap);
38 double post_time=currTime();
40 ListGraph::NodeMap<bool> cut(G);
41 max_flow_test.minCut(cut);
43 for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
44 if (cut.get(G.tail(e)) && !cut.get(G.head(e))) min_cut_value+=cap.get(e);
47 ListGraph::NodeMap<bool> cut1(G);
48 max_flow_test.minMinCut(cut1);
49 int min_min_cut_value=0;
50 for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
51 if (cut.get(G.tail(e)) && !cut.get(G.head(e)))
52 min_min_cut_value+=cap.get(e);
55 ListGraph::NodeMap<bool> cut2(G);
56 max_flow_test.maxMinCut(cut2);
57 int max_min_cut_value=0;
58 for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
59 if (cut2.get(G.tail(e)) && !cut2.get(G.head(e)))
60 max_min_cut_value+=cap.get(e);
63 std::cout << "min time of 10 runs: " << mintime << " sec"<< std::endl;
64 std::cout << "phase 0: " << max_flow_test.time-pre_time
65 << " sec"<< std::endl;
66 std::cout << "phase 1: " << post_time-max_flow_test.time
67 << " sec"<< std::endl;
68 std::cout << "flow value: "<< max_flow_test.maxFlow() << std::endl;
69 std::cout << "min cut value: "<< min_cut_value << std::endl;
70 std::cout << "min min cut value: "<< min_min_cut_value << std::endl;
71 std::cout << "max min cut value: "<< max_min_cut_value <<
72 std::endl<< std::endl;