# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1266681103 -3600
# Node ID 9d380bf271941ce00c6f0edb200f9a81a71959a5
# Parent  c841ae1aca299b7274d51c506871c57b73f1311a
Use 'long long' flow cost in dimacs-solver.cc (#347)

diff -r c841ae1aca29 -r 9d380bf27194 tools/dimacs-solver.cc
--- a/tools/dimacs-solver.cc	Wed Feb 17 23:10:36 2010 +0100
+++ b/tools/dimacs-solver.cc	Sat Feb 20 16:51:43 2010 +0100
@@ -91,7 +91,7 @@
   if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n';  
 }
 
-template<class Value>
+template<class Value, class LargeValue>
 void solve_min(ArgParser &ap, std::istream &is, std::ostream &,
                Value infty, DimacsDescriptor &desc)
 {
@@ -127,7 +127,8 @@
   if (report) {
     std::cerr << "Run NetworkSimplex: " << ti << "\n\n";
     std::cerr << "Feasible flow: " << (res ? "found" : "not found") << '\n';
-    if (res) std::cerr << "Min flow cost: " << ns.totalCost() << '\n';
+    if (res) std::cerr << "Min flow cost: "
+                       << ns.template totalCost<LargeValue>() << '\n';
   }
 }
 
@@ -151,7 +152,7 @@
 }
 
 
-template<class Value>
+template<class Value, class LargeValue>
 void solve(ArgParser &ap, std::istream &is, std::ostream &os,
            DimacsDescriptor &desc)
 {
@@ -169,7 +170,7 @@
   switch(desc.type)
     {
     case DimacsDescriptor::MIN:
-      solve_min<Value>(ap,is,os,infty,desc);
+      solve_min<Value, LargeValue>(ap,is,os,infty,desc);
       break;
     case DimacsDescriptor::MAX:
       solve_max<Value>(ap,is,os,infty,desc);
@@ -264,14 +265,16 @@
     }
     
   if(ap.given("double"))
-    solve<double>(ap,is,os,desc);
+    solve<double, double>(ap,is,os,desc);
   else if(ap.given("ldouble"))
-    solve<long double>(ap,is,os,desc);
+    solve<long double, long double>(ap,is,os,desc);
 #ifdef LEMON_HAVE_LONG_LONG
   else if(ap.given("long"))
-    solve<long long>(ap,is,os,desc);
+    solve<long long, long long>(ap,is,os,desc);
+  else solve<int, long long>(ap,is,os,desc);
+#else
+  else solve<int, long>(ap,is,os,desc);
 #endif
-  else solve<int>(ap,is,os,desc);
 
   return 0;
 }