Reputation: 15046
After some tests I observer that the stamp_times visitor is the problem:
typedef adjacency_list <vecS, vecS, undirectedS> Graph;
typedef graph_traits <Graph>::edge_descriptor Edge;
typedef graph_traits <Graph>::vertex_descriptor Vertex;
Graph g(edges.begin(), edges.end(), n);
typedef graph_traits <Graph>::vertices_size_type Size;
std::vector<Size> dtime(num_vertices(g));
Size time = 0;
breadth_first_search(g, s, visitor(make_bfs_visitor(
stamp_times(dtime.begin(), time, on_discover_vertex()))));
(I got more less the same error with that code).
I need to use two visitors one to record predecessors and a second one two obtain visiting time.
boost::breadth_first_search
(g, s,
boost::visitor(boost::make_bfs_visitor
(std::make_pair(
boost::record_predecessors(&p[0], boost::on_tree_edge()),
stamp_times(dtime.begin(), time, on_discover_vertex())))));
But this code event do not compile. I get following error.
/usr/include/boost/graph/visitors.hpp: In member function ‘void boost::time_stamper<TimeMap, TimeT, Tag>::operator()(Vertex, const Graph&) [with Vertex = long unsigned int, Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>, TimeMap = __gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int> >, TimeT = long unsigned int, Tag = boost::on_discover_vertex]’:
/usr/include/boost/graph/visitors.hpp:109:8: instantiated from ‘void boost::detail::invoke_dispatch(Visitor&, T, Graph&, mpl_::true_) [with Visitor = boost::time_stamper<__gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int> >, long unsigned int, boost::on_discover_vertex>, T = long unsigned int, Graph = const boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>, mpl_::true_ = mpl_::bool_<true>]’
/usr/include/boost/graph/visitors.hpp:140:5: instantiated from ‘void boost::invoke_visitors(Visitor&, T, Graph&, Tag) [with Visitor = boost::time_stamper<__gnu_cxx::__normal_iterator<long unsigned int*, std::vector<long unsigned int> >, long unsigned int, boost::on_discover_vertex>, T = long unsigned int, Graph = const boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>, Tag = boost::on_discover_vertex]’
Upvotes: 2
Views: 492
Reputation:
stamp_times
(and the other EventVisitors) expects a WritablePropertyMap
. According to this there are specializations of property_traits
that allow using c++ pointers as property maps and according to this "Since the iterator of a std::vector (obtained with a call to begin()) is a pointer, the pointer property map method also works for std::vector::iterator". Apparently this last part is not true with recent versions of g++ (tested on 4.6.3 and 4.7.1). So in order to invoke stamp_times
you need to use &dtime[0]
instead of dtime.begin()
.
Upvotes: 4