COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/marci/edmonds_karp_demo.cc @ 139:c76f1eea05d2

Last change on this file since 139:c76f1eea05d2 was 139:c76f1eea05d2, checked in by marci, 20 years ago

next, getNext

File size: 2.6 KB
RevLine 
[73]1#include <iostream>
2#include <fstream>
3
4#include <list_graph.hh>
5#include <dimacs.hh>
6#include <edmonds_karp.hh>
7#include <time_measure.h>
8
[105]9using namespace hugo;
[73]10
11// Use a DIMACS max flow file as stdin.
12// read_dimacs_demo < dimacs_max_flow_file
[139]13
14/*
15  struct Ize {
16  };
17 
18  struct Mize {
19    Ize bumm;
20  };
21
22  template <typename B>
23    class Huha {
24    public:
25      int u;
26      B brr;
27    };
28*/
29
[73]30int main(int, char **) {
31  typedef ListGraph::NodeIt NodeIt;
32  typedef ListGraph::EachEdgeIt EachEdgeIt;
33
[139]34/*
35  Mize mize[10];
36  Mize bize[0];
37  Mize zize;
38  typedef Mize Tize[0];
39
40  std::cout << &zize << " " << sizeof(mize) << sizeof(Tize) << std::endl;
41  std::cout << sizeof(bize) << std::endl;
42
43
44  Huha<Tize> k;
45  std::cout << sizeof(k) << std::endl;
46*/
47
[73]48  ListGraph G;
49  NodeIt s, t;
50  ListGraph::EdgeMap<int> cap(G);
51  readDimacsMaxFlow(std::cin, G, s, t, cap);
52
[133]53  {
54  std::cout << "edmonds karp demo (blocking flow augmentation)..." << std::endl;
[73]55  ListGraph::EdgeMap<int> flow(G); //0 flow
56
57  double pre_time=currTime();
58  MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
[133]59  //max_flow_test.augmentWithBlockingFlow<ListGraph>();
[138]60  int i=0;
61  while (max_flow_test.augmentOnBlockingFlow<ListGraph>()) { ++i; }
[73]62  double post_time=currTime();
[133]63
[73]64  //std::cout << "maximum flow: "<< std::endl;
65  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
66  //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
67  //}
68  //std::cout<<std::endl;
69  std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl;
[138]70  std::cout << "number of augmentation phases: " << i << std::endl;
[73]71  std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
[133]72  }
73
74  {
75  std::cout << "edmonds karp demo (shortest path augmentation)..." << std::endl;
76  ListGraph::EdgeMap<int> flow(G); //0 flow
77
78  double pre_time=currTime();
79  MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
80  //max_flow_test.augmentWithBlockingFlow<ListGraph>();
[138]81  int i=0;
82  while (max_flow_test.augmentOnShortestPath()) { ++i; }
[133]83  double post_time=currTime();
84
85  //std::cout << "maximum flow: "<< std::endl;
86  //for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
87  //  std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
88  //}
89  //std::cout<<std::endl;
90  std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl;
[138]91  std::cout << "number of augmentation phases: " << i << std::endl;
[133]92  std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
93  }
[73]94
95  return 0;
96}
Note: See TracBrowser for help on using the repository browser.