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

source code of boost/libs/graph/test/max_flow_algorithms_bundled_properties_and_named_params.cpp