reverse_graph
requires that the adapted graph be a model of BidirectionalGraph
. If you change your graph to typedef boost::adjacency_list< boost::setS, boost::vecS, boost::bidirectionalS > Graph;
your program compiles and gives the result:
3
4
############# RGRAPH #############
1
that I believe is what you should expect.
Another way that does not require the reverse_graph
(but still requires bidirectionalS
) is to use:
Graph::out_edge_iterator out_begin, out_end;
for (boost::tie(out_begin, out_end) = out_edges(v2,graph); out_begin != out_end; ++out_begin)
{
std::cout << target(*out_begin,graph) << std::endl;
}
std::cout << std::endl;
Graph::in_edge_iterator in_begin, in_end;
for (boost::tie(in_begin, in_end) = in_edges(v2,graph); in_begin != in_end; ++in_begin)
{
std::cout << source(*in_begin,graph) << std::endl;
}
std::cout << std::endl;