15 #ifndef PAAL_PRUNE_RESTRICTIONS_TO_TREE_HPP
16 #define PAAL_PRUNE_RESTRICTIONS_TO_TREE_HPP
21 #include <boost/function_output_iterator.hpp>
22 #include <boost/graph/adjacency_list.hpp>
23 #include <boost/graph/kruskal_min_spanning_tree.hpp>
27 using RestrictionsVector = std::vector<std::pair<unsigned, unsigned>>;
40 template <
typename Restrictions>
42 using Dist = decltype(std::declval<Restrictions>()(0, 0));
43 using EdgeProp = boost::property<boost::edge_weight_t, Dist>;
45 boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS,
46 boost::no_property, EdgeProp>;
47 using Edge =
typename boost::graph_traits<TGraph>::edge_descriptor;
49 RestrictionsVector res_vec;
52 for (
auto j :
irange(i + 1, N)) {
53 add_edge(i, j, EdgeProp(-std::max(res(i, j), res(j, i))), g);
57 auto add_edge_to_graph = [&](Edge e) {
58 res_vec.push_back(std::make_pair(source(e, g), target(e, g)));
61 boost::kruskal_minimum_spanning_tree(
62 g, boost::make_function_output_iterator(
68 #endif // PAAL_PRUNE_RESTRICTIONS_TO_TREE_HPP
auto irange(T begin, T end)
irange
auto make_assignable_functor(Functor &f)
make function for assignable_functor
This file contains set of simple useful functors or functor adapters.
RestrictionsVector prune_restrictions_to_tree(Restrictions res, int N)
Returns a list of restrictions, made of the edges of a maximum spanning tree in a clique with edge we...