src/work/alpar/f_ed_ka_demo.cc
author athos
Fri, 02 Apr 2004 14:53:05 +0000
changeset 276 b38f4cfa76cf
parent 117 67253d52b284
child 921 818510fa3d99
permissions -rw-r--r--
suurballe fordulo es segfaultolo(!) valtozata
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@108
    11
using namespace hugo;
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@74
    44
  //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(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
}