Re: [Boost-users] BGL: shared_ptr as bundled properties > how to generate properties maps ???
On Wed, 6 Jan 2010, Emil Dotchevski wrote:
On Wed, Jan 6, 2010 at 8:20 AM, Damien Maupu
wrote: I write something like: typedef boost::shared_ptr<Vertex> VertexPtr; typedef boost::shared_ptr<Edge> EdgePtr; typedef adjacency_list
Graph; It is probably not a good idea to use shared_ptr for graphs; some graphs have cycles and this will lead to leaks (if your data structure is a DAG, you're fine.)
I don't think that will be an issue -- his shared pointers link to properties; the graph structure itself is in BGL data structures. However, if the properties refer to other graph vertices or edges, there is an issue of dangling references if those objects are removed from the graph.
-- Jeremiah Willcock
Hi, I am not sure I understand why using smart pointer should be an issue. Could you explain me in little more details? Do you know how to get properties maps if bundle properties are pointer or smart pointers? Thank you Damien
On Thu, 7 Jan 2010, Damien Maupu wrote:
On Wed, 6 Jan 2010, Emil Dotchevski wrote:
On Wed, Jan 6, 2010 at 8:20 AM, Damien Maupu
wrote: I write something like: typedef boost::shared_ptr<Vertex> VertexPtr; typedef boost::shared_ptr<Edge> EdgePtr; typedef adjacency_list
Graph; It is probably not a good idea to use shared_ptr for graphs; some graphs have cycles and this will lead to leaks (if your data structure is a DAG, you're fine.)
I don't think that will be an issue -- his shared pointers link to properties; the graph structure itself is in BGL data structures. However, if the properties refer to other graph vertices or edges, there is an issue of dangling references if those objects are removed from the graph.
-- Jeremiah Willcock
Hi,
I am not sure I understand why using smart pointer should be an issue. Could you explain me in little more details?
Do you know how to get properties maps if bundle properties are pointer or smart pointers?
The bundled property mechanism expects the bundled property template parameters (for vertices and edges) to be structs/classes that contain individual properties as members. The get() function with a pointer to member gets the property map for an individual member of the struct. Therefore, the default property map mechanism can only get the members of the shared_ptr itself, which I believe are private (and not the members of the pointed-to object, which you want). Therefore, you need to use another mechanism to obtain property maps for objects pointed to by a bundled property. It might be possible to use metaprogramming to make that automatic, but Boost.Graph does not contain that functionality currently. The solution is to use something like function_property_map (the message you are replying to). -- Jeremiah Willcock
participants (2)
-
Damien Maupu
-
Jeremiah Willcock