Index: src/work/marci/lp/min_cost_gen_flow.h
===================================================================
--- src/work/marci/lp/min_cost_gen_flow.h	(revision 1025)
+++ src/work/marci/lp/min_cost_gen_flow.h	(revision 1028)
@@ -11,8 +11,9 @@
 //#include <graph_wrapper.h>
 #include <lemon/preflow.h>
+#include <lemon/min_cost_flow.h>
 //#include <augmenting_flow.h>
 //#include <preflow_res.h>
-#include <../merge_node_graph_wrapper.h>
-#include <lemon/../work/marci/lp/lp_solver_wrapper.h>
+#include <work/marci/merge_node_graph_wrapper.h>
+#include <work/marci/lp/lp_solver_wrapper.h>
 
 namespace lemon {
@@ -31,5 +32,5 @@
   };
 
-  // excess: rho-delta
+  // excess: rho-delta egyelore csak =0-ra.
   template <typename Graph, typename Num,
 	    typename Excess=typename Graph::template NodeMap<Num>, 
@@ -75,7 +76,10 @@
       typename GWWW::template EdgeMap<Num> translated_cap(gwww);
 
-      for (typename GW::EdgeIt e(gw); e!=INVALID; ++e)
-      translated_cap.set(typename GWWW::Edge(e,INVALID,false), 
-			 capacity[e]-lcapacity[e]);
+      for (typename GW::EdgeIt e(gw); e!=INVALID; ++e) {
+	translated_cap.set(typename GWWW::Edge(e,INVALID,false), 
+			   capacity[e]-lcapacity[e]);
+	//	cout << "t_cap " << gw.id(e) << " " 
+	//	     << translated_cap[typename GWWW::Edge(e,INVALID,false)] << endl;
+      }
 
       Num expected=0;
@@ -93,4 +97,5 @@
 	  translated_cap.set(typename GWWW::Edge(INVALID, e, true), 
 			     excess[n]-a);
+	  //	  std::cout << g.id(n) << "->t " << excess[n]-a << std::endl;
 	}
 	if (excess[n]<a) {
@@ -100,4 +105,5 @@
 			     a-excess[n]);
 	  expected+=a-excess[n];
+	  //	  std::cout << "s->" << g.id(n) << " "<< a-excess[n] <<std:: endl;
 	}
       }
@@ -118,5 +124,92 @@
       return (expected>=preflow.flowValue());
     }
-    void run() {
+    // for nonnegative costs
+    bool run() {
+      //      std::cout << "making new vertices..." << std::endl; 
+      typedef ListGraph Graph2;
+      Graph2 g2;
+      typedef MergeEdgeGraphWrapper<const Graph, Graph2> GW;
+      //      std::cout << "merging..." << std::endl; 
+      GW gw(g, g2);
+      typename GW::Node s(INVALID, g2.addNode(), true);
+      typename GW::Node t(INVALID, g2.addNode(), true);
+      typedef SmartGraph Graph3;
+      //      std::cout << "making extender graph..." << std::endl; 
+      typedef NewEdgeSetGraphWrapper2<GW, Graph3> GWW;
+//       {
+// 	checkConcept<StaticGraph, GWW>();   
+//       }
+      GWW gww(gw);
+      typedef AugmentingGraphWrapper<GW, GWW> GWWW;
+      GWWW gwww(gw, gww);
+
+      //      std::cout << "making new edges..." << std::endl; 
+      typename GWWW::template EdgeMap<Num> translated_cap(gwww);
+
+      for (typename Graph::EdgeIt e(g); e!=INVALID; ++e) {
+	typename GW::Edge ew(e, INVALID, false);
+	typename GWWW::Edge ewww(ew, INVALID, false);
+	translated_cap.set(ewww, capacity[e]-lcapacity[e]);
+	//	cout << "t_cap " << g.id(e) << " " 
+	//	     << translated_cap[ewww] << endl;
+      }
+
+      Num expected=0;
+
+      //      std::cout << "making new edges 2..." << std::endl; 
+      for (typename Graph::NodeIt n(g); n!=INVALID; ++n) {
+	//	std::cout << "node: " << g.id(n) << std::endl;
+	Num a=0;
+	for (typename Graph::InEdgeIt e(g, n); e!=INVALID; ++e) {
+	  a+=lcapacity[e];
+	  //	  std::cout << "bee: " << g.id(e) << " " << lcapacity[e] << std::endl;
+	}
+	for (typename Graph::OutEdgeIt e(g, n); e!=INVALID; ++e) {
+	  a-=lcapacity[e];
+	  //	  std::cout << "kie: " << g.id(e) << " " << lcapacity[e] << std::endl;
+	}
+	//	std::cout << "excess " << g.id(n) << ": " << a << std::endl;
+	if (0>a) {
+	  typename GWW::Edge e=
+	    gww.addEdge(typename GW::Node(n,INVALID,false), t);
+	  translated_cap.set(typename GWWW::Edge(INVALID, e, true), 
+			     -a);
+	  //	  std::cout << g.id(n) << "->t " << -a << std::endl;
+	}
+	if (0<a) {
+	  typename GWW::Edge e=
+	    gww.addEdge(s, typename GW::Node(n,INVALID,false));
+	  translated_cap.set(typename GWWW::Edge(INVALID, e, true), 
+			     a);
+	  expected+=a;
+	  //	  std::cout << "s->" << g.id(n) << " "<< a <<std:: endl;
+	}
+      }
+
+      //      std::cout << "preflow..." << std::endl; 
+      typename GWWW::template EdgeMap<Num> translated_cost(gwww, 0);
+      for (typename Graph::EdgeIt e(g); e!=INVALID; ++e) {
+	translated_cost.set(typename GWWW::Edge(
+        typename GW::Edge(e, INVALID, false), INVALID, false), cost[e]);
+      }
+      //      typename GWWW::template EdgeMap<Num> translated_flow(gwww, 0);
+      MinCostFlow<GWWW, typename GWWW::template EdgeMap<Num>, 
+      typename GWWW::template EdgeMap<Num> > 
+      min_cost_flow(gwww, translated_cost, translated_cap, 
+		    s, t);
+      while (min_cost_flow.augment()) { }
+      std::cout << "fv: " << min_cost_flow.flowValue() << std::endl; 
+      std::cout << "expected: " << expected << std::endl; 
+
+      for (typename Graph::EdgeIt e(g); e!=INVALID; ++e) {
+	typename GW::Edge ew(e, INVALID, false);
+	typename GWWW::Edge ewww(ew, INVALID, false);
+	//	std::cout << g.id(e) << " " << flow[e] << std::endl;
+	flow.set(e, lcapacity[e]+
+		 min_cost_flow.getFlow()[ewww]);
+      }
+      return (expected>=min_cost_flow.flowValue());
+    }
+    void runByLP() {
       LPSolverWrapper lp;
       lp.setMinimize();
