src/work/marci/leda_graph_demo.cc
changeset 1365 c280de819a73
parent 1364 ee5959aa4410
child 1366 d00b85f8be45
     1.1 --- a/src/work/marci/leda_graph_demo.cc	Sun Apr 17 18:57:22 2005 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,85 +0,0 @@
     1.4 -// -*- c++ -*-
     1.5 -#include <iostream>
     1.6 -#include <fstream>
     1.7 -
     1.8 -#include <LEDA/graph.h>
     1.9 -#include <leda_graph_wrapper.h>
    1.10 -#include <dimacs.h>
    1.11 -#include <time_measure.h>
    1.12 -#include <edmonds_karp.h>
    1.13 -
    1.14 -using namespace lemon;
    1.15 -
    1.16 -using std::cout; 
    1.17 -using std::endl;
    1.18 -
    1.19 -int main() {
    1.20 -  leda::graph g;
    1.21 -  typedef LedaGraphWrapper<leda::graph> Graph;
    1.22 -  Graph G(g);
    1.23 -//   G.addNode();
    1.24 -//   G.addNode();
    1.25 -//   std::cout << G.nodeNum() << std::endl; 
    1.26 -
    1.27 -  typedef Graph::Node Node;
    1.28 -  typedef Graph::NodeIt NodeIt;  
    1.29 -  typedef Graph::Edge Edge;
    1.30 -  typedef Graph::EdgeIt EdgeIt;
    1.31 -  typedef Graph::OutEdgeIt OutEdgeIt;
    1.32 -  typedef Graph::InEdgeIt InEdgeIt;
    1.33 -
    1.34 -  Node s, t;
    1.35 -  Graph::EdgeMap<int> cap(G);
    1.36 -  readDimacsMaxFlow(std::cin, G, s, t, cap);
    1.37 -
    1.38 -
    1.39 -//   cout << "bfs and dfs iterator demo on the directed graph" << endl;
    1.40 -//   for(NodeIt n=G.first<NodeIt>(); G.valid(n); G.next(n)) { 
    1.41 -//     cout << G.id(n) << ": ";
    1.42 -//     cout << "out edges: ";
    1.43 -//     for(OutEdgeIt e=G.first<OutEdgeIt>(n); G.valid(e); G.next(e)) 
    1.44 -//       cout << G.id(G.source(e)) << "-" << cap.get(e) << "->" << G.id(G.target(e)) << " ";
    1.45 -//     cout << "in edges: ";
    1.46 -//     for(InEdgeIt e=G.first<InEdgeIt>(n); G.valid(e); G.next(e)) 
    1.47 -//       cout << G.id(G.source(e)) << "-" << cap.get(e) << "->" << G.id(G.target(e)) << " ";
    1.48 -//     cout << endl;
    1.49 -//   }
    1.50 -
    1.51 -//   int i=0;
    1.52 -//   for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) { cap.set(e, i); i+=3; }
    1.53 -//   for(EdgeIt e=G.first<EdgeIt>(); G.valid(e); G.next(e)) { cout << cap.get(e) << " "; }
    1.54 -//   cout << endl;
    1.55 -
    1.56 -  {
    1.57 -    //std::cout << "SmartGraph..." << std::endl;
    1.58 -    std::cout << "on-the-fly edmonds karp demo on wrapped leda graph..." << std::endl;
    1.59 -    Graph::EdgeMap<int> flow(G); //0 flow
    1.60 -
    1.61 -
    1.62 -    Timer ts;
    1.63 -    ts.reset();
    1.64 -
    1.65 -    MaxFlow<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
    1.66 -    //max_flow_test.augmentWithBlockingFlow<Graph>();
    1.67 -    int i=0;
    1.68 -    while (max_flow_test.augmentOnShortestPath()) { 
    1.69 -//     for(EdgeIt e=G.template first<EdgeIt>(); e.valid(); ++e) { 
    1.70 -//       std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    1.71 -//     }
    1.72 -//     std::cout<<std::endl;
    1.73 -      ++i; 
    1.74 -    }
    1.75 -
    1.76 -//   std::cout << "maximum flow: "<< std::endl;
    1.77 -//   for(EdgeIt e=G.first<EdgeIt>(); e.valid(); ++e) { 
    1.78 -//     std::cout<<"("<<G.source(e)<< "-"<<flow.get(e)<<"->"<<G.target(e)<<") ";
    1.79 -//   }
    1.80 -//   std::cout<<std::endl;
    1.81 -    std::cout << "elapsed time: " << ts << std::endl;
    1.82 -    std::cout << "number of augmentation phases: " << i << std::endl; 
    1.83 -    std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
    1.84 -  }
    1.85 -  
    1.86 -
    1.87 -  return 0;
    1.88 -}