1.1 --- a/src/work/jacint/preflow.cc Thu Apr 22 13:59:37 2004 +0000
1.2 +++ b/src/work/jacint/preflow.cc Thu Apr 22 14:11:28 2004 +0000
1.3 @@ -1,43 +1,35 @@
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 +#include <preflowproba.h>
1.12 #include <time_measure.h>
1.13
1.14 using namespace hugo;
1.15
1.16 -// Use a DIMACS max flow file as stdin.
1.17 -// read_dimacs_demo < dimacs_max_flow_file
1.18 int main(int, char **) {
1.19 - typedef SmartGraph::Node Node;
1.20 - typedef SmartGraph::EdgeIt EdgeIt;
1.21 +
1.22 + typedef SmartGraph Graph;
1.23 +
1.24 + typedef Graph::Node Node;
1.25 + typedef Graph::EdgeIt EdgeIt;
1.26
1.27 - SmartGraph G;
1.28 + Graph G;
1.29 Node s, t;
1.30 - SmartGraph::EdgeMap<int> cap(G);
1.31 + Graph::EdgeMap<int> cap(G);
1.32 readDimacsMaxFlow(std::cin, G, s, t, cap);
1.33 -
1.34 + Timer ts;
1.35 +
1.36 std::cout << "preflow demo ..." << std::endl;
1.37
1.38 - double mintime=1000000;
1.39 -
1.40 - for ( int i=1; i!=11; ++i ) {
1.41 - SmartGraph::EdgeMap<int> flow(G);
1.42 - double pre_time=currTime();
1.43 - Preflow<SmartGraph, int> max_flow_test(G, s, t, cap, flow);
1.44 - max_flow_test.run();
1.45 - double post_time=currTime();
1.46 - if ( mintime > post_time-pre_time ) mintime = post_time-pre_time;
1.47 - }
1.48 -
1.49 - SmartGraph::EdgeMap<int> flow(G);
1.50 - Preflow<SmartGraph, int> max_flow_test(G, s, t, cap, flow);
1.51 + Graph::EdgeMap<int> flow(G);
1.52 + Preflow<Graph, int> max_flow_test(G, s, t, cap, flow, 1);
1.53 + ts.reset();
1.54 max_flow_test.run();
1.55 + std::cout << "elapsed time: " << ts << std::endl;
1.56
1.57 - SmartGraph::NodeMap<bool> cut(G);
1.58 + Graph::NodeMap<bool> cut(G);
1.59 max_flow_test.minCut(cut);
1.60 int min_cut_value=0;
1.61 EdgeIt e;
1.62 @@ -45,7 +37,7 @@
1.63 if (cut[G.tail(e)] && !cut[G.head(e)]) min_cut_value+=cap[e];
1.64 }
1.65
1.66 - SmartGraph::NodeMap<bool> cut1(G);
1.67 + Graph::NodeMap<bool> cut1(G);
1.68 max_flow_test.minMinCut(cut1);
1.69 int min_min_cut_value=0;
1.70 for(G.first(e); G.valid(e); G.next(e)) {
1.71 @@ -53,7 +45,7 @@
1.72 min_min_cut_value+=cap[e];
1.73 }
1.74
1.75 - SmartGraph::NodeMap<bool> cut2(G);
1.76 + Graph::NodeMap<bool> cut2(G);
1.77 max_flow_test.maxMinCut(cut2);
1.78 int max_min_cut_value=0;
1.79 for(G.first(e); G.valid(e); G.next(e)) {
1.80 @@ -61,7 +53,6 @@
1.81 max_min_cut_value+=cap[e];
1.82 }
1.83
1.84 - std::cout << "min time of 10 runs: " << mintime << " sec"<< std::endl;
1.85 std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
1.86 std::cout << "min cut value: "<< min_cut_value << std::endl;
1.87 std::cout << "min min cut value: "<< min_min_cut_value << std::endl;