1.1 --- a/src/work/jacint/preflow.cc Fri Mar 19 21:15:14 2004 +0000
1.2 +++ b/src/work/jacint/preflow.cc Fri Mar 19 22:16:05 2004 +0000
1.3 @@ -1,8 +1,8 @@
1.4 #include <iostream>
1.5 #include <fstream>
1.6
1.7 -#include <list_graph.hh>
1.8 -#include <dimacs.hh>
1.9 +#include <list_graph.h>
1.10 +#include <dimacs.h>
1.11 #include <preflow.h>
1.12 #include <time_measure.h>
1.13
1.14 @@ -11,11 +11,11 @@
1.15 // Use a DIMACS max flow file as stdin.
1.16 // read_dimacs_demo < dimacs_max_flow_file
1.17 int main(int, char **) {
1.18 - typedef ListGraph::NodeIt NodeIt;
1.19 - typedef ListGraph::EachEdgeIt EachEdgeIt;
1.20 + typedef ListGraph::Node Node;
1.21 + typedef ListGraph::EdgeIt EdgeIt;
1.22
1.23 ListGraph G;
1.24 - NodeIt s, t;
1.25 + Node s, t;
1.26 ListGraph::EdgeMap<int> cap(G);
1.27 readDimacsMaxFlow(std::cin, G, s, t, cap);
1.28
1.29 @@ -24,27 +24,30 @@
1.30 double mintime=1000000;
1.31
1.32 for ( int i=1; i!=11; ++i ) {
1.33 + ListGraph::EdgeMap<int> flow(G);
1.34 double pre_time=currTime();
1.35 - preflow<ListGraph, int> max_flow_test(G, s, t, cap);
1.36 + Preflow<ListGraph, int> max_flow_test(G, s, t, cap, flow);
1.37 + max_flow_test.run();
1.38 double post_time=currTime();
1.39 if ( mintime > post_time-pre_time ) mintime = post_time-pre_time;
1.40 }
1.41
1.42 - double pre_time=currTime();
1.43 - preflow<ListGraph, int> max_flow_test(G, s, t, cap);
1.44 - double post_time=currTime();
1.45 -
1.46 + ListGraph::EdgeMap<int> flow(G);
1.47 + Preflow<ListGraph, int> max_flow_test(G, s, t, cap, flow);
1.48 + max_flow_test.run();
1.49 +
1.50 ListGraph::NodeMap<bool> cut(G);
1.51 max_flow_test.minCut(cut);
1.52 int min_cut_value=0;
1.53 - for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
1.54 + EdgeIt e;
1.55 + for(G.first(e); G.valid(e); G.next(e)) {
1.56 if (cut.get(G.tail(e)) && !cut.get(G.head(e))) min_cut_value+=cap.get(e);
1.57 }
1.58
1.59 ListGraph::NodeMap<bool> cut1(G);
1.60 max_flow_test.minMinCut(cut1);
1.61 int min_min_cut_value=0;
1.62 - for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
1.63 + for(G.first(e); G.valid(e); G.next(e)) {
1.64 if (cut.get(G.tail(e)) && !cut.get(G.head(e)))
1.65 min_min_cut_value+=cap.get(e);
1.66 }
1.67 @@ -52,17 +55,13 @@
1.68 ListGraph::NodeMap<bool> cut2(G);
1.69 max_flow_test.maxMinCut(cut2);
1.70 int max_min_cut_value=0;
1.71 - for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
1.72 + for(G.first(e); G.valid(e); G.next(e)) {
1.73 if (cut2.get(G.tail(e)) && !cut2.get(G.head(e)))
1.74 max_min_cut_value+=cap.get(e);
1.75 }
1.76
1.77 std::cout << "min time of 10 runs: " << mintime << " sec"<< std::endl;
1.78 - std::cout << "phase 0: " << max_flow_test.time-pre_time
1.79 - << " sec"<< std::endl;
1.80 - std::cout << "phase 1: " << post_time-max_flow_test.time
1.81 - << " sec"<< std::endl;
1.82 - std::cout << "flow value: "<< max_flow_test.maxFlow() << std::endl;
1.83 + std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
1.84 std::cout << "min cut value: "<< min_cut_value << std::endl;
1.85 std::cout << "min min cut value: "<< min_min_cut_value << std::endl;
1.86 std::cout << "max min cut value: "<< max_min_cut_value <<