#define BOOST_TEST_MODULE find_flow_cost_bundled_properties_and_named_params_test #include #include #include #include "min_cost_max_flow_utils.hpp" typedef boost::adjacency_list_traits traits; struct edge_t { double capacity; float cost; float residual_capacity; traits::edge_descriptor reversed_edge; }; struct node_t { traits::edge_descriptor predecessor; int dist; int dist_prev; boost::vertex_index_t id; }; typedef boost::adjacency_list Graph; // Unit test written in order to fails (at compile time) if the find_flow_cost() // is not properly handling bundled properties BOOST_AUTO_TEST_CASE(using_bundled_properties_with_find_max_flow_test) { Graph g; traits::vertex_descriptor s,t; boost::property_map::type capacity = get(&edge_t::capacity, g); boost::property_map::type cost = get(&edge_t::cost, g); boost::property_map::type residual_capacity = get(&edge_t::residual_capacity, g); boost::property_map::type rev = get(&edge_t::reversed_edge, g); boost::property_map::type pred = get(&node_t::predecessor, g); boost::property_map::type vertex_indices = get(boost::vertex_index, g); boost::property_map::type dist = get(&node_t::dist, g); boost::property_map::type dist_prev = get(&node_t::dist_prev, g); boost::SampleGraph::getSampleGraph(g,s,t,capacity,residual_capacity,cost,rev); boost::successive_shortest_path_nonnegative_weights(g,s,t, capacity,residual_capacity,cost,rev,vertex_indices, pred,dist,dist_prev); // The "bundled properties" version (producing errors) int flow_cost = boost::find_flow_cost(g,capacity,residual_capacity,cost); BOOST_CHECK_EQUAL(flow_cost, 29); } // Unit test written in order to fails (at compile time) if the find_flow_cost() // is not properly handling bundled properties BOOST_AUTO_TEST_CASE(using_named_params_and_bundled_properties_with_find_max_flow_test) { Graph g; traits::vertex_descriptor s,t; boost::property_map::type capacity = get(&edge_t::capacity, g); boost::property_map::type cost = get(&edge_t::cost, g); boost::property_map::type residual_capacity = get(&edge_t::residual_capacity, g); boost::property_map::type rev = get(&edge_t::reversed_edge, g); boost::property_map::type pred = get(&node_t::predecessor, g); boost::property_map::type vertex_indices = get(boost::vertex_index, g); boost::property_map::type dist = get(&node_t::dist, g); boost::property_map::type dist_prev = get(&node_t::dist_prev, g); boost::SampleGraph::getSampleGraph(g,s,t,capacity,residual_capacity,cost,rev); boost::successive_shortest_path_nonnegative_weights(g,s,t, capacity,residual_capacity,cost,rev,vertex_indices, pred,dist,dist_prev); // The "named parameters" version (with "bundled properties"; producing errors) int flow_cost = boost::find_flow_cost(g, boost::capacity_map(capacity) .residual_capacity_map(residual_capacity) .weight_map(cost)); BOOST_CHECK_EQUAL(flow_cost, 29); }