COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/dimacs-solver.cc

    r594 r611  
    4444#include <lemon/preflow.h>
    4545#include <lemon/matching.h>
     46#include <lemon/network_simplex.h>
    4647
    4748using namespace lemon;
     
    9192}
    9293
     94template<class Value>
     95void solve_min(ArgParser &ap, std::istream &is, std::ostream &,
     96               DimacsDescriptor &desc)
     97{
     98  bool report = !ap.given("q");
     99  Digraph g;
     100  Digraph::ArcMap<Value> lower(g), cap(g), cost(g);
     101  Digraph::NodeMap<Value> sup(g);
     102  Timer ti;
     103  ti.restart();
     104  readDimacsMin(is, g, lower, cap, cost, sup, 0, desc);
     105  if (report) std::cerr << "Read the file: " << ti << '\n';
     106  ti.restart();
     107  NetworkSimplex<Digraph, Value> ns(g);
     108  ns.lowerMap(lower).capacityMap(cap).costMap(cost).supplyMap(sup);
     109  if (report) std::cerr << "Setup NetworkSimplex class: " << ti << '\n';
     110  ti.restart();
     111  ns.run();
     112  if (report) std::cerr << "Run NetworkSimplex: " << ti << '\n';
     113  if (report) std::cerr << "\nMin flow cost: " << ns.totalCost() << '\n';
     114}
     115
    93116void solve_mat(ArgParser &ap, std::istream &is, std::ostream &,
    94117              DimacsDescriptor &desc)
     
    129152    {
    130153    case DimacsDescriptor::MIN:
    131       std::cerr <<
    132         "\n\n Sorry, the min. cost flow solver is not yet available.\n";
     154      solve_min<Value>(ap,is,os,desc);
    133155      break;
    134156    case DimacsDescriptor::MAX:
Note: See TracChangeset for help on using the changeset viewer.