marci@73: #include marci@73: #include marci@73: marci@73: #include marci@73: #include marci@73: #include marci@73: #include marci@73: #include marci@73: marci@73: #include marci@73: marci@73: // Use a DIMACS network flow file as stdin. marci@73: // max_flow < max_flow.dat marci@73: int main() marci@73: { marci@73: using namespace boost; marci@73: marci@73: typedef adjacency_list_traits Traits; marci@73: typedef adjacency_list, marci@73: property > > marci@73: > Graph; marci@73: marci@73: Graph g; marci@73: marci@73: property_map::type marci@73: capacity = get(edge_capacity, g); marci@73: property_map::type marci@73: rev = get(edge_reverse, g); marci@73: property_map::type marci@73: residual_capacity = get(edge_residual_capacity, g); marci@73: marci@73: Traits::vertex_descriptor s, t; marci@73: read_dimacs_max_flow(g, capacity, rev, s, t); marci@73: marci@73: std::cout << "edmonds karp demo (BOOST)..." << endl; marci@73: double pre_time=currTime(); marci@73: long flow = edmunds_karp_max_flow(g, s, t); marci@73: double post_time=currTime(); marci@73: marci@73: //std::cout << "maximum flow: " << std::endl; marci@73: //graph_traits::vertex_iterator u_iter, u_end; marci@73: //graph_traits::out_edge_iterator ei, e_end; marci@73: //for (tie(u_iter, u_end) = vertices(g); u_iter != u_end; ++u_iter) marci@73: // for (tie(ei, e_end) = out_edges(*u_iter, g); ei != e_end; ++ei) marci@73: // if (capacity[*ei] > 0) marci@73: // std::cout << "f " << *u_iter << " " << target(*ei, g) << " " marci@73: // << (capacity[*ei] - residual_capacity[*ei]) << std::endl; marci@73: // marci@73: //std::cout << std::endl; marci@73: std::cout << "elapsed time: " << post_time-pre_time << " sec"<< std::endl; marci@73: std::cout << "flow value: " << flow << std::endl; marci@73: marci@73: return 0; marci@73: }