Boost logo

Boost Users :

Subject: [Boost-users] [BGL] getting an edge_descriptor of a reverse_graph
From: Alex Hagen-Zanker (ahh34_at_[hidden])
Date: 2011-12-20 09:13:11


I upgraded from boost 1.45 to 1.48 and there are some breaking changes
related to reverse_graph

The main problem that I encounter is that boost::edge(u ,v, graph)
returns a edge_descriptor to the graph that underlies reverse_graph,
rather than reverse_graph itself . The following therefore does not
compile:

template<typename Graph>
void foo(Graph& graph)
{
   boost::graph_traits<Graph>::edge_descriptor e = boost::edge(0, 1,
graph).first;
}

int main() {
   boost::adjacency_list<boost::vecS, boost::vecS,
boost::bidirectionalS> graph(2);
   foo(graph); // this line compiles
   foo(boost::make_reverse_graph(graph)); // this line does not compile
}

Do you have suggestions how to rewrite foo(Graph& graph) in order to
generically work for both plain and reversed graphs? For now I have
rewritten the boost::edge function in reverse_graph.hpp to return a
pair<reverse_graph_edge_descriptor, bool> but that does not seem right.

Thanks, Alex


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