COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/work/marci/read_dimacs_demo.cc @ 69:24c2c2989e0f

Last change on this file since 69:24c2c2989e0f was 69:24c2c2989e0f, checked in by marci, 17 years ago

.

File size: 976 bytes
RevLine 
[69]1#include <iostream>
2#include <fstream>
3#include <list_graph.hh>
4#include <dimacs.hh>
5#include <edmonds_karp.hh>
6
7using namespace marci;
8
9// Use a DIMACS max flow file as stdin.
10// read_dimacs_demo < dimacs_flow_file
11int main(int, char **) {
12  typedef ListGraph::NodeIt NodeIt;
13  typedef ListGraph::EachEdgeIt EachEdgeIt;
14
15  ListGraph G;
16  NodeIt s, t;
17  ListGraph::EdgeMap<int> cap(G);
18  readDimacsMaxFlow(std::cin, G, s, t, cap);
19
20  std::cout << "augmenting path flow algorithm demo..." << std::endl;
21  ListGraph::EdgeMap<int> flow(G); //0 flow
22  MaxFlow<ListGraph, int, ListGraph::EdgeMap<int>, ListGraph::EdgeMap<int> > max_flow_test(G, s, t, flow, cap);
23  max_flow_test.run();
24
25  std::cout << "maximum flow: "<< std::endl;
26  for(EachEdgeIt e=G.first<EachEdgeIt>(); e.valid(); ++e) {
27    std::cout<<"("<<G.tail(e)<< "-"<<flow.get(e)<<"->"<<G.head(e)<<") ";
28  }
29  std::cout<<std::endl;
30  std::cout << "flow value: "<< max_flow_test.flowValue() << std::endl;
31
32  return 0;
33}
Note: See TracBrowser for help on using the repository browser.