[BGL] graph & reverse_graph type conversion

Given a type of graph G such as : typedef adjacency_list < listS, listS, bidirectionalS > G; and its reverse graph type : typedef reverse_graph<G> RG How can I convert a graph RG to a graph G simply ? For instance, I would like to apply a function like : void foo(G x); to graphs of type G as well as type RG. I looked in the documentation, unsuccesfully. I tried to change the type of the function to : void foo(RG x); It worked for some functions, but not for others like : void bar(RG x) { // ... add_vertex(x); //... } The compiler complains about : 'Config::vertex_descriptor boost::add_vertex( const Config::vertex_property_type &, boost::adj_list_impl<Derived,Config,Base> &)' : expects 2 arguments - 1 provided Apparently there seems to be no default type conversion ... ? PS : I am currently using VC++ 7.1.

On Monday 22 May 2006 11:55, Jean-Charles Campagne wrote:
Given a type of graph G such as : typedef adjacency_list < listS, listS, bidirectionalS > G;
and its reverse graph type : typedef reverse_graph<G> RG
How can I convert a graph RG to a graph G simply ?
reverse_graph doesn't provide any means for such a conversion. Given an RG you can access the underlying G via the public m_g member, but I wouldn't depend on that since m_g is likely to become private in the future.
For instance, I would like to apply a function like : void foo(G x); to graphs of type G as well as type RG.
Can foo be a function template?
I tried to change the type of the function to : void foo(RG x); It worked for some functions, but not for others like : void bar(RG x) { // ... add_vertex(x); //... }
reverse_graph doesn't model MutableGraph. D.

On Monday 22 May 2006 11:55, Jean-Charles Campagne wrote: Can foo be a function template?
thanks for the idea ;-) I've solved my problem type making the function a template and by passing it the two graphs (graph and reverse_graph) : template< G1, G2 > foo(G1 g1, G2 g2, x) { ... index = get(index, g1); // I get the properties from g1 dijkstra_shortest_paths(g2, ....); // I apply algos to g2 ... } G1 being a "normal" graph, and G2 being a "normal" graph or a reverse graph : if I want to work on the "normal" graph I call : foo(g, g); and if i want to work on the reversed graph : foo(g, rg); JCC
participants (2)
-
Daniel Mitchell
-
Jean-Charles Campagne