Boost logo

Boost Users :

From: Jeremy Siek (jsiek_at_[hidden])
Date: 2002-09-16 13:27:56


Hi Chris,

On Mon, 16 Sep 2002, Chris Russell wrote:
cdr> Okay - I think I understand this. Since posting I've re-read the
cdr> property map documentation online and in the book and am still
cdr> confused about several points (forgive me ignorance - I'm learning a
cdr> lot of new concepts (in the canonical sense) at once). Will you help
cdr> me with these follow-up questions please:
cdr>
cdr> Assertions: (please validate)
cdr>
cdr> 1. a property map maps some type (an enum or struct tag) to some other
cdr> type.

No, a propery map is a map from a set of key objects to a set of value
objects.

What you are probably thinking about is the boost::get() function that
returns a property map for a given graph and property tag. Perhaps it is a
little confusing that you use a different overload of boost::get() on the
property map itself.

cdr> 2. a property map declaration may contain nested property map
cdr> declarations but this does not reflect a hierarchy - it's just a
cdr> template trick. Effectively the property maps are peers.

Hmm, the above statement doesn't make much sense to me.

cdr> 3. graph containers like adjacency list will internally create a new
cdr> value_type object upon insertion of a vertex (in the case of a vertex
cdr> property map) and an edge (in the case of an edge property map).

Yes.

cdr> Assuming the above assertions are correct, I'm still confused about
cdr> several points:
cdr>
cdr> 1. a boost::get call to return either a property_map<x,y>::type or
cdr> property_map<x,y>::const_type by value? I think yes. The question is does
cdr> return by value also copy all the value_type's? I'm guessing not because
cdr> this would be a huge performance hit. Just the property map itself is
cdr> copied. Correct?

The copy semantics for property maps is required to be shallow, so that
copying is lightweight. In browsing through the online property map docs
it looks like I forgot to make that explicit.

cdr> 2. In the case of my algorithm visitor, I am passed a const reference
cdr> to a graph that will result in a boost::get returning a const_type a
cdr> property map. I can understand that changing the value_type's of an
cdr> arbitrary property map could potentially screw up an algorithm (if
cdr> the algorithm is using the specific property that I am trying to
cdr> write). Is this why the graph passed to the visitor is const? In the
cdr> case where I need to write an internal property map that is not being
cdr> used by the specific algorithm (in the case of my dfs search, dfs is
cdr> using the vertex color and I want to write another, distinct internal
cdr> property map that I have registered with my graph class), I should
cdr> pass a reference to the specific map into the constructor of the
cdr> visitor?

Yes, that would work.

cdr> Thank you for your help Jeremy.

You bet!

Cheers,
Jeremy

----------------------------------------------------------------------
 Jeremy Siek http://php.indiana.edu/~jsiek/
 Ph.D. Student, Indiana Univ. B'ton email: jsiek_at_[hidden]
 C++ Booster (http://www.boost.org) office phone: (812) 855-3608
----------------------------------------------------------------------


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