Index: src/work/athos/mincostflows.h
===================================================================
--- src/work/athos/mincostflows.h	(revision 527)
+++ src/work/athos/mincostflows.h	(revision 530)
@@ -12,5 +12,5 @@
 #include <maps.h>
 #include <vector.h>
-
+#include <for_each_macros.h>
 
 namespace hugo {
@@ -35,10 +35,11 @@
   ///
   ///\author Attila Bernath
-  template <typename Graph, typename LengthMap>
+  template <typename Graph, typename LengthMap, typename CapacityMap>
   class MinCostFlows {
 
     typedef typename LengthMap::ValueType Length;
 
-    typedef typename LengthMap::ValueType Length;
+    //Warning: this should be integer type
+    typedef typename CapacityMap::ValueType Capacity;
     
     typedef typename Graph::Node Node;
@@ -50,6 +51,6 @@
     //    typedef ConstMap<Edge,int> ConstMap;
 
-    typedef ResGraphWrapper<const Graph,int,EdgeIntMap,EdgeIntMap> ResGraphType;
-
+    typedef ResGraphWrapper<const Graph,int,CapacityMap,EdgeIntMap> ResGraphType;
+    typedef typename ResGraphType::Edge ResGraphEdge;
     class ModLengthMap {   
       typedef typename ResGraphType::template NodeMap<Length> NodeMap;
@@ -69,5 +70,5 @@
       }     
 	
-      ModLengthMap(const ResGraphType& _G, const EdgeIntMap& _rev, 
+      ModLengthMap(const ResGraphType& _G,
 		   const LengthMap &o,  const NodeMap &p) : 
 	G(_G), /*rev(_rev),*/ ol(o), pot(p){}; 
@@ -79,5 +80,5 @@
     const Graph& G;
     const LengthMap& length;
-    const EdgeIntMap& capacity;
+    const CapacityMap& capacity;
 
     //auxiliary variables
@@ -99,5 +100,5 @@
 
 
-    MinLengthPaths(Graph& _G, LengthMap& _length, EdgeIntMap& _cap) : G(_G), 
+    MinCostFlows(Graph& _G, LengthMap& _length, CapacityMap& _cap) : G(_G), 
       length(_length), capacity(_cap), flow(_G)/*, dijkstra_dist(_G)*/{ }
 
@@ -110,5 +111,11 @@
     int run(Node s, Node t, int k) {
 
-
+      //Resetting variables from previous runs
+      total_length = 0;
+      FOR_EACH_LOC(typename Graph::EdgeIt, e, G){
+	flow.set(e,0);
+      }
+
+      
       //We need a residual graph
       ResGraphType res_graph(G, capacity, flow);
@@ -139,9 +146,14 @@
 	//Augmenting on the sortest path
 	Node n=t;
-	Edge e;
+	ResGraphEdge e;
 	while (n!=s){
 	  e = dijkstra.pred(n);
 	  n = dijkstra.predNode(n);
-	  G.augment(e,1);
+	  res_graph.augment(e,1);
+	  //Let's update the total length
+	  if (res_graph.forward(e))
+	    total_length += length[e];
+	  else 
+	    total_length -= length[e];	    
 	}
 
@@ -149,40 +161,9 @@
       }
       
-      /*
-	///\TODO To be implemented later
-
-      //Let's find the paths
-      //We put the paths into stl vectors (as an inner representation). 
-      //In the meantime we lose the information stored in 'reversed'.
-      //We suppose the lengths to be positive now.
-
-      //Meanwhile we put the total length of the found paths 
-      //in the member variable total_length
-      paths.clear();
-      total_length=0;
-      paths.resize(k);
-      for (int j=0; j<i; ++j){
-	Node n=s;
-	OutEdgeIt e;
-
-	while (n!=t){
-
-
-	  G.first(e,n);
-	  
-	  while (!reversed[e]){
-	    G.next(e);
-	  }
-	  n = G.head(e);
-	  paths[j].push_back(e);
-	  total_length += length[e];
-	  reversed[e] = 1-reversed[e];
-	}
-	
-      }
-      */
 
       return i;
     }
+
+
 
     ///This function gives back the total length of the found paths.
@@ -191,4 +172,7 @@
       return total_length;
     }
+
+    /*
+      ///\todo To be implemented later
 
     ///This function gives back the \c j-th path in argument p.
@@ -207,5 +191,7 @@
     }
 
-  }; //class MinLengthPaths
+    */
+
+  }; //class MinCostFlows
 
   ///@}
Index: src/work/athos/mincostflows_test.cc
===================================================================
--- src/work/athos/mincostflows_test.cc	(revision 527)
+++ src/work/athos/mincostflows_test.cc	(revision 530)
@@ -62,14 +62,19 @@
   length.set(v5_t, 8);
 
-  ConstMap const1map(1);
-  std::cout << "Minlengthpaths algorithm test..." << std::endl;
+  ConstMap<Edge, int> const1map(1);
+  std::cout << "Mincostflows algorithm test..." << std::endl;
 
   
   int k=3;
-  MinCostFlows< ListGraph, ListGraph::EdgeMap<int> >
+  MinCostFlows< ListGraph, ListGraph::EdgeMap<int>, ConstMap<Edge, int> >
     surb_test(graph, length, const1map);
 
   check(  surb_test.run(s,t,k) == 2 && surb_test.totalLength() == 46,"Two paths, total length should be 46");
 
+  k=1;
+  check(  surb_test.run(s,t,k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
+  
+  //cout << surb_test.run(s,t,k) << surb_test.totalLength()<<endl;
+  /*
   typedef DirPath<ListGraph> DPath;
   DPath P(graph);
@@ -86,5 +91,5 @@
   surb_test.getPath(P,0);
   check(P.length() == 4, "First path should contain 4 edges.");  
-
+  */
   cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
        << endl;
