1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/work/marci/edmonds_karp_demo_boost.cc Fri Feb 13 15:57:22 2004 +0000
1.3 @@ -0,0 +1,57 @@
1.4 +#include <iostream>
1.5 +#include <string>
1.6 +
1.7 +#include <boost/config.hpp>
1.8 +#include <boost/graph/edmunds_karp_max_flow.hpp>
1.9 +#include <boost/graph/adjacency_list.hpp>
1.10 +#include <boost/graph/read_dimacs.hpp>
1.11 +#include <boost/graph/graph_utility.hpp>
1.12 +
1.13 +#include <time_measure.h>
1.14 +
1.15 +// Use a DIMACS network flow file as stdin.
1.16 +// max_flow < max_flow.dat
1.17 +int main()
1.18 +{
1.19 + using namespace boost;
1.20 +
1.21 + typedef adjacency_list_traits<vecS, vecS, directedS> Traits;
1.22 + typedef adjacency_list<listS, vecS, directedS,
1.23 + property<vertex_name_t, std::string>,
1.24 + property<edge_capacity_t, long,
1.25 + property<edge_residual_capacity_t, long,
1.26 + property<edge_reverse_t, Traits::edge_descriptor> > >
1.27 + > Graph;
1.28 +
1.29 + Graph g;
1.30 +
1.31 + property_map<Graph, edge_capacity_t>::type
1.32 + capacity = get(edge_capacity, g);
1.33 + property_map<Graph, edge_reverse_t>::type
1.34 + rev = get(edge_reverse, g);
1.35 + property_map<Graph, edge_residual_capacity_t>::type
1.36 + residual_capacity = get(edge_residual_capacity, g);
1.37 +
1.38 + Traits::vertex_descriptor s, t;
1.39 + read_dimacs_max_flow(g, capacity, rev, s, t);
1.40 +
1.41 + std::cout << "edmonds karp demo (BOOST)..." << endl;
1.42 + double pre_time=currTime();
1.43 + long flow = edmunds_karp_max_flow(g, s, t);
1.44 + double post_time=currTime();
1.45 +
1.46 + //std::cout << "maximum flow: " << std::endl;
1.47 + //graph_traits<Graph>::vertex_iterator u_iter, u_end;
1.48 + //graph_traits<Graph>::out_edge_iterator ei, e_end;
1.49 + //for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter)
1.50 + // for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei)
1.51 + // if (capacity[*ei] > 0)
1.52 + // std::cout << "f " << *u_iter << " " << target(*ei, g) << " "
1.53 + // << (capacity[*ei] - residual_capacity[*ei]) << std::endl;
1.54 + //
1.55 + //std::cout << std::endl;
1.56 + std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl;
1.57 + std::cout << "flow value: " << flow << std::endl;
1.58 +
1.59 + return 0;
1.60 +}