trying if without stl stack we are faster
authorjacint
Tue, 20 Jul 2004 14:31:24 +0000
changeset 715665689d86225
parent 714 104069336039
child 716 e7f13f60fcfd
trying if without stl stack we are faster
src/work/jacint/makefile
src/work/jacint/max_flow_test.cc
     1.1 --- a/src/work/jacint/makefile	Tue Jul 20 14:29:16 2004 +0000
     1.2 +++ b/src/work/jacint/makefile	Tue Jul 20 14:31:24 2004 +0000
     1.3 @@ -1,3 +1,3 @@
     1.4 -BINARIES = max_matching
     1.5 -INCLUDEDIRS= -I../../include -I.. -I../{klao,marci,jacint,alpar,johanna,akos}
     1.6 +BINARIES = max_flow_test
     1.7 +INCLUDEDIRS= -I../../include -I../.. -I.. -I../{klao,marci,jacint,alpar,johanna,akos}
     1.8  include ../makefile 
     2.1 --- a/src/work/jacint/max_flow_test.cc	Tue Jul 20 14:29:16 2004 +0000
     2.2 +++ b/src/work/jacint/max_flow_test.cc	Tue Jul 20 14:31:24 2004 +0000
     2.3 @@ -1,9 +1,10 @@
     2.4  #include <iostream>
     2.5  
     2.6 -#include <list_graph.h>
     2.7 -#include <dimacs.h>
     2.8 +#include <hugo/list_graph.h>
     2.9 +#include <hugo/dimacs.h>
    2.10  #include <max_flow.h>
    2.11 -#include <time_measure.h>
    2.12 +#include <max_flow_no_stack.h>
    2.13 +#include <hugo/time_measure.h>
    2.14  
    2.15  using namespace hugo;
    2.16  
    2.17 @@ -25,15 +26,22 @@
    2.18      G.nodeNum() << " nodes and " << G.edgeNum() << " edges..."
    2.19  	   << std::endl<<std::endl;
    2.20  
    2.21 -  Graph::EdgeMap<int> flow(G,0);
    2.22 -  MaxFlow<Graph, int> max_flow_test(G, s, t, cap, flow);
    2.23 +  Graph::EdgeMap<int> flowstack(G,0);
    2.24 +  MaxFlow<Graph, int> max_flow_test(G, s, t, cap, flowstack);
    2.25    ts.reset();
    2.26    max_flow_test.run();
    2.27 -  std::cout << "Elapsed time of run(): " << std::endl 
    2.28 +  std::cout << "Elapsed time of run() with stl stack: " << std::endl 
    2.29 +	    <<ts << std::endl;
    2.30 +
    2.31 +  Graph::EdgeMap<int> flow(G,0);
    2.32 +  MaxFlowNoStack<Graph, int> max_flow_test_no_stack(G, s, t, cap, flow);
    2.33 +  ts.reset();
    2.34 +  max_flow_test_no_stack.run();
    2.35 +  std::cout << "Elapsed time of run() without stack: " << std::endl 
    2.36  	    <<ts << std::endl;
    2.37    
    2.38    Graph::NodeMap<bool> mincut(G);
    2.39 -  max_flow_test.minMinCut(mincut); 
    2.40 +  max_flow_test_no_stack.minMinCut(mincut); 
    2.41    int min_min_cut_value=0;
    2.42    EdgeIt e;
    2.43    for(G.first(e); G.valid(e); G.next(e)) {
    2.44 @@ -41,7 +49,7 @@
    2.45    }
    2.46  
    2.47    Graph::NodeMap<bool> cut(G);
    2.48 -  max_flow_test.minCut(cut); 
    2.49 +  max_flow_test_no_stack.minCut(cut); 
    2.50    int min_cut_value=0;
    2.51    for(G.first(e); G.valid(e); G.next(e)) {
    2.52      if (cut[G.tail(e)] && !cut[G.head(e)]) 
    2.53 @@ -49,26 +57,26 @@
    2.54    }
    2.55  
    2.56    Graph::NodeMap<bool> maxcut(G);
    2.57 -  max_flow_test.maxMinCut(maxcut); 
    2.58 +  max_flow_test_no_stack.maxMinCut(maxcut); 
    2.59    int max_min_cut_value=0;
    2.60    for(G.first(e); G.valid(e); G.next(e)) {
    2.61      if (maxcut[G.tail(e)] && !maxcut[G.head(e)]) 
    2.62        max_min_cut_value+=cap[e];
    2.63        }
    2.64  
    2.65 -  std::cout << "\n Checking the result: " <<std::endl;  
    2.66 -  std::cout << "Flow value: "<< max_flow_test.flowValue() << std::endl;
    2.67 +  std::cout << "\n Checking the result without stack: " <<std::endl;  
    2.68 +  std::cout << "Flow value: "<< max_flow_test_no_stack.flowValue() << std::endl;
    2.69    std::cout << "Min cut value: "<< min_cut_value << std::endl;
    2.70    std::cout << "Min min cut value: "<< min_min_cut_value << std::endl;
    2.71    std::cout << "Max min cut value: "<< max_min_cut_value << 
    2.72      std::endl;
    2.73  
    2.74 -  if ( max_flow_test.flowValue() == min_cut_value &&
    2.75 +  if ( max_flow_test_no_stack.flowValue() == min_cut_value &&
    2.76         min_cut_value == min_min_cut_value &&
    2.77         min_min_cut_value == max_min_cut_value )
    2.78      std::cout << "They are equal! " <<std::endl<< std::endl<<"\n";  
    2.79  
    2.80 -
    2.81 +  /*
    2.82  
    2.83    Graph::EdgeMap<int> flow2(G,0);
    2.84    std::cout << "Calling resetFlow() " << std::endl 
    2.85 @@ -152,6 +160,7 @@
    2.86         min_cut_value3 == min_min_cut_value3 &&
    2.87         min_min_cut_value3 == max_min_cut_value3 )
    2.88      std::cout << "They are equal! " <<std::endl<< std::endl<<"\n";  
    2.89 +  */
    2.90    
    2.91    return 0;
    2.92  }