On Sat, 19 Jun 2004 23:16:39 -0400 (EDT), Douglas Paul Gregor wrote:
On Sun, 20 Jun 2004, Tim Rowe wrote:
In the Kevin Bacon example in the Boost::Graph documentation, we declare: typedef adjacency_list < vecS, vecS, undirectedS, property < vertex_name_t, std::string >, property < edge_name_t, std::string > > Graph; Graph g;
and later declare and call:
typedef property_map < Graph, vertex_name_t >::type actor_name_map_t; actor_name_map_t actor_name = get(vertex_name, g);
What are we actually getting back here? I can see that we can index it (we do later), but is it just an array? Or a vector? Or what? I assume I am /supposed/ to know (not like Ada's "type foo is private"), so that I know what I can do with it!
You're actually getting back an (Lvalue) property map. Think of it like an std::map
, because it maps from the vertices in the graph g to the vertex name (which is an std::string here). The difference is that the property map is fast (O(1)) whereas the std::map would be slow (O(log |V|)). Interior properties will get a bit easier with the next Boost release.
Doug
Thanks. The property_map documentation says that "the get() function takes a property map object [...] and a key object"; is that the get() that's used there? So vertex_name is a map of maps, with a Graph as a key? Or is get() overloaded with a meaning I've not managed to find yet? And where is the interface to property_map defined? boost_1_31_0\libs\graph\doc\using_property_maps.html says that it's defined in boost_1_31_0\libs\property_map\property_map.html, but that just contains another example, and I can't find which header declares it -- I can't see it in property_map.hpp which is where I expected it to be! TIA, Tim