Re: [Boost-users] Newbie: What is the actual return type?
[Sorry about the top-post; switching e-mail accounts] On Sun, 20 Jun 2004, Tim Rowe wrote:
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?
Well, no :(. The get() being used there is actually part of the PropertyGraph concept, documented here: http://www.boost.org/libs/graph/doc/PropertyGraph.html When you have an interior property p (like vertex_name_t in the example graph) and graph g, the expression get(p, g) gives you a property map for that particular property and graph, that can be "indexed" with the appropriate key (e.g., a vertex or edge descriptor).
So vertex_name is a map of maps, with a Graph as a key?
This analogy actually works (much to my surprise!), so long as you don't push it too far :) So yes, get(vertex_name, g) returns a map from vertices in g to the name of the vertex.
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!
The actual struct template property_map is used (only!) to get the return type of, e.g., get(vertex_name, g). It is defined in boost/graph/properties.hpp, but the definition won't help much because I don't think that's quite what you're asking for. When you use get(vertex_name, g) you get back a property map. There's no single type that defines a property map, because it's a concept. To find out what you can do with a property map, check out: http://www.boost.org/libs/property_map/property_map.html Specifically, you want the links to the ReadablePropertyMap, WriteblePropertyMap, and LvaluePropertyMap concepts. Doug
participants (1)
-
Doug Gregor