[Boost.Graph] Accessing underlying graph of a boost::reverse_graph
Hello, I am currently trying to find out if there is a way to access the underlying graph of a boost::reverse_graph [1]. There does not seem to be support for this. I want to use this to generically define interior edge-properties for reversed graphs, if the underlying graph has them as well. Currently this does not work, because I cannot access the underlying graph object. Am I overlooking something? If not, where could I request to add this? Cheers, Björn Pollex [1]: http://www.boost.org/doc/libs/release/libs/graph/doc/reverse_graph.html
On 09/12/2016 04:35 PM, Björn Pollex wrote:
Hello,
I am currently trying to find out if there is a way to access the underlying graph of a boost::reverse_graph [1]. There does not seem to be support for this. I want to use this to generically define interior edge-properties for reversed graphs, if the underlying graph has them as well. Currently this does not work, because I cannot access the underlying graph object.
For a reverse_graph's bundled properties operator[] simply dispatches to the underlying graph's operator[]. reverse_graph has a public GraphRef m_g member attribute. It should be private and a implementation detail. But it isn't. But can you elaborate a bit on your use-case? Cheers, Daniel J H
Am I overlooking something? If not, where could I request to add this?
Cheers,
Björn Pollex
[1]: http://www.boost.org/doc/libs/release/libs/graph/doc/reverse_graph.html _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi Daniel, the use case is as follows. I have defined a custom graph concept, in which each edge has certain properties, such as a length and a sequence (basically a string). I’ve defined custom property tags for them as well. Now users can make their graphs implement this concept by providing property getters for these properties. Now I’d like to provide a generic mechanism for exposing these properties on reversed graphs. So when a user provides a property getter for the sequence of edges of their graph type, then the reverse_graph of their type should automatically expose the same property, only with reversed sequences. The problem is, in order to generically define the property getter for the reversed graph, I need to be able to access the underlying graph. Here is a more concrete example: struct edge_sequence_tag { using kind = boost::edge_property_tag; }; Let G be some user-defined graph type, then they could implement a property getter like this (skipping all the boilerplate trait specialisations for brevity): boost::property_map<G, edge_sequence_tag>::const_type get(edge_sequence_tag, const G& graph) { // return appropriate property map }; Similarly, I could define a generic version of this function to support reversed graphs (trait specialisations can be written generically as well): class reverse_sequence_property_map { // class that wraps a property map and reverses the sequences it produces }; template<typename U> boost::property_map<boost::reverse_graph<U>, edge_sequence_tag>::const_type get(edge_sequence_tag, const boost::reverse_graph<U>& graph) { const auto & underlying_graph = ???; return reverse_sequence_property_map{get(edge_sequence_tag{}, underlying_graph())}; }; As you can see, this fails because there is no mechanism to access the underlying graph. Do you have any advice on how to achieve this? Cheers, Björn
On 12 Sep 2016, at 16:58, Daniel Hofmann <daniel@trvx.org> wrote:
On 09/12/2016 04:35 PM, Björn Pollex wrote:
Hello,
I am currently trying to find out if there is a way to access the underlying graph of a boost::reverse_graph [1]. There does not seem to be support for this. I want to use this to generically define interior edge-properties for reversed graphs, if the underlying graph has them as well. Currently this does not work, because I cannot access the underlying graph object.
For a reverse_graph's bundled properties operator[] simply dispatches to the underlying graph's operator[].
reverse_graph has a public GraphRef m_g member attribute. It should be private and a implementation detail. But it isn't.
But can you elaborate a bit on your use-case?
Cheers, Daniel J H
Am I overlooking something? If not, where could I request to add this?
Cheers,
Björn Pollex
[1]: http://www.boost.org/doc/libs/release/libs/graph/doc/reverse_graph.html _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Björn Pollex
-
Daniel Hofmann