src/work/marci/max_flow_1.cc
author klao
Sun, 09 Jan 2005 23:21:52 +0000
changeset 1066 520769d825f2
parent 762 511200bdb71f
permissions -rw-r--r--
src/work/Doxyfile: Minor changes

* include \internal documentation
* input whole directories: marci, alpar, deba, klao
* sync to doc/Doxyfile
marci@615
     1
// -*- c++ -*-
marci@615
     2
#include <iostream>
marci@615
     3
#include <fstream>
marci@615
     4
marci@642
     5
#include <sage_graph.h>
alpar@921
     6
#include <lemon/smart_graph.h>
alpar@921
     7
#include <lemon/dimacs.h>
alpar@921
     8
#include <lemon/time_measure.h>
marci@615
     9
//#include <graph_wrapper.h>
alpar@921
    10
#include <lemon/max_flow.h>
marci@615
    11
//#include <preflow_res.h>
marci@762
    12
#include <for_each_macros.h>
marci@615
    13
alpar@921
    14
using namespace lemon;
marci@615
    15
marci@615
    16
// Use a DIMACS max flow file as stdin.
marci@615
    17
// read_dimacs_demo < dimacs_max_flow_file
marci@615
    18
marci@615
    19
marci@615
    20
int main(int, char **) {
marci@615
    21
marci@642
    22
  typedef SageGraph MutableGraph;
marci@615
    23
marci@615
    24
  typedef SmartGraph Graph;
marci@615
    25
  //  typedef ListGraph Graph;
marci@615
    26
  typedef Graph::Node Node;
marci@615
    27
  typedef Graph::EdgeIt EdgeIt;
marci@615
    28
marci@615
    29
marci@615
    30
  Graph g;
marci@615
    31
  Node s, t;
marci@615
    32
  Graph::EdgeMap<int> cap(g);
marci@615
    33
  //readDimacsMaxFlow(std::cin, g, s, t, cap);
marci@615
    34
  readDimacs(std::cin, g, cap, s, t);
marci@615
    35
  Timer ts;
marci@615
    36
  Graph::EdgeMap<int> flow(g); //0 flow
marci@615
    37
  MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > 
marci@615
    38
    max_flow_test(g, s, t, cap, flow);
marci@615
    39
marci@615
    40
  {
marci@615
    41
    std::cout << "preflow ..." << std::endl;
marci@615
    42
    FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
marci@615
    43
    ts.reset();
jacint@629
    44
    max_flow_test.preflowPhase1(MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::ZERO_FLOW);
marci@615
    45
    std::cout << "elapsed time: " << ts << std::endl;
marci@615
    46
    std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
marci@615
    47
  }
marci@615
    48
marci@615
    49
  {
marci@615
    50
    std::cout << "preflow ..." << std::endl;
marci@615
    51
    FOR_EACH_LOC(Graph::EdgeIt, e, g) flow.set(e, 0);
marci@615
    52
    ts.reset();
jacint@629
    53
    max_flow_test.preflowPhase1(MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> >::ZERO_FLOW);
marci@615
    54
    std::cout << "elapsed time: " << ts << std::endl;
marci@615
    55
    std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
marci@615
    56
  }
marci@615
    57
marci@615
    58
marci@615
    59
  return 0;
marci@615
    60
}