Comparison == changed to <=
authorjacint
Thu, 29 Apr 2004 11:09:12 +0000
changeset 470b64956c701c9
parent 469 5f6ea657b75d
child 471 a40985a922d0
Comparison == changed to <=
src/work/jacint/preflow.cc
src/work/jacint/preflow.h
     1.1 --- a/src/work/jacint/preflow.cc	Thu Apr 29 10:51:58 2004 +0000
     1.2 +++ b/src/work/jacint/preflow.cc	Thu Apr 29 11:09:12 2004 +0000
     1.3 @@ -19,6 +19,7 @@
     1.4    Graph::EdgeMap<int> cap(G);
     1.5    readDimacsMaxFlow(std::cin, G, s, t, cap);
     1.6    Timer ts;
     1.7 +  bool error=false;
     1.8    
     1.9    std::cout <<
    1.10      "\n  Testing preflow.h on a graph with " << 
    1.11 @@ -61,8 +62,10 @@
    1.12         min_cut_value == min_min_cut_value &&
    1.13         min_min_cut_value == max_min_cut_value )
    1.14      std::cout << "They are equal. " <<std::endl;  
    1.15 -
    1.16 -
    1.17 +  else {
    1.18 +    std::cout << "ERROR! They are not equal! " <<std::endl;  
    1.19 +    error=true;
    1.20 +  }
    1.21  
    1.22  
    1.23  
    1.24 @@ -96,8 +99,12 @@
    1.25         min_min_cut2_value == max_min_cut2_value )
    1.26      std::cout <<", which is equal to all three min cut values." 
    1.27  	      <<std::endl;  
    1.28 -
    1.29 -
    1.30 +  else {
    1.31 +    std::cout << "ERROR! It is not equal to all three min cut values! " 
    1.32 +	      <<std::endl;  
    1.33 +    error=true;
    1.34 +  }
    1.35 +  
    1.36  
    1.37  
    1.38  
    1.39 @@ -148,7 +155,13 @@
    1.40        ", which is equal to the given flow value and to all three min cut values after phase 1." 
    1.41  	      <<std::endl;  
    1.42    }
    1.43 -
    1.44 +  else {
    1.45 +    std::cout << 
    1.46 +      "ERROR! It is not equal to the given flow value and to all three min cut values after phase 1! " 
    1.47 +	      <<std::endl;  
    1.48 +    error=true;
    1.49 +  }
    1.50 +  
    1.51  
    1.52  
    1.53  
    1.54 @@ -195,6 +208,11 @@
    1.55         min_min_cut4_value == max_min_cut4_value )
    1.56      std::cout <<", which is equal to all three min cut values." 
    1.57  	      <<std::endl;  
    1.58 +  else {
    1.59 +    std::cout << "ERROR! It is not equal to all three min cut values! " 
    1.60 +	      <<std::endl;  
    1.61 +    error=true;
    1.62 +  }
    1.63  
    1.64  
    1.65  
    1.66 @@ -233,7 +251,14 @@
    1.67         min_min_cut5_value == max_min_cut5_value )
    1.68      std::cout <<", which is equal to all three min cut values." 
    1.69  	      <<std::endl<<std::endl;  
    1.70 -
    1.71 +  else {
    1.72 +    std::cout << "ERROR! It is not equal to all three min cut values! " 
    1.73 +	      <<std::endl;  
    1.74 +    error=true;
    1.75 +  }
    1.76 +  
    1.77 +  if (error) std::cout <<"\nThere was some error in the results!\n"<<std::endl; 
    1.78 +  else std::cout <<"\nThere was no error in the results.\n"<<std::endl; 
    1.79  
    1.80    return 0;
    1.81  }
     2.1 --- a/src/work/jacint/preflow.h	Thu Apr 29 10:51:58 2004 +0000
     2.2 +++ b/src/work/jacint/preflow.h	Thu Apr 29 11:09:12 2004 +0000
     2.3 @@ -153,10 +153,8 @@
     2.4  	  
     2.5  	  break;
     2.6  	}
     2.7 -//       default:
     2.8 -// 	break;
     2.9 -// 	ZERO_FLOW ize kell
    2.10 -
    2.11 +      default:
    2.12 +	break;
    2.13        }
    2.14        
    2.15        preflowPreproc( fe, active, level_list, left, right );
    2.16 @@ -217,7 +215,7 @@
    2.17  	      
    2.18  	InEdgeIt e;
    2.19  	for(g->first(e,v); g->valid(e); g->next(e)) {
    2.20 -	  if ( (*capacity)[e] == (*flow)[e] ) continue;
    2.21 +	  if ( (*capacity)[e] <= (*flow)[e] ) continue;
    2.22  	  Node u=g->tail(e);
    2.23  	  if ( level[u] >= n ) { 
    2.24  	    bfs_queue.push(u);
    2.25 @@ -228,7 +226,7 @@
    2.26  	
    2.27  	OutEdgeIt f;
    2.28  	for(g->first(f,v); g->valid(f); g->next(f)) {
    2.29 -	  if ( 0 == (*flow)[f] ) continue;
    2.30 +	  if ( 0 >= (*flow)[f] ) continue;
    2.31  	  Node u=g->head(f);
    2.32  	  if ( level[u] >= n ) { 
    2.33  	    bfs_queue.push(u);
    2.34 @@ -388,12 +386,12 @@
    2.35        OutEdgeIt e;
    2.36        for(g->first(e,w); g->valid(e); g->next(e)) {
    2.37  	    
    2.38 -	if ( (*flow)[e] == (*capacity)[e] ) continue; 
    2.39 +	if ( (*flow)[e] >= (*capacity)[e] ) continue; 
    2.40  	Node v=g->head(e);            
    2.41  	    
    2.42  	if( lev > level[v] ) { //Push is allowed now
    2.43  	  
    2.44 -	  if ( excess[v]==0 && v!=t && v!=s ) {
    2.45 +	  if ( excess[v]<=0 && v!=t && v!=s ) {
    2.46  	    int lev_v=level[v];
    2.47  	    active[lev_v].push(v);
    2.48  	  }
    2.49 @@ -421,12 +419,12 @@
    2.50  	InEdgeIt e;
    2.51  	for(g->first(e,w); g->valid(e); g->next(e)) {
    2.52  	  
    2.53 -	  if( (*flow)[e] == 0 ) continue; 
    2.54 +	  if( (*flow)[e] <= 0 ) continue; 
    2.55  	  Node v=g->tail(e); 
    2.56  	  
    2.57  	  if( lev > level[v] ) { //Push is allowed now
    2.58  	    
    2.59 -	    if ( excess[v]==0 && v!=t && v!=s ) {
    2.60 +	    if ( excess[v]<=0 && v!=t && v!=s ) {
    2.61  	      int lev_v=level[v];
    2.62  	      active[lev_v].push(v);
    2.63  	    }
    2.64 @@ -493,10 +491,10 @@
    2.65  	  for(g->first(e,s); g->valid(e); g->next(e)) 
    2.66  	    {
    2.67  	      Num c=(*capacity)[e];
    2.68 -	      if ( c == 0 ) continue;
    2.69 +	      if ( c <= 0 ) continue;
    2.70  	      Node w=g->head(e);
    2.71  	      if ( level[w] < n ) {	  
    2.72 -		if ( excess[w] == 0 && w!=t ) active[level[w]].push(w);
    2.73 +		if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
    2.74  		flow->set(e, c); 
    2.75  		excess.set(w, excess[w]+c);
    2.76  	      }
    2.77 @@ -520,7 +518,7 @@
    2.78  	    
    2.79  	    InEdgeIt e;
    2.80  	    for(g->first(e,v); g->valid(e); g->next(e)) {
    2.81 -	      if ( (*capacity)[e] == (*flow)[e] ) continue;
    2.82 +	      if ( (*capacity)[e] <= (*flow)[e] ) continue;
    2.83  	      Node w=g->tail(e);
    2.84  	      if ( level[w] == n && w != s ) {
    2.85  		bfs_queue.push(w);
    2.86 @@ -534,7 +532,7 @@
    2.87  	    
    2.88  	    OutEdgeIt f;
    2.89  	    for(g->first(f,v); g->valid(f); g->next(f)) {
    2.90 -	      if ( 0 == (*flow)[f] ) continue;
    2.91 +	      if ( 0 >= (*flow)[f] ) continue;
    2.92  	      Node w=g->head(f);
    2.93  	      if ( level[w] == n && w != s ) {
    2.94  		bfs_queue.push(w);
    2.95 @@ -553,10 +551,10 @@
    2.96  	  for(g->first(e,s); g->valid(e); g->next(e)) 
    2.97  	    {
    2.98  	      Num rem=(*capacity)[e]-(*flow)[e];
    2.99 -	      if ( rem == 0 ) continue;
   2.100 +	      if ( rem <= 0 ) continue;
   2.101  	      Node w=g->head(e);
   2.102  	      if ( level[w] < n ) {	  
   2.103 -		if ( excess[w] == 0 && w!=t ) active[level[w]].push(w);
   2.104 +		if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
   2.105  		flow->set(e, (*capacity)[e]); 
   2.106  		excess.set(w, excess[w]+rem);
   2.107  	      }
   2.108 @@ -565,10 +563,10 @@
   2.109  	  InEdgeIt f;
   2.110  	  for(g->first(f,s); g->valid(f); g->next(f)) 
   2.111  	    {
   2.112 -	      if ( (*flow)[f] == 0 ) continue;
   2.113 +	      if ( (*flow)[f] <= 0 ) continue;
   2.114  	      Node w=g->tail(f);
   2.115  	      if ( level[w] < n ) {	  
   2.116 -		if ( excess[w] == 0 && w!=t ) active[level[w]].push(w);
   2.117 +		if ( excess[w] <= 0 && w!=t ) active[level[w]].push(w);
   2.118  		excess.set(w, excess[w]+(*flow)[f]);
   2.119  		flow->set(f, 0); 
   2.120  	      }
   2.121 @@ -582,7 +580,7 @@
   2.122  
   2.123      void relabel(Node w, int newlevel, VecStack& active,  
   2.124  		 VecNode& level_list, NNMap& left, 
   2.125 -		 NNMap& right, int& b, int& k, const bool what_heur ) {
   2.126 +		 NNMap& right, int& b, int& k, bool what_heur ) {
   2.127  
   2.128        Num lev=level[w];	
   2.129