BGL: Retrieving a vertex_descriptor from a custom property?
I'm wondering if it is somehow possible to attach a custom property (eg. a pointer to some object) to each vertex in a graph, and then lookup the vertex based on that index? My first attempt was to use a simple map outside of the graph, mapping my custom property to a vertex_descriptor, but since the vertex_descriptors seem to change as vertices are inserted and removed this does not work. Is it possible to do this using BGL? An example would be greatly appreciated. Sincerely, Peter
Peter Palotas schrieb:
My first attempt was to use a simple map outside of the graph, mapping my custom property to a vertex_descriptor, but since the vertex_descriptors seem to change as vertices are inserted and removed
Yeah, it's like that when you're using vecS storage ... With listS, insertion and removal should leave vertex descriptors intact.
So is this the recommended way of performing this task? Is there no more
efficient way to do it? And can vecS not be used somehow in this case?
// Peter
On 11/29/06, Jens Müller
Peter Palotas schrieb:
My first attempt was to use a simple map outside of the graph, mapping my custom property to a vertex_descriptor, but since the vertex_descriptors seem to change as vertices are inserted and removed
Yeah, it's like that when you're using vecS storage ...
With listS, insertion and removal should leave vertex descriptors intact.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Jens Müller wrote:
Peter Palotas schrieb:
My first attempt was to use a simple map outside of the graph, mapping my custom property to a vertex_descriptor, but since the vertex_descriptors seem to change as vertices are inserted and removed
Yeah, it's like that when you're using vecS storage ...
With listS, insertion and removal should leave vertex descriptors intact.
See http://www.boost.org/libs/graph/doc/adjacency_list.html, "Iterator and Descriptor Stability/Invalidation".
Okay, it seems using listS storage instead would solve my problem and allow
me to maintain a hash_map mapping my custom data type to a vertex
descriptor. However, using listS I ran in to another problem that I'm having
a problem understanding.
It seems now that I need to generate a ColorMap to pass to depth_first_visit
in some other way than I had been doing before. Can someone perhaps provide
an example of how depth_first_visit would be called using listS for vertex
storage?
Sincerely, Peter
On 11/30/06, Jens Müller
Jens Müller wrote:
Peter Palotas schrieb:
My first attempt was to use a simple map outside of the graph, mapping my custom property to a vertex_descriptor, but since the vertex_descriptors seem to change as vertices are inserted and removed
Yeah, it's like that when you're using vecS storage ...
With listS, insertion and removal should leave vertex descriptors intact.
See http://www.boost.org/libs/graph/doc/adjacency_list.html, "Iterator and Descriptor Stability/Invalidation".
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Jens Müller
-
Peter Palotas