src/work/marci/read_dimacs_demo.cc
changeset 69 24c2c2989e0f
child 71 1d8d806ac8e0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/marci/read_dimacs_demo.cc	Mon Feb 09 13:11:10 2004 +0000
     1.3 @@ -0,0 +1,33 @@
     1.4 +#include <iostream>
     1.5 +#include <fstream>
     1.6 +#include <list_graph.hh>
     1.7 +#include <dimacs.hh>
     1.8 +#include <edmonds_karp.hh>
     1.9 +
    1.10 +using namespace marci;
    1.11 +
    1.12 +// Use a DIMACS max flow file as stdin.
    1.13 +// read_dimacs_demo < dimacs_flow_file
    1.14 +int main(int, char **) {
    1.15 +  typedef ListGraph::NodeIt NodeIt;
    1.16 +  typedef ListGraph::EachEdgeIt EachEdgeIt;
    1.17 +
    1.18 +  ListGraph G;
    1.19 +  NodeIt s, t;
    1.20 +  ListGraph::EdgeMap<int> cap(G);
    1.21 +  readDimacsMaxFlow(std::cin, G, s, t, cap);
    1.22 +
    1.23 +  std::cout << "augmenting path flow algorithm demo..." << std::endl;
    1.24 +  ListGraph::EdgeMap<int> flow(G); //0 flow
    1.25 +  MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
    1.26 +  max_flow_test.run();
    1.27 +
    1.28 +  std::cout << "maximum flow: "<< std::endl;
    1.29 +  for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) { 
    1.30 +    std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
    1.31 +  }
    1.32 +  std::cout<<std::endl;
    1.33 +  std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
    1.34 +
    1.35 +  return 0;
    1.36 +}