1.1 --- a/src/work/jacint/preflow.cc Sat Mar 20 19:39:42 2004 +0000
1.2 +++ b/src/work/jacint/preflow.cc Sat Mar 20 20:06:23 2004 +0000
1.3 @@ -1,6 +1,7 @@
1.4 #include <iostream>
1.5 #include <fstream>
1.6
1.7 +#include <smart_graph.h>
1.8 #include <list_graph.h>
1.9 #include <dimacs.h>
1.10 #include <preflow.h>
1.11 @@ -11,12 +12,12 @@
1.12 // Use a DIMACS max flow file as stdin.
1.13 // read_dimacs_demo < dimacs_max_flow_file
1.14 int main(int, char **) {
1.15 - typedef ListGraph::Node Node;
1.16 - typedef ListGraph::EdgeIt EdgeIt;
1.17 + typedef SmartGraph::Node Node;
1.18 + typedef SmartGraph::EdgeIt EdgeIt;
1.19
1.20 - ListGraph G;
1.21 + SmartGraph G;
1.22 Node s, t;
1.23 - ListGraph::EdgeMap<int> cap(G);
1.24 + SmartGraph::EdgeMap<int> cap(G);
1.25 readDimacsMaxFlow(std::cin, G, s, t, cap);
1.26
1.27 std::cout << "preflow demo ..." << std::endl;
1.28 @@ -24,40 +25,40 @@
1.29 double mintime=1000000;
1.30
1.31 for ( int i=1; i!=11; ++i ) {
1.32 - ListGraph::EdgeMap<int> flow(G);
1.33 + SmartGraph::EdgeMap<int> flow(G);
1.34 double pre_time=currTime();
1.35 - Preflow<ListGraph, int> max_flow_test(G, s, t, cap, flow);
1.36 + Preflow<SmartGraph, 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 - ListGraph::EdgeMap<int> flow(G);
1.43 - Preflow<ListGraph, int> max_flow_test(G, s, t, cap, flow);
1.44 + SmartGraph::EdgeMap<int> flow(G);
1.45 + Preflow<SmartGraph, int> max_flow_test(G, s, t, cap, flow);
1.46 max_flow_test.run();
1.47
1.48 - ListGraph::NodeMap<bool> cut(G);
1.49 + SmartGraph::NodeMap<bool> cut(G);
1.50 max_flow_test.minCut(cut);
1.51 int min_cut_value=0;
1.52 EdgeIt e;
1.53 for(G.first(e); G.valid(e); G.next(e)) {
1.54 - if (cut.get(G.tail(e)) && !cut.get(G.head(e))) min_cut_value+=cap.get(e);
1.55 + if (cut[G.tail(e)] && !cut[G.head(e)]) min_cut_value+=cap[e];
1.56 }
1.57
1.58 - ListGraph::NodeMap<bool> cut1(G);
1.59 + SmartGraph::NodeMap<bool> cut1(G);
1.60 max_flow_test.minMinCut(cut1);
1.61 int min_min_cut_value=0;
1.62 for(G.first(e); G.valid(e); G.next(e)) {
1.63 - if (cut.get(G.tail(e)) && !cut.get(G.head(e)))
1.64 - min_min_cut_value+=cap.get(e);
1.65 + if (cut[G.tail(e)] && !cut[G.head(e)])
1.66 + min_min_cut_value+=cap[e];
1.67 }
1.68
1.69 - ListGraph::NodeMap<bool> cut2(G);
1.70 + SmartGraph::NodeMap<bool> cut2(G);
1.71 max_flow_test.maxMinCut(cut2);
1.72 int max_min_cut_value=0;
1.73 for(G.first(e); G.valid(e); G.next(e)) {
1.74 - if (cut2.get(G.tail(e)) && !cut2.get(G.head(e)))
1.75 - max_min_cut_value+=cap.get(e);
1.76 + if (cut2[G.tail(e)] && !cut2[G.head(e)])
1.77 + max_min_cut_value+=cap[e];
1.78 }
1.79
1.80 std::cout << "min time of 10 runs: " << mintime << " sec"<< std::endl;