Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. template <class DistMap>
  2. class djk_max_visitor:
  3. public boost::dijkstra_visitor<null_visitor>
  4. {
  5. public:
  6. djk_max_visitor(DistMap dist_map,
  7. typename property_traits<DistMap>::value_type max_dist, size_t target)
  8. : _dist_map(dist_map), _max_dist(max_dist), _target(target) {}
  9.  
  10.  
  11. template <class Graph>
  12. void examine_vertex(typename graph_traits<Graph>::vertex_descriptor u,
  13. Graph&)
  14. {
  15. if (_dist_map[u] > _max_dist)
  16. throw stop_search();
  17.  
  18. std::size_t search = _target.find(u);
  19. if (search != _target.end())
  20. {
  21. _target.erase(*search)
  22. if _target.empty()
  23. throw stop_search();
  24. }
  25. }
  26.  
  27.  
  28. private:
  29. DistMap _dist_map;
  30. typename property_traits<DistMap>::value_type _max_dist;
  31. std::unordered_set<std::size_t> _target;
  32. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement