src/work/marci/edmonds_karp.h
changeset 324 c8b0ad782bda
parent 312 54e07057eb47
child 330 7ac0d4e8a31c
equal deleted inserted replaced
3:c5de2cc6556a 4:42591efa5c09
   597  	typename ErasingResGW::NodeMap<typename ErasingResGW::OutEdgeIt> 
   597  	typename ErasingResGW::NodeMap<typename ErasingResGW::OutEdgeIt> 
   598  	  pred(erasing_res_graph); 
   598  	  pred(erasing_res_graph); 
   599  	pred.set(s, INVALID);
   599  	pred.set(s, INVALID);
   600   	//invalid iterators for sources
   600   	//invalid iterators for sources
   601 
   601 
   602   	typename ErasingResGW::NodeMap<Number> free(erasing_res_graph);
   602   	typename ErasingResGW::NodeMap<Number> free1(erasing_res_graph);
   603 
   603 
   604  	dfs.pushAndSetReached(s);
   604  	dfs.pushAndSetReached(
       
   605 	  typename ErasingResGW::Node(
       
   606 	    typename FilterResGW::Node(
       
   607 	      typename ResGW::Node(s)
       
   608 	      )
       
   609 	    )
       
   610 	  );
   605  	while (!dfs.finished()) {
   611  	while (!dfs.finished()) {
   606  	  ++dfs;
   612  	  ++dfs;
   607  	  if (erasing_res_graph.valid(
   613  	  if (erasing_res_graph.valid(
   608  		/*typename ErasingResGW::OutEdgeIt*/(dfs))) 
   614  		typename ErasingResGW::OutEdgeIt(dfs))) 
   609  	  { 
   615  	  { 
   610   	    if (dfs.isBNodeNewlyReached()) {
   616   	    if (dfs.isBNodeNewlyReached()) {
   611 	  
   617 	  
   612  	      typename ErasingResGW::Node v=erasing_res_graph.aNode(dfs);
   618  	      typename ErasingResGW::Node v=erasing_res_graph.aNode(dfs);
   613  	      typename ErasingResGW::Node w=erasing_res_graph.bNode(dfs);
   619  	      typename ErasingResGW::Node w=erasing_res_graph.bNode(dfs);
   614 
   620 
   615  	      pred.set(w, /*typename ErasingResGW::OutEdgeIt*/(dfs));
   621  	      pred.set(w, /*typename ErasingResGW::OutEdgeIt*/(dfs));
   616  	      if (erasing_res_graph.valid(pred[v])) {
   622  	      if (erasing_res_graph.valid(pred[v])) {
   617  		free.set(w, std::min(free[v], res_graph.resCap(dfs)));
   623  		free1.set(w, std::min(free1[v], res_graph.resCap(
       
   624 				       typename ErasingResGW::OutEdgeIt(dfs))));
   618  	      } else {
   625  	      } else {
   619  		free.set(w, res_graph.resCap(dfs)); 
   626  		free1.set(w, res_graph.resCap(
       
   627 			   typename ErasingResGW::OutEdgeIt(dfs))); 
   620  	      }
   628  	      }
   621 	      
   629 	      
   622  	      if (w==t) { 
   630  	      if (w==t) { 
   623  		__augment=true; 
   631  		__augment=true; 
   624  		_augment=true;
   632  		_augment=true;
   629 	    }
   637 	    }
   630 	  }
   638 	  }
   631 	}	
   639 	}	
   632 
   640 
   633   	if (__augment) {
   641   	if (__augment) {
   634   	  typename ErasingResGW::Node n=t;
   642    	  typename ErasingResGW::Node n=typename FilterResGW::Node(typename ResGW::Node(t));
   635  	  Number augment_value=free[n];
   643 // 	  typename ResGW::NodeMap<Number> a(res_graph);
       
   644 // 	  typename ResGW::Node b;
       
   645 // 	  Number j=a[b];
       
   646 // 	  typename FilterResGW::NodeMap<Number> a1(filter_res_graph);
       
   647 // 	  typename FilterResGW::Node b1;
       
   648 // 	  Number j1=a1[b1];
       
   649 // 	  typename ErasingResGW::NodeMap<Number> a2(erasing_res_graph);
       
   650 // 	  typename ErasingResGW::Node b2;
       
   651 // 	  Number j2=a2[b2];
       
   652  	  Number augment_value=free1[n];
   636  	  while (erasing_res_graph.valid(pred[n])) { 
   653  	  while (erasing_res_graph.valid(pred[n])) { 
   637  	    typename ErasingResGW::OutEdgeIt e=pred[n];
   654  	    typename ErasingResGW::OutEdgeIt e=pred[n];
   638  	    res_graph.augment(e, augment_value);
   655  	    res_graph.augment(e, augment_value);
   639  	    n=erasing_res_graph.tail(e);
   656  	    n=erasing_res_graph.tail(e);
   640  	    if (res_graph.resCap(e)==0)
   657  	    if (res_graph.resCap(e)==0)