1 #define BOOST_TEST_MODULE \
2 max_flow_algorithms_named_parameters_and_bundled_params_test
3
4 #include <boost/graph/adjacency_list.hpp>
5 #include <boost/test/unit_test.hpp>
6 #include <boost/graph/edmonds_karp_max_flow.hpp>
7
8 #include "min_cost_max_flow_utils.hpp"
9
10 typedef boost::adjacency_list_traits< boost::vecS, boost::vecS,
11 boost::directedS >
12 traits;
13 struct edge_t
14 {
15 double capacity;
16 float cost;
17 float residual_capacity;
18 traits::edge_descriptor reversed_edge;
19 };
20 struct node_t
21 {
22 traits::edge_descriptor predecessor;
23 int dist;
24 int dist_prev;
25 boost::vertex_index_t id;
26 boost::default_color_type color;
27 };
28 typedef boost::adjacency_list< boost::listS, boost::vecS, boost::directedS,
29 node_t, edge_t >
30 Graph;
31
BOOST_AUTO_TEST_CASE(using_named_parameters_and_bundled_params_on_edmonds_karp_max_flow_test)32 BOOST_AUTO_TEST_CASE(
33 using_named_parameters_and_bundled_params_on_edmonds_karp_max_flow_test)
34 {
35 Graph g;
36 traits::vertex_descriptor s, t;
37
38 boost::property_map< Graph, double edge_t::* >::type capacity
39 = get(&edge_t::capacity, g);
40 boost::property_map< Graph, float edge_t::* >::type cost
41 = get(&edge_t::cost, g);
42 boost::property_map< Graph, float edge_t::* >::type residual_capacity
43 = get(&edge_t::residual_capacity, g);
44 boost::property_map< Graph, traits::edge_descriptor edge_t::* >::type rev
45 = get(&edge_t::reversed_edge, g);
46 boost::property_map< Graph, traits::edge_descriptor node_t::* >::type pred
47 = get(&node_t::predecessor, g);
48 boost::property_map< Graph, boost::default_color_type node_t::* >::type col
49 = get(&node_t::color, g);
50
51 boost::SampleGraph::getSampleGraph(
52 g, s, t, capacity, residual_capacity, cost, rev);
53
54 // The "named parameter version" (producing errors)
55 // I chose to show the error with edmonds_karp_max_flow().
56 int flow_value = edmonds_karp_max_flow(g, s, t,
57 boost::capacity_map(capacity)
58 .residual_capacity_map(residual_capacity)
59 .reverse_edge_map(rev)
60 .color_map(col)
61 .predecessor_map(pred));
62
63 BOOST_CHECK_EQUAL(flow_value, 4);
64 }
65