src/work/alpar/f_ed_ka_demo.cc
author alpar
Mon, 16 Feb 2004 10:57:01 +0000
changeset 74 82d3dbe912d9
child 91 81bf58164f60
permissions -rw-r--r--
.
alpar@74
     1
#include <iostream>
alpar@74
     2
#include <fstream>
alpar@74
     3
alpar@74
     4
#include "../list_graph.hh"
alpar@74
     5
#include "../marci/dimacs.hh"
alpar@74
     6
#include "f_ed_ka.h"
alpar@74
     7
#include "../marci/time_measure.h"
alpar@74
     8
alpar@74
     9
using namespace marci;
alpar@74
    10
alpar@74
    11
// Use a DIMACS max flow file as stdin.
alpar@74
    12
// read_dimacs_demo < dimacs_max_flow_file
alpar@74
    13
alpar@74
    14
int main(int, char **) {
alpar@74
    15
  typedef ListGraph::NodeIt NodeIt;
alpar@74
    16
  typedef ListGraph::EachEdgeIt EachEdgeIt;
alpar@74
    17
alpar@74
    18
  ListGraph G;
alpar@74
    19
  NodeIt s, t;
alpar@74
    20
  ListGraph::EdgeMap<int> cap(G);
alpar@74
    21
  readDimacsMaxFlow(std::cin, G, s, t, cap);
alpar@74
    22
alpar@74
    23
  std::cout << "edmonds karp demo..." << std::endl;
alpar@74
    24
  ListGraph::EdgeMap<int> flow(G); //0 flow
alpar@74
    25
  
alpar@74
    26
  int ret;
alpar@74
    27
  double pre_time=currTime();
alpar@74
    28
  ret = maxFlow(G,flow,cap,s,t);
alpar@74
    29
  double post_time=currTime();
alpar@74
    30
  //std::cout << "maximum flow: "<< std::endl;
alpar@74
    31
  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
alpar@74
    32
  //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
alpar@74
    33
  //}
alpar@74
    34
  //std::cout<<std::endl;
alpar@74
    35
  std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
alpar@74
    36
  std::cout << "flow value: "<< ret << std::endl;
alpar@74
    37
alpar@74
    38
  return 0;
alpar@74
    39
}