[Lemon-commits] [lemon_svn] marci: r1005 - hugo/trunk/src/hugo

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:42:41 CET 2006


Author: marci
Date: Thu Jul 29 19:18:49 2004
New Revision: 1005

Modified:
   hugo/trunk/src/hugo/max_flow.h

Log:
jacint javitgatott.


Modified: hugo/trunk/src/hugo/max_flow.h
==============================================================================
--- hugo/trunk/src/hugo/max_flow.h	(original)
+++ hugo/trunk/src/hugo/max_flow.h	Thu Jul 29 19:18:49 2004
@@ -140,7 +140,7 @@
     ///\todo Document, please.
     ///
     MaxFlow(const Graph& _G, Node _s, Node _t,
-		   const CapMap& _capacity, FlowMap& _flow) :
+	    const CapMap& _capacity, FlowMap& _flow) :
       g(&_G), s(_s), t(_t), capacity(&_capacity),
       flow(&_flow), n(_G.nodeNum()), level(_G), excess(_G,0), 
       status(AFTER_NOTHING) { }
@@ -217,7 +217,6 @@
 
       VecFirst first(n, INVALID);
       NNMap next(*g, INVALID); //maybe INVALID is not needed
-      //    VecStack active(n);
 
       NNMap left(*g, INVALID);
       NNMap right(*g, INVALID);
@@ -254,7 +253,6 @@
 		next.set(v,first[lev]);
 		first[lev]=v;
 	      }
-	    //	  active[lev].push(v);
 	  }
 	  break;
 	}
@@ -280,7 +278,7 @@
 	}
       }
 
-      preflowPreproc(fe, next, first,/*active*/ level_list, left, right);
+      preflowPreproc(fe, next, first, level_list, left, right);
       //End of preprocessing
 
 
@@ -293,15 +291,13 @@
 	  } else break;
 	}
 
-	if ( !g->valid(first[b])/*active[b].empty()*/ ) --b;
+	if ( !g->valid(first[b]) ) --b;
 	else {
 	  end=false;
 	  Node w=first[b];
 	  first[b]=next[w];
-	  /*	Node w=active[b].top();
-		active[b].pop();*/
-	  int newlevel=push(w,/*active*/next, first);
-	  if ( excess[w] > 0 ) relabel(w, newlevel, /*active*/next, first, level_list,
+	  int newlevel=push(w, next, first);
+	  if ( excess[w] > 0 ) relabel(w, newlevel, next, first, level_list,
 				       left, right, b, k, what_heur);
 
 	  ++numrelabel;
@@ -340,7 +336,6 @@
     
       VecFirst first(n, INVALID);
       NNMap next(*g, INVALID); //maybe INVALID is not needed
-      //    VecStack active(n);
       level.set(s,0);
       std::queue<Node> bfs_queue;
       bfs_queue.push(s);
@@ -361,7 +356,6 @@
 	    if ( excess[u] > 0 ) {
 	      next.set(u,first[l]);
 	      first[l]=u;
-	      //active[l].push(u);
 	    }
 	  }
 	}
@@ -376,7 +370,6 @@
 	    if ( excess[u] > 0 ) {
 	      next.set(u,first[l]);
 	      first[l]=u;
-	      //active[l].push(u);
 	    }
 	  }
 	}
@@ -387,13 +380,11 @@
 
 	if ( b == 0 ) break;
 
-	if ( !g->valid(first[b])/*active[b].empty()*/ ) --b;
+	if ( !g->valid(first[b]) ) --b;
 	else {
 
 	  Node w=first[b];
 	  first[b]=next[w];
-	  /*	Node w=active[b].top();
-		active[b].pop();*/
 	  int newlevel=push(w,next, first/*active*/);
 
 	  //relabel
@@ -401,7 +392,6 @@
 	    level.set(w,++newlevel);
 	    next.set(w,first[newlevel]);
 	    first[newlevel]=w;
-	    //active[newlevel].push(w);
 	    b=newlevel;
 	  }
 	}  // if stack[b] is nonempty
@@ -420,9 +410,18 @@
       Num a=0;
       for(InEdgeIt e(*g,t);g->valid(e);g->next(e)) a+=(*flow)[e];
       for(OutEdgeIt e(*g,t);g->valid(e);g->next(e)) a-=(*flow)[e];
-
+      return a;
       //marci figyu: excess[t] epp ezt adja preflow 1. fazisa utan   
     }
+    Num flowValue2() const {
+      return excess[t];
+//       Num a=0;
+//       for(InEdgeIt e(*g,t);g->valid(e);g->next(e)) a+=(*flow)[e];
+//       for(OutEdgeIt e(*g,t);g->valid(e);g->next(e)) a-=(*flow)[e];
+//       return a;
+//       //marci figyu: excess[t] epp ezt adja preflow 1. fazisa utan  
+      
+    }
 
     ///Returns a minimum value cut after calling \ref preflowPhase1.
 
@@ -451,6 +450,8 @@
 	break;
       case AFTER_PRE_FLOW_PHASE_2:
       case AFTER_NOTHING:
+      case AFTER_AUGMENTING:
+      case AFTER_FAST_AUGMENTING:
 	minMinCut(M);
 	break;
       }
@@ -591,8 +592,6 @@
 	  if ( excess[v]<=0 && v!=t && v!=s ) {
 	    next.set(v,first[level[v]]);
 	    first[level[v]]=v;
-	    //	    int lev_v=level[v];
-	    //active[lev_v].push(v);
 	  }
 
 	  Num cap=(*capacity)[e];
@@ -626,8 +625,6 @@
 	    if ( excess[v]<=0 && v!=t && v!=s ) {
 	      next.set(v,first[level[v]]);
 	      first[level[v]]=v;
-	      //int lev_v=level[v];
-	      //active[lev_v].push(v);
 	    }
 
 	    Num flo=(*flow)[e];
@@ -700,7 +697,6 @@
 		  {
 		    next.set(w,first[level[w]]);
 		    first[level[w]]=w;
-		    //active[level[w]].push(w);
 		  }
 		flow->set(e, c);
 		excess.set(w, excess[w]+c);
@@ -765,7 +761,6 @@
 		  {
 		    next.set(w,first[level[w]]);
 		    first[level[w]]=w;
-		    //active[level[w]].push(w);
 		  }   
 		flow->set(e, (*capacity)[e]);
 		excess.set(w, excess[w]+rem);
@@ -782,7 +777,6 @@
 		  {
 		    next.set(w,first[level[w]]);
 		    first[level[w]]=w;
-		    //active[level[w]].push(w);
 		  }   
 		excess.set(w, excess[w]+(*flow)[f]);
 		flow->set(f, 0);
@@ -834,11 +828,6 @@
 	  }
 	  level_list[i]=INVALID;
 	  if ( !what_heur ) first[i]=INVALID;
-	  /*{
-	    while ( !active[i].empty() ) {
-	    active[i].pop();    //FIXME: ezt szebben kene
-	    }
-	    }*/
 	}
 
 	level.set(w,n);
@@ -853,7 +842,6 @@
 	  level.set(w,++newlevel);
 	  next.set(w,first[newlevel]);
 	  first[newlevel]=w;
-	  //	  active[newlevel].push(w);
 	  if ( what_heur ) b=newlevel;
 	  if ( k < newlevel ) ++k;      //now k=newlevel
 	  Node z=level_list[newlevel];



More information about the Lemon-commits mailing list