Ticket #9368: prim-patch.patch

File prim-patch.patch, 2.4 KB (added by lgtorres42@…, 9 years ago)

general edge weight patch to BGL prim's minimum spanning tree

  • boost/graph/prim_minimum_spanning_tree.hpp

     
    1515#include <boost/graph/dijkstra_shortest_paths.hpp>
    1616
    1717namespace boost {
    18  
     18
    1919  namespace detail {
    2020    // this should be somewhere else in boost...
    2121    template <class U, class V> struct _project2nd {
     
    3636                  Weight)
    3737    {
    3838      typedef typename property_traits<Weight>::value_type W;
    39       std::less<W> compare;
    4039      detail::_project2nd<W,W> combine;
    41       dijkstra_shortest_paths(G, s, params.distance_compare(compare).
    42                               distance_combine(combine));
     40      dijkstra_shortest_paths
     41        (G, s, params.distance_combine(combine));
    4342    }
    4443  } // namespace detail
    4544
    46   template <class VertexListGraph, class DijkstraVisitor, 
     45  template <class VertexListGraph, class DijkstraVisitor,
    4746            class PredecessorMap, class DistanceMap,
    48             class WeightMap, class IndexMap>
     47            class WeightMap, class IndexMap, class BinaryPredicate,
     48            class DistZero, class DistInf>
    4949  inline void
    5050  prim_minimum_spanning_tree
    5151    (const VertexListGraph& g,
    52      typename graph_traits<VertexListGraph>::vertex_descriptor s,
    53      PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
     52     typename graph_traits<VertexListGraph>::vertex_descriptor s,
     53     PredecessorMap predecessor, DistanceMap distance, WeightMap weight,
     54     BinaryPredicate compare, DistZero zero, DistInf inf,
    5455     IndexMap index_map,
    5556     DijkstraVisitor vis)
    5657  {
    5758    typedef typename property_traits<WeightMap>::value_type W;
    58     std::less<W> compare;
    5959    detail::_project2nd<W,W> combine;
    6060    dijkstra_shortest_paths(g, s, predecessor, distance, weight, index_map,
    61                             compare, combine, (std::numeric_limits<W>::max)(), 0,
     61                            compare, combine, inf, zero,
    6262                            vis);
    6363  }
    6464
     
    7070     const bgl_named_params<P,T,R>& params)
    7171  {
    7272    detail::prim_mst_impl
    73       (g, 
    74        choose_param(get_param(params, root_vertex_t()), *vertices(g).first), 
     73      (g,
     74       choose_param(get_param(params, root_vertex_t()), *vertices(g).first),
    7575       params.predecessor_map(p_map),
    7676       choose_const_pmap(get_param(params, edge_weight), g, edge_weight));
    7777  }