Index: src/work/edmonds_karp.h
===================================================================
--- src/work/edmonds_karp.h	(revision 196)
+++ src/work/edmonds_karp.h	(revision 197)
@@ -565,8 +565,8 @@
       for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
 	if (S->get(s)) {
-	  Number f=0;
+	  Number u=0;
 	  for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
-	    f+=flow->get(e);
-	  if (f<1) {
+	    u+=flow->get(e);
+	  if (u<1) {
 	    res_bfs.pushAndSetReached(s);
 	    pred.set(s, AugEdge(INVALID));
@@ -590,8 +590,13 @@
 	    free.set(w, res_graph.free(e)); 
 	  }
-	  if (T->get(res_graph.head(e))) { 
-	    n=res_graph.head(e);
-	    _augment=true; 
-	    break; 
+	  n=res_graph.head(e);
+	  if (T->get(n)) { 
+	    Number u=0;
+	    for(InEdgeIt f=G->template first<InEdgeIt>(n); G->valid(f); G->next(f))
+	      u+=flow->get(f);
+	    if (u<1) {
+	      _augment=true; 
+	      break; 
+	    }
 	  }
 	}
@@ -621,5 +626,25 @@
 //       BfsIterator4< AugGraph, AugOutEdgeIt, ReachedMap > bfs(res_graph);
 
-//       bfs.pushAndSetReached(s);
+
+
+
+
+//       //typename AugGraph::NodeMap<AugEdge> pred(res_graph); 
+//       for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
+// 	if (S->get(s)) {
+// 	  Number u=0;
+// 	  for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
+// 	    u+=flow->get(e);
+// 	  if (u<1) {
+// 	    res_bfs.pushAndSetReached(s);
+// 	    //pred.set(s, AugEdge(INVALID));
+// 	  }
+// 	}
+//       }
+
+
+
+
+//       //bfs.pushAndSetReached(s);
 //       typename AugGraph::NodeMap<int> dist(res_graph); //filled up with 0's
 //       while ( !bfs.finished() ) { 
@@ -713,92 +738,130 @@
 //       return _augment;
 //     }
-//     bool augmentOnBlockingFlow2() {
-//       bool _augment=false;
-
-//       //typedef ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> EAugGraph;
-//       typedef FilterGraphWrapper< ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > EAugGraph;
-//       typedef typename EAugGraph::OutEdgeIt EAugOutEdgeIt;
-//       typedef typename EAugGraph::Edge EAugEdge;
-
-//       EAugGraph res_graph(*G, *flow, *capacity);
-
-//       //typedef typename EAugGraph::NodeMap<bool> ReachedMap;
-//       BfsIterator4< 
-// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>, 
-// 	typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt, 
-// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<bool> > bfs(res_graph);
-      
-//       bfs.pushAndSetReached(s);
-
-//       typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::
-// 	NodeMap<int>& dist=res_graph.dist;
-
-//       while ( !bfs.finished() ) {
-// 	typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
-// 	if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
-// 	  dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
-// 	}
-// 	++bfs;	
-//       } //computing distances from s in the residual graph
-
-//       bool __augment=true;
-
-//       while (__augment) {
-
-// 	__augment=false;
-// 	//computing blocking flow with dfs
-// 	typedef typename EAugGraph::NodeMap<bool> BlockingReachedMap;
-// 	DfsIterator4< EAugGraph, EAugOutEdgeIt, BlockingReachedMap > 
-// 	  dfs(res_graph);
-// 	typename EAugGraph::NodeMap<EAugEdge> pred(res_graph); 
-// 	pred.set(s, EAugEdge(INVALID));
-// 	//invalid iterators for sources
-
-// 	typename EAugGraph::NodeMap<Number> free(res_graph);
-
-// 	dfs.pushAndSetReached(s);
-// 	while (!dfs.finished()) {
-// 	  ++dfs;
-// 	  if (res_graph.valid(EAugOutEdgeIt(dfs))) { 
-// 	    if (dfs.isBNodeNewlyReached()) {
+    bool augmentOnBlockingFlow2() {
+      bool _augment=false;
+
+      //typedef ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> EAugGraph;
+      typedef FilterGraphWrapper< ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > EAugGraph;
+      typedef typename EAugGraph::OutEdgeIt EAugOutEdgeIt;
+      typedef typename EAugGraph::Edge EAugEdge;
+
+      EAugGraph res_graph(*G, *flow, *capacity);
+
+      //typedef typename EAugGraph::NodeMap<bool> ReachedMap;
+      BfsIterator4< 
+	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>, 
+	typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt, 
+	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<bool> > bfs(res_graph);
+
+
+      //typename AugGraph::NodeMap<AugEdge> pred(res_graph); 
+      for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
+	if (S->get(s)) {
+	  Number u=0;
+	  for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
+	    u+=flow->get(e);
+	  if (u<1) {
+	    bfs.pushAndSetReached(s);
+	    //pred.set(s, AugEdge(INVALID));
+	  }
+	}
+      }
+
+      
+      //bfs.pushAndSetReached(s);
+
+      typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::
+	NodeMap<int>& dist=res_graph.dist;
+
+      while ( !bfs.finished() ) {
+	typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt e=bfs;
+	if (res_graph.valid(e) && bfs.isBNodeNewlyReached()) {
+	  dist.set(res_graph.head(e), dist.get(res_graph.tail(e))+1);
+	}
+	++bfs;	
+      } //computing distances from s in the residual graph
+
+      bool __augment=true;
+
+      while (__augment) {
+
+	__augment=false;
+	//computing blocking flow with dfs
+	typedef typename EAugGraph::NodeMap<bool> BlockingReachedMap;
+	DfsIterator4< EAugGraph, EAugOutEdgeIt, BlockingReachedMap > 
+	  dfs(res_graph);
+	typename EAugGraph::NodeMap<EAugEdge> pred(res_graph, INVALID); 
+	//pred.set(s, EAugEdge(INVALID));
+	//invalid iterators for sources
+
+	typename EAugGraph::NodeMap<Number> free(res_graph);
+
+
+	//typename AugGraph::NodeMap<AugEdge> pred(res_graph); 
+      for(NodeIt s=G->template first<NodeIt>(); G->valid(s); G->next(s)) {
+	if (S->get(s)) {
+	  Number u=0;
+	  for(OutEdgeIt e=G->template first<OutEdgeIt>(s); G->valid(e); G->next(e))
+	    u+=flow->get(e);
+	  if (u<1) {
+	    dfs.pushAndSetReached(s);
+	    //pred.set(s, AugEdge(INVALID));
+	  }
+	}
+      }
+
+
+
+      //dfs.pushAndSetReached(s);
+      typename EAugGraph::Node n;
+	while (!dfs.finished()) {
+	  ++dfs;
+	  if (res_graph.valid(EAugOutEdgeIt(dfs))) { 
+	    if (dfs.isBNodeNewlyReached()) {
 	  
-// 	      typename EAugGraph::Node v=res_graph.aNode(dfs);
-// 	      typename EAugGraph::Node w=res_graph.bNode(dfs);
-
-// 	      pred.set(w, EAugOutEdgeIt(dfs));
-// 	      if (res_graph.valid(pred.get(v))) {
-// 		free.set(w, std::min(free.get(v), res_graph.free(dfs)));
-// 	      } else {
-// 		free.set(w, res_graph.free(dfs)); 
-// 	      }
-	      
-// 	      if (w==t) { 
-// 		__augment=true; 
-// 		_augment=true;
-// 		break; 
-// 	      }
-// 	    } else {
-// 	      res_graph.erase(dfs);
-// 	    }
-// 	  } 
-
-// 	}
-
-// 	if (__augment) {
-// 	  typename EAugGraph::Node n=t;
-// 	  Number augment_value=free.get(t);
-// 	  while (res_graph.valid(pred.get(n))) { 
-// 	    EAugEdge e=pred.get(n);
-// 	    res_graph.augment(e, augment_value);
-// 	    n=res_graph.tail(e);
-// 	    if (res_graph.free(e)==0)
-// 	      res_graph.erase(e);
-// 	  }
-// 	}
-      
-//       }
+	      typename EAugGraph::Node v=res_graph.aNode(dfs);
+	      typename EAugGraph::Node w=res_graph.bNode(dfs);
+
+	      pred.set(w, EAugOutEdgeIt(dfs));
+	      if (res_graph.valid(pred.get(v))) {
+		free.set(w, std::min(free.get(v), res_graph.free(dfs)));
+	      } else {
+		free.set(w, res_graph.free(dfs)); 
+	      }
+	     
+	      n=w;
+	      if (T->get(w)) {
+		Number u=0;
+		for(InEdgeIt f=G->template first<InEdgeIt>(n); G->valid(f); G->next(f))
+		  u+=flow->get(f);
+		if (u<1) {
+		  __augment=true; 
+		  _augment=true;
+		  break; 
+		}
+	      }
+	    } else {
+	      res_graph.erase(dfs);
+	    }
+	  } 
+
+	}
+
+	if (__augment) {
+	  // typename EAugGraph::Node n=t;
+	  Number augment_value=free.get(n);
+	  while (res_graph.valid(pred.get(n))) { 
+	    EAugEdge e=pred.get(n);
+	    res_graph.augment(e, augment_value);
+	    n=res_graph.tail(e);
+	    if (res_graph.free(e)==0)
+	      res_graph.erase(e);
+	  }
+	}
+      
+      }
             
-//       return _augment;
-//     }
+      return _augment;
+    }
     void run() {
       //int num_of_augmentations=0;
