tools/dimacs-solver.cc
changeset 561 6e0525ec5355
parent 532 997a75bac45a
child 569 24682336c38e
     1.1 --- a/tools/dimacs-solver.cc	Sun Mar 29 22:19:14 2009 +0100
     1.2 +++ b/tools/dimacs-solver.cc	Mon Mar 30 16:46:37 2009 +0100
     1.3 @@ -72,7 +72,7 @@
     1.4  
     1.5  template<class Value>
     1.6  void solve_max(ArgParser &ap, std::istream &is, std::ostream &,
     1.7 -              DimacsDescriptor &desc)
     1.8 +               Value infty, DimacsDescriptor &desc)
     1.9  {
    1.10    bool report = !ap.given("q");
    1.11    Digraph g;
    1.12 @@ -80,7 +80,7 @@
    1.13    Digraph::ArcMap<Value> cap(g);
    1.14    Timer ti;
    1.15    ti.restart();
    1.16 -  readDimacsMax(is, g, cap, s, t, desc);
    1.17 +  readDimacsMax(is, g, cap, s, t, infty, desc);
    1.18    if(report) std::cerr << "Read the file: " << ti << '\n';
    1.19    ti.restart();
    1.20    Preflow<Digraph, Digraph::ArcMap<Value> > pre(g,cap,s,t);
    1.21 @@ -115,6 +115,17 @@
    1.22  void solve(ArgParser &ap, std::istream &is, std::ostream &os,
    1.23             DimacsDescriptor &desc)
    1.24  {
    1.25 +  std::stringstream iss(ap["infcap"]);
    1.26 +  Value infty;
    1.27 +  iss >> infty;
    1.28 +  if(iss.fail())
    1.29 +    {
    1.30 +      std::cerr << "Cannot interpret '"
    1.31 +                << static_cast<std::string>(ap["infcap"]) << "' as infinite"
    1.32 +                << std::endl;
    1.33 +      exit(1);
    1.34 +    }
    1.35 +  
    1.36    switch(desc.type)
    1.37      {
    1.38      case DimacsDescriptor::MIN:
    1.39 @@ -122,7 +133,7 @@
    1.40          "\n\n Sorry, the min. cost flow solver is not yet available.\n";
    1.41        break;
    1.42      case DimacsDescriptor::MAX:
    1.43 -      solve_max<Value>(ap,is,os,desc);
    1.44 +      solve_max<Value>(ap,is,os,infty,desc);
    1.45        break;
    1.46      case DimacsDescriptor::SP:
    1.47        solve_sp<Value>(ap,is,os,desc);
    1.48 @@ -159,6 +170,7 @@
    1.49      .boolOption("ldouble","Use 'long double' for capacities, costs etc.")
    1.50      .optionGroup("datatype","ldouble")
    1.51      .onlyOneGroup("datatype")
    1.52 +    .stringOption("infcap","Value used for 'very high' capacities","0")
    1.53      .run();
    1.54  
    1.55    std::ifstream input;