src/work/marci/preflow_demo_athos.cc
author klao
Thu, 26 Feb 2004 16:07:40 +0000
changeset 132 1ac27e476e25
parent 82 4d6a48fc0a2d
child 522 a0ed1fa1b800
permissions -rw-r--r--
makefile: tobb include konyvtar, jobb depend keszites
flow_test.cc: torolve, mert a depend-et megakasztja, igy gondolom nem is fordul
marci@82
     1
#include <iostream>
marci@82
     2
#include <fstream>
marci@82
     3
marci@82
     4
#include <list_graph.hh>
marci@82
     5
#include <dimacs.hh>
marci@82
     6
#include <preflow_push.hh>
marci@82
     7
#include <time_measure.h>
marci@82
     8
alpar@105
     9
using namespace hugo;
marci@82
    10
marci@82
    11
// Use a DIMACS max flow file as stdin.
marci@82
    12
// read_dimacs_demo < dimacs_max_flow_file
marci@82
    13
int main(int, char **) {
marci@82
    14
  typedef ListGraph::NodeIt NodeIt;
marci@82
    15
  typedef ListGraph::EachEdgeIt EachEdgeIt;
marci@82
    16
marci@82
    17
  ListGraph G;
marci@82
    18
  NodeIt s, t;
marci@82
    19
  ListGraph::EdgeMap<int> cap(G);
marci@82
    20
  readDimacsMaxFlow(std::cin, G, s, t, cap);
marci@82
    21
marci@82
    22
  std::cout << "preflow demo (ATHOS)..." << std::endl;
marci@82
    23
  //ListGraph::EdgeMap<int> flow(G); //0 flow
marci@82
    24
marci@82
    25
  double pre_time=currTime();
marci@82
    26
  preflow_push<ListGraph, int> max_flow_test(G, s, t, cap);
marci@82
    27
  int flow_value=max_flow_test.run();
marci@82
    28
  //ListGraph::NodeMap<bool> cut=max_flow_test.mincut();
marci@82
    29
  //int cut_value=0;
marci@82
    30
  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
marci@82
    31
  //  if (cut.get(G.tail(e)) && !cut.get(G.head(e))) cut_value+=cap.get(e);
marci@82
    32
  //}
marci@82
    33
  double post_time=currTime();
marci@82
    34
  //std::cout << "maximum flow: "<< std::endl;
marci@82
    35
  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
marci@82
    36
  //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
marci@82
    37
  //}
marci@82
    38
  //std::cout<<std::endl;
marci@82
    39
  std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; 
marci@82
    40
  std::cout << "flow value: "<< flow_value << std::endl;
marci@82
    41
  //std::cout << "cut value: "<< cut_value << std::endl;
marci@82
    42
marci@82
    43
  return 0;
marci@82
    44
}