COIN-OR::LEMON - Graph Library

Ticket #347: 347-9d380bf27194.patch

File 347-9d380bf27194.patch, 2.0 KB (added by Peter Kovacs, 14 years ago)
  • tools/dimacs-solver.cc

    # 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 --git a/tools/dimacs-solver.cc b/tools/dimacs-solver.cc
    a b  
    9191  if(report) std::cerr << "\nMax flow value: " << pre.flowValue() << '\n'; 
    9292}
    9393
    94 template<class Value>
     94template<class Value, class LargeValue>
    9595void solve_min(ArgParser &ap, std::istream &is, std::ostream &,
    9696               Value infty, DimacsDescriptor &desc)
    9797{
     
    127127  if (report) {
    128128    std::cerr << "Run NetworkSimplex: " << ti << "\n\n";
    129129    std::cerr << "Feasible flow: " << (res ? "found" : "not found") << '\n';
    130     if (res) std::cerr << "Min flow cost: " << ns.totalCost() << '\n';
     130    if (res) std::cerr << "Min flow cost: "
     131                       << ns.template totalCost<LargeValue>() << '\n';
    131132  }
    132133}
    133134
     
    151152}
    152153
    153154
    154 template<class Value>
     155template<class Value, class LargeValue>
    155156void solve(ArgParser &ap, std::istream &is, std::ostream &os,
    156157           DimacsDescriptor &desc)
    157158{
     
    169170  switch(desc.type)
    170171    {
    171172    case DimacsDescriptor::MIN:
    172       solve_min<Value>(ap,is,os,infty,desc);
     173      solve_min<Value, LargeValue>(ap,is,os,infty,desc);
    173174      break;
    174175    case DimacsDescriptor::MAX:
    175176      solve_max<Value>(ap,is,os,infty,desc);
     
    264265    }
    265266   
    266267  if(ap.given("double"))
    267     solve<double>(ap,is,os,desc);
     268    solve<double, double>(ap,is,os,desc);
    268269  else if(ap.given("ldouble"))
    269     solve<long double>(ap,is,os,desc);
     270    solve<long double, long double>(ap,is,os,desc);
    270271#ifdef LEMON_HAVE_LONG_LONG
    271272  else if(ap.given("long"))
    272     solve<long long>(ap,is,os,desc);
     273    solve<long long, long long>(ap,is,os,desc);
     274  else solve<int, long long>(ap,is,os,desc);
     275#else
     276  else solve<int, long>(ap,is,os,desc);
    273277#endif
    274   else solve<int>(ap,is,os,desc);
    275278
    276279  return 0;
    277280}