15 #ifndef PAAL_CONTRACT_BGL_ADJACENCY_MATRIX_HPP
16 #define PAAL_CONTRACT_BGL_ADJACENCY_MATRIX_HPP
21 #include <boost/functional/hash.hpp>
22 #include <boost/graph/adjacency_matrix.hpp>
23 #include <boost/range/as_array.hpp>
29 template <
typename Idx,
typename... GraphArgs>
30 void contract(boost::adjacency_matrix<GraphArgs...> &amatrix,
32 typedef boost::graph_traits<puretype(amatrix)> mtraits;
33 typedef typename mtraits::edge_descriptor MEdge;
34 auto const &weight_map =
get(boost::edge_weight, amatrix);
35 weight_map[edge(v, w, amatrix).first] = 0;
36 for (
auto && e : boost::as_array(out_edges(v, amatrix))) {
37 MEdge f = edge(w, target(e, amatrix), amatrix).first;
38 auto &we = weight_map[e];
39 auto &wf = weight_map[f];
40 wf = we = std::min(we, wf);
43 auto teste = edge(target(e, amatrix), w, amatrix).first;
44 auto testf = edge(target(e, amatrix), v, amatrix).first;
45 auto wte = weight_map[teste];
46 auto wtf = weight_map[testf];
47 assert(wte == wtf && wte == we);
52 #endif // PAAL_CONTRACT_BGL_ADJACENCY_MATRIX_HPP
void contract(boost::adjacency_matrix< GraphArgs...> &amatrix, Idx v, Idx w)
contracts to vertices in adjacency_matrix