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