|
Boost Users : |
From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2006-07-05 08:56:22
On Jul 4, 2006, at 7:49 PM, sean yang wrote:
> My question is: (1) is there an easy (some API, sorry I am not
> familar with the library) way to reverse edge direction?
Yes, the "reverse_graph" adaptor reverses the edge direction.
> (2) is there an easy way to add a 'printf()' during BFS?
You can write your own BFS visitor, which has an "examine_vertex"
method that printf()'s the current vertex as it is processed.
The whole thing will look something like this:
struct print_visitor : boost::bfs_visitor<> {
template<typename Graph, typename Vertex>
void examine_vertex(Vertex u, const Graph& g) {
printf(...);
}
};
breadth_first_search(boost::make_reverse_graph(travel), target_2,
boost::visitor(print_visitor()));
Doug
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net