src/work/marci/preflow_demo_athos.cc
author alpar
Tue, 15 Feb 2005 15:00:31 +0000
changeset 1150 c20bcf71efe3
parent 921 818510fa3d99
permissions -rw-r--r--
Minor changes.
marci@82
     1
#include <iostream>
marci@82
     2
#include <fstream>
marci@82
     3
athos@522
     4
#include <list_graph.h>
athos@522
     5
#include <dimacs.h>
marci@82
     6
#include <preflow_push.hh>
marci@82
     7
#include <time_measure.h>
marci@82
     8
alpar@921
     9
using namespace lemon;
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 **) {
athos@522
    14
  typedef ListGraph::Node Node;
athos@522
    15
  //typedef ListGraph::EachEdgeIt EachEdgeIt;
marci@82
    16
marci@82
    17
  ListGraph G;
athos@522
    18
  Node 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) {
alpar@986
    31
  //  if (cut.get(G.source(e)) && !cut.get(G.target(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) { 
alpar@986
    36
  //  std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(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
}