mincostflow_test is ok.
authormarci
Thu, 02 Sep 2004 16:56:33 +0000
changeset 788c3187cafcabf
parent 787 584270fba752
child 789 65c5c7d37578
mincostflow_test is ok.
src/hugo/mincostflows.h
src/hugo/minlengthpaths.h
src/test/Makefile.am
     1.1 --- a/src/hugo/mincostflows.h	Thu Sep 02 15:30:50 2004 +0000
     1.2 +++ b/src/hugo/mincostflows.h	Thu Sep 02 16:56:33 2004 +0000
     1.3 @@ -11,7 +11,6 @@
     1.4  #include <hugo/graph_wrapper.h>
     1.5  #include <hugo/maps.h>
     1.6  #include <vector>
     1.7 -#include <hugo/for_each_macros.h>
     1.8  
     1.9  namespace hugo {
    1.10  
    1.11 @@ -116,16 +115,11 @@
    1.12        //Resetting variables from previous runs
    1.13        total_length = 0;
    1.14        
    1.15 -      for(typename Graph::EdgeIt e=loopFirst(typename Graph::EdgeIt(), (G)); e!=INVALID; ++e){
    1.16 -	flow.set(e,0);
    1.17 -      }
    1.18 +      for (typename Graph::EdgeIt e(G); e!=INVALID; ++e) flow.set(e, 0);
    1.19  
    1.20        //Initialize the potential to zero
    1.21 -      for(typename Graph::NodeIt n=loopFirst(typename Graph::NodeIt(), (G)); n!=INVALID; ++n){
    1.22 -	potential.set(n,0);
    1.23 -      }
    1.24 +      for (typename Graph::NodeIt n(G); n!=INVALID; ++n) potential.set(n, 0);
    1.25        
    1.26 -
    1.27        
    1.28        //We need a residual graph
    1.29        ResGraphType res_graph(G, capacity, flow);
    1.30 @@ -144,11 +138,8 @@
    1.31  	};
    1.32  	
    1.33  	//We have to change the potential
    1.34 -        //#define FOR_EACH_LOC(Ittype, e, g) for(Ittype e=loopFirst(Ittype(), (g)); (g).valid(e); (g).next(e))
    1.35 -	//FOR_EACH_LOC(typename ResGraphType::NodeIt, n, res_graph){
    1.36 -        for(typename ResGraphType::NodeIt n=loopFirst(typename ResGraphType::NodeIt(), (res_graph)); n!=INVALID; ++n){
    1.37 +        for(typename ResGraphType::NodeIt n(res_graph); n!=INVALID; ++n)
    1.38  	  potential[n] += dijkstra.distMap()[n];
    1.39 -	}
    1.40  
    1.41  
    1.42  	//Augmenting on the sortest path
    1.43 @@ -197,9 +188,7 @@
    1.44      bool checkComplementarySlackness(){
    1.45        Length mod_pot;
    1.46        Length fl_e;
    1.47 -        //#define FOR_EACH_LOC(Ittype, e, g) for(Ittype e=loopFirst(Ittype(), (g)); (g).valid(e); (g).next(e))
    1.48 -        //FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
    1.49 -        for(typename Graph::EdgeIt e=loopFirst(typename Graph::EdgeIt(), (G)); e!=INVALID; ++e){
    1.50 +        for(typename Graph::EdgeIt e(G); e!=INVALID; ++e) {
    1.51  	//C^{\Pi}_{i,j}
    1.52  	mod_pot = length[e]-potential[G.head(e)]+potential[G.tail(e)];
    1.53  	fl_e = flow[e];
     2.1 --- a/src/hugo/minlengthpaths.h	Thu Sep 02 15:30:50 2004 +0000
     2.2 +++ b/src/hugo/minlengthpaths.h	Thu Sep 02 16:56:33 2004 +0000
     2.3 @@ -12,7 +12,6 @@
     2.4  #include <hugo/maps.h>
     2.5  #include <vector>
     2.6  #include <hugo/mincostflows.h>
     2.7 -#include <for_each_macros.h>
     2.8  
     2.9  namespace hugo {
    2.10  
    2.11 @@ -83,10 +82,8 @@
    2.12        //The name here suggests that the flow has only 0/1 values.
    2.13        EdgeIntMap reversed(G); 
    2.14  
    2.15 -      //FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
    2.16 -      for(typename Graph::EdgeIt e=loopFirst(typename Graph::EdgeIt(), (G)); e!=INVALID; ++e){
    2.17 +      for(typename Graph::EdgeIt e(G); e!=INVALID; ++e) 
    2.18  	reversed[e] = mincost_flow.getFlow()[e];
    2.19 -      }
    2.20        
    2.21        paths.clear();
    2.22        //total_length=0;
     3.1 --- a/src/test/Makefile.am	Thu Sep 02 15:30:50 2004 +0000
     3.2 +++ b/src/test/Makefile.am	Thu Sep 02 16:56:33 2004 +0000
     3.3 @@ -4,7 +4,8 @@
     3.4  
     3.5  check_PROGRAMS = graph_test dijkstra_test bfs_test dfs_test time_measure_test \
     3.6  	error_test xy_test \
     3.7 -	unionfind_test test_tools_pass test_tools_fail
     3.8 +	unionfind_test test_tools_pass test_tools_fail \
     3.9 +	minlengthpaths_test mincostflows_test
    3.10  
    3.11  TESTS = $(check_PROGRAMS)
    3.12  XFAIL_TESTS = test_tools_fail
    3.13 @@ -19,4 +20,6 @@
    3.14  xy_test_SOURCES = xy_test.cc
    3.15  test_tools_pass_SOURCES = test_tools_pass.cc
    3.16  test_tools_fail_SOURCES = test_tools_fail.cc
    3.17 +minlengthpaths_test_SOURCES = minlengthpaths_test.cc
    3.18 +mincostflows_test_SOURCES = mincostflows_test.cc
    3.19