15 #ifndef PAAL_METRIC_TO_BGL_HPP
16 #define PAAL_METRIC_TO_BGL_HPP
18 #define BOOST_RESULT_OF_USE_DECLTYPE
25 #include <boost/graph/adjacency_matrix.hpp>
26 #include <boost/range/adaptor/transformed.hpp>
29 namespace data_structures {
39 using type = boost::adjacency_matrix<
40 boost::undirectedS, boost::no_property,
41 boost::property<boost::edge_weight_t, typename MT::DistanceType>>;
51 template <
typename Metric,
typename Vertices>
53 Vertices && vertices) {
54 using Graph =
typename adjacency_matrix<Metric>::type;
55 const unsigned N = boost::distance(vertices);
57 using Dist =
typename MT::DistanceType;
59 for (
auto && v : vertices) {
60 for (
auto && w : vertices) {
63 v, w, boost::property<boost::edge_weight_t, Dist>(m(v, w)),
83 template <
typename Metric,
typename Vertices>
85 const Metric &m, Vertices && vertices,
86 bimap<
typename boost::range_value<Vertices>::type> &idx) {
88 using VertexType =
typename MT::VertexType;
91 auto get_idx = [&](VertexType v) {
return idx.get_idx(v); };
94 boost::adaptors::transformed(get_idx));
99 #endif // PAAL_METRIC_TO_BGL_HPP
adjacency_matrix< Metric >::type metric_to_bgl_with_index(const Metric &m, Vertices &&vertices, bimap< typename boost::range_value< Vertices >::type > &idx)
produces graph from metric with index
implements both sides mapping from the collection to (0,size(collection)) interval.
metric_on_idx< Metric, Bimap, Strategy > make_metric_on_idx(Metric &&m, Bimap &&b)
make for metric_on_idx
adjacency_matrix< Metric >::type metric_to_bgl(const Metric &m, Vertices &&vertices)
we assume that vertices is sequence of values (0, vertices.size()).
type of adjacency_matrix, for given metric
This file contains set of simple useful functors or functor adapters.