diff --git a/tools/dimacs-solver.cc b/tools/dimacs-solver.cc --- a/tools/dimacs-solver.cc +++ b/tools/dimacs-solver.cc @@ -72,7 +72,7 @@ template void solve_max(ArgParser &ap, std::istream &is, std::ostream &, - DimacsDescriptor &desc) + Value infty, DimacsDescriptor &desc) { bool report = !ap.given("q"); Digraph g; @@ -80,7 +80,7 @@ Digraph::ArcMap cap(g); Timer ti; ti.restart(); - readDimacsMax(is, g, cap, s, t, desc); + readDimacsMax(is, g, cap, s, t, infty, desc); if(report) std::cerr << "Read the file: " << ti << '\n'; ti.restart(); Preflow > pre(g,cap,s,t); @@ -115,6 +115,17 @@ void solve(ArgParser &ap, std::istream &is, std::ostream &os, DimacsDescriptor &desc) { + std::stringstream iss(ap["infcap"]); + Value infty; + iss >> infty; + if(iss.fail()) + { + std::cerr << "Cannot interpret '" + << static_cast(ap["infcap"]) << "' as infinite" + << std::endl; + exit(1); + } + switch(desc.type) { case DimacsDescriptor::MIN: @@ -122,7 +133,7 @@ "\n\n Sorry, the min. cost flow solver is not yet available.\n"; break; case DimacsDescriptor::MAX: - solve_max(ap,is,os,desc); + solve_max(ap,is,os,infty,desc); break; case DimacsDescriptor::SP: solve_sp(ap,is,os,desc); @@ -159,6 +170,7 @@ .boolOption("ldouble","Use 'long double' for capacities, costs etc.") .optionGroup("datatype","ldouble") .onlyOneGroup("datatype") + .stringOption("infcap","Value used for 'very high' capacities","0") .run(); std::ifstream input;