src/work/alpar/f_ed_ka_demo.cc
author alpar
Wed, 16 Feb 2005 16:17:30 +0000
changeset 1151 b217fc69f913
parent 921 818510fa3d99
permissions -rw-r--r--
Several changes in the docs.
alpar@74
     1
#include <iostream>
alpar@74
     2
#include <fstream>
alpar@74
     3
alpar@103
     4
#include "smart_graph.h"
alpar@103
     5
alpar@74
     6
#include "../list_graph.hh"
alpar@74
     7
#include "../marci/dimacs.hh"
alpar@74
     8
#include "f_ed_ka.h"
alpar@74
     9
#include "../marci/time_measure.h"
alpar@74
    10
alpar@921
    11
using namespace lemon;
alpar@74
    12
alpar@74
    13
// Use a DIMACS max flow file as stdin.
alpar@74
    14
// read_dimacs_demo < dimacs_max_flow_file
alpar@74
    15
alpar@74
    16
int main(int, char **) {
alpar@108
    17
  typedef SmartGraph Graph;
alpar@108
    18
  //typedef ListGraph Graph;
alpar@74
    19
alpar@103
    20
  typedef Graph::NodeIt NodeIt;
alpar@103
    21
  typedef Graph::EachNodeIt EachNodeIt;
alpar@103
    22
  typedef Graph::EachEdgeIt EachEdgeIt;
alpar@103
    23
alpar@103
    24
  Graph G;
marci@95
    25
  NodeIt s, t;
alpar@118
    26
  Timer ts;
alpar@108
    27
  Graph::DynEdgeMap<int> cap(G);
alpar@74
    28
  readDimacsMaxFlow(std::cin, G, s, t, cap);
alpar@74
    29
alpar@118
    30
  std::cout << "loading time: " << ts << std::endl;
alpar@118
    31
  ts.reset();
alpar@74
    32
  std::cout << "edmonds karp demo..." << std::endl;
alpar@108
    33
  Graph::DynEdgeMap<int> flow(G); //0 flow
alpar@74
    34
  
alpar@74
    35
  int ret;
alpar@118
    36
  //  double pre_time=currTime();
alpar@117
    37
  
alpar@74
    38
  ret = maxFlow(G,flow,cap,s,t);
alpar@118
    39
  //  double post_time=currTime();
alpar@118
    40
  std::cout << "running time: " << ts << std::endl;
alpar@117
    41
alpar@74
    42
  //std::cout << "maximum flow: "<< std::endl;
alpar@74
    43
  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
alpar@986
    44
  //  std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
alpar@74
    45
  //}
alpar@74
    46
  //std::cout<<std::endl;
alpar@118
    47
  //  std::cout<<"elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
alpar@74
    48
  std::cout << "flow value: "<< ret << std::endl;
alpar@74
    49
alpar@74
    50
  return 0;
alpar@74
    51
}