COIN-OR::LEMON - Graph Library

Changeset 649:a79ef774fae1 in lemon


Ignore:
Timestamp:
02/24/09 09:52:26 (16 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Support min cost flow in dimacs-solver (#234)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/dimacs-solver.cc

    r579 r649  
    4545#include <lemon/preflow.h>
    4646#include <lemon/max_matching.h>
     47#include <lemon/network_simplex.h>
    4748
    4849using namespace lemon;
     
    9293}
    9394
     95template<class Value>
     96void solve_min(ArgParser &ap, std::istream &is, std::ostream &,
     97               DimacsDescriptor &desc)
     98{
     99  bool report = !ap.given("q");
     100  Digraph g;
     101  Digraph::ArcMap<Value> lower(g), cap(g), cost(g);
     102  Digraph::NodeMap<Value> sup(g);
     103  Timer ti;
     104  ti.restart();
     105  readDimacsMin(is, g, lower, cap, cost, sup, desc);
     106  if (report) std::cerr << "Read the file: " << ti << '\n';
     107  ti.restart();
     108  NetworkSimplex< Digraph, Digraph::ArcMap<Value>, Digraph::ArcMap<Value>,
     109                  Digraph::ArcMap<Value>, Digraph::NodeMap<Value> >
     110    ns(g, lower, cap, cost, sup);
     111  if (report) std::cerr << "Setup NetworkSimplex class: " << ti << '\n';
     112  ti.restart();
     113  ns.run();
     114  if (report) std::cerr << "Run NetworkSimplex: " << ti << '\n';
     115  if (report) std::cerr << "\nMin flow cost: " << ns.totalCost() << '\n';
     116}
     117
    94118void solve_mat(ArgParser &ap, std::istream &is, std::ostream &,
    95119              DimacsDescriptor &desc)
     
    119143    {
    120144    case DimacsDescriptor::MIN:
    121       std::cerr <<
    122         "\n\n Sorry, the min. cost flow solver is not yet available.\n";
     145      solve_min<Value>(ap,is,os,desc);
    123146      break;
    124147    case DimacsDescriptor::MAX:
Note: See TracChangeset for help on using the changeset viewer.