Hate to keep peppering the list with these, but I am stuck:
In the Kevin Bacon sample, there appears this fragment:
// Convenience function
template <typename DistanceMap>
bacon_number_recorder<DistanceMap>
record_bacon_number(DistanceMap d)
{
return bacon_number_recorder<DistanceMap>(d);
}
Which is used thus:
std::vector<int> bacon_number(num_vertices(g));
breadth_first_search(g, src, visitor(record_bacon_number(&bacon_number[0])));
I am puzzled about the convenience function ... why use it at all?
But when I take it out:
vector<int> numbers(num_vertices(g));
numbers[s] = 0;
breadth_first_search(g, s, visitor(my_distance_recorder (numbers))); All entries for vector<int> numbers are zero.
I changed the declaration for the recorder's ctor to look like this:
my_distance_recorder(Map& _m):m(_m){};
Making it get a reference to that vector, because I assumed I was
recording into a local copy that was being thrown away. No dice, still
zeroes.
My "graph" is a straight line of v---v---v---v---v---etc. for
simplicity, so I should be seeing a bfs count of 0, 1, 2, 3, etc. The
visitor function is being called and is writing incremented values
into the vector - but when it comes back, all are zero.
What's going on? The convenience function must be related to this
problem but I don't see the connection.
Eric
Also noticed that:
breadth_first_search(g, s, visitor(my_distance_recorder (&numbers[0]))); for
breadth_first_search(g, s, visitor(my_distance_recorder (numbers))); gets a compile time error.
participants (1)
-
Eric Fowler