|
Boost Users : |
Subject: Re: [Boost-users] Boost Graph: determining type of bundled property
From: Trevor Harmon (Trevor.W.Harmon_at_[hidden])
Date: 2010-04-30 17:11:59
On Apr 29, 2010, at 6:54 PM, Jeremiah Willcock wrote:
> You wouldn't be ordering your properties themselves (or pointers to
> them),
> just the vertex indices. Those are usually integers and so are easy
> to
> compare. Or am I misunderstanding what you're keeping maps of?
The vertex descriptors are the map values, not the map keys. The keys
are the properties themselves. (I don't see how it would work
otherwise.) It's just like the kevin-bacon example:
typedef adjacency_list < vecS, vecS, undirectedS, property <
vertex_name_t,
std::string >, property < edge_name_t, std::string > > Graph;
...
typedef graph_traits < Graph >::vertex_descriptor Vertex;
typedef std::map < std::string, Vertex > NameVertexMap;
NameVertexMap actors;
But I just realized I'm actually still using Foo pointers for my
vertex map's keys. Despite switching to shared_ptr for the vertex
property, the map's functionality doesn't change, due to the way I'm
modeling the data. So there's no need for me to use
shared_ptr<BaseVertex> as the key. In other words, as long as the
efficiency of std::map is as good with pointers as it is with
integers, I've got no worries.
> Look at dynamic_pointer_cast<FooVertex>(vertex).
Seems to work perfectly; thanks!
Trevor
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