]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/graph/test/max_flow_algorithms_bundled_properties_and_named_params.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / graph / test / max_flow_algorithms_bundled_properties_and_named_params.cpp
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
7 typedef boost::adjacency_list_traits< boost::vecS, boost::vecS,
8 boost::directedS >
9 traits;
10 struct edge_t
11 {
12 double capacity;
13 float cost;
14 float residual_capacity;
15 traits::edge_descriptor reversed_edge;
16 };
17 struct 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 };
25 typedef boost::adjacency_list< boost::listS, boost::vecS, boost::directedS,
26 node_t, edge_t >
27 Graph;
28
29 void 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(&edge_t::capacity, g);
36 boost::property_map< Graph, float edge_t::* >::type cost
37 = get(&edge_t::cost, g);
38 boost::property_map< Graph, float edge_t::* >::type residual_capacity
39 = get(&edge_t::residual_capacity, g);
40 boost::property_map< Graph, traits::edge_descriptor edge_t::* >::type rev
41 = get(&edge_t::reversed_edge, g);
42 boost::property_map< Graph, traits::edge_descriptor node_t::* >::type pred
43 = get(&node_t::predecessor, g);
44 boost::property_map< Graph, boost::default_color_type node_t::* >::type col
45 = get(&node_t::color, g);
46
47 boost::SampleGraph::getSampleGraph(
48 g, s, t, capacity, residual_capacity, 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, s, t,
53 boost::capacity_map(capacity)
54 .residual_capacity_map(residual_capacity)
55 .reverse_edge_map(rev)
56 .color_map(col)
57 .predecessor_map(pred));
58
59 BOOST_TEST_EQ(flow_value, 4);
60 }
61
62 int main()
63 {
64 using_named_parameters_and_bundled_params_on_edmonds_karp_max_flow_test();
65 return boost::report_errors();
66 }