tools/dimacs-solver.cc
changeset 847 754272f20318
parent 644 8d289c89d43e
child 877 141f9c0db4a3
     1.1 --- a/tools/dimacs-solver.cc	Sun Feb 28 19:38:29 2010 +0100
     1.2 +++ b/tools/dimacs-solver.cc	Sun Feb 28 19:58:24 2010 +0100
     1.3 @@ -91,7 +91,7 @@
     1.4    if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n';  
     1.5  }
     1.6  
     1.7 -template<class Value>
     1.8 +template<class Value, class LargeValue>
     1.9  void solve_min(ArgParser &ap, std::istream &is, std::ostream &,
    1.10                 Value infty, DimacsDescriptor &desc)
    1.11  {
    1.12 @@ -127,7 +127,8 @@
    1.13    if (report) {
    1.14      std::cerr << "Run NetworkSimplex: " << ti << "\n\n";
    1.15      std::cerr << "Feasible flow: " << (res ? "found" : "not found") << '\n';
    1.16 -    if (res) std::cerr << "Min flow cost: " << ns.totalCost() << '\n';
    1.17 +    if (res) std::cerr << "Min flow cost: "
    1.18 +                       << ns.template totalCost<LargeValue>() << '\n';
    1.19    }
    1.20  }
    1.21  
    1.22 @@ -151,7 +152,7 @@
    1.23  }
    1.24  
    1.25  
    1.26 -template<class Value>
    1.27 +template<class Value, class LargeValue>
    1.28  void solve(ArgParser &ap, std::istream &is, std::ostream &os,
    1.29             DimacsDescriptor &desc)
    1.30  {
    1.31 @@ -169,7 +170,7 @@
    1.32    switch(desc.type)
    1.33      {
    1.34      case DimacsDescriptor::MIN:
    1.35 -      solve_min<Value>(ap,is,os,infty,desc);
    1.36 +      solve_min<Value, LargeValue>(ap,is,os,infty,desc);
    1.37        break;
    1.38      case DimacsDescriptor::MAX:
    1.39        solve_max<Value>(ap,is,os,infty,desc);
    1.40 @@ -264,14 +265,16 @@
    1.41      }
    1.42      
    1.43    if(ap.given("double"))
    1.44 -    solve<double>(ap,is,os,desc);
    1.45 +    solve<double, double>(ap,is,os,desc);
    1.46    else if(ap.given("ldouble"))
    1.47 -    solve<long double>(ap,is,os,desc);
    1.48 +    solve<long double, long double>(ap,is,os,desc);
    1.49  #ifdef LEMON_HAVE_LONG_LONG
    1.50    else if(ap.given("long"))
    1.51 -    solve<long long>(ap,is,os,desc);
    1.52 +    solve<long long, long long>(ap,is,os,desc);
    1.53 +  else solve<int, long long>(ap,is,os,desc);
    1.54 +#else
    1.55 +  else solve<int, long>(ap,is,os,desc);
    1.56  #endif
    1.57 -  else solve<int>(ap,is,os,desc);
    1.58  
    1.59    return 0;
    1.60  }