Boost logo

Boost Users :

Subject: Re: [Boost-users] [graph] Is reverse_graph<> read-only?
From: Cedric Laczny (cedric.laczny_at_[hidden])
Date: 2011-02-18 02:07:42


On Friday, 18. February 2011 07:50:09 Jeremiah Willcock wrote:
> On Fri, 18 Feb 2011, Cedric Laczny wrote:
> > Hi Jeremiah,
> >
> > On Friday, 18. February 2011 00:14:08 Jeremiah Willcock wrote:
> >> On Fri, 18 Feb 2011, al.zatv wrote:
> >>> Jeremiah Willcock <jewillco_at_[hidden]> писал(а) в своём письме Fri, 18
> >>> Feb
> >>>
> >>> 2011 01:49:27 +0300:
> >>>>> Is reverse_graph<> in Boost::Graph Library, read-only?
> >>>>
> >>>> It appears to be read-only. It should be possible to add mutation; it
> >>>> just isn't there yet. Do you need that feature?
> >>>
> >>> Yes. My program build two trees in the same graph. First tree is
> >>> "forward". Second tree is "backward": build by the same algorithm, but
> >>> in reverse order. So I need add_vertex and add_edge for reverse trees.
> >>> I wrote them this way (please look if I'm correct - because I'm a
> >>> newbie and can make stupid errors).
> >>
> >> Do those versions work? I forgot whether edge_descriptors in the
> >> original graph are implicitly convertible to edge_descriptors in the
> >> reverse_graph; your implementations require that.
> >
> > Just of pure interest, where do you see this requirement in the code?
> > It's not that I doubt the fact that it actually is like this but I am
> > interested in knowing how this can be seen in these short, two
> > functions?
>
> He's directly returning the result of add_edge() on the underlying graph
> as a pair<reverse_graph::edge_descriptor, bool> without explicitly
> converting the underlying graph's edge_descriptor to the reverse_graph's
> version.

I just saw, that reverse_graph.hpp does not provide add_edge()... Which
function is then called? The one of the underlying graph, that is _not_
reversed?
Because I was assuming that add_ege would simply return an edge_descriptor of
the same type as the input graph, which in this case actually is
reverse_graph<>. Therefore I didn't quite see the implicit conversion...

>
> Anyway, it turns out that the descriptors are exactly the same between the
> underlying and reverse graphs; that is not documented, however.
>
> >> Your code would be easy to fix for the
> >> other case, though.
> >
> > Again, I would really like to know how.
>
> See above about the types being the same. If not, there is no documented
> way to do the conversion.
>
> -- Jeremiah Willcock

Best,

Cedric


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