Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-07-10 08:50:39


Douglas Gregor <doug.gregor_at_[hidden]> writes:

> On Jul 9, 2005, at 10:38 PM, David Abrahams wrote:
>> Douglas Gregor <doug.gregor_at_[hidden]> writes:
>>> color_map has a nontrivial default of:
>>> vector_property_map<color_type, typeof(index_map)>
>>>
>>
>> Say, that doesn't correspond to what I see at
>> http://www.boost-consulting.com/boost/libs/graph/doc/
>> depth_first_search.html
>> and furthermore I think that last "nontrivial default" is a type, not
>> a value. Can you clear this up? Did you mean a different algorithm?
>
> I changed two things, to try to simplify the example:

Hmm, but any real simplification tends to confuse if the reader does
what I did, and refers to the BGL docs.

Anyway, suppose I want to use your simplified example. What is the
*value* of the last "nontrivial default?"

You wrote:

       vector_property_map<color_type, typeof(index_map)>

but as I said, that seems to be a type!

> 1) I dropped the optional root_vertex parameter.

Okay.

> 2) I changed the default for the color_map to something a little
> simpler.

And impossible ;-)

> The real color map will be built like this:
>
> typename graph_traits<Graph>::vertices_size_type n =
> num_vertices(graph);
> std::vector<default_color_type> color_vec(n);
> iterator_property_map<
> typename std::vector<default_color_type>::iterator, IndexMap
> > default_color_map(color_vec.begin(), index_map);
>
> The really tough part is that color_vec needs to stick around, so it
> can't be buried in a function object somewhere.

Well, you can have it in a function object, as long as there's a way
to retrieve it, or the function object outlives the function call.
But more to the point, shouldn't it be part of the color_map itself?
There's no rule that the color_map has to be a simple vector, is
there?

> An equivalent (but slightly simpler) alternative is to use:
>
> typename graph_traits<Graph>::vertices_size_type n =
> num_vertices(graph);
> vector_property_map<default_color_type, IndexMap>(n, index_map);

Yes, that looks simpler, because it avoids the issue of holding onto a
separate color_vec. Is there some downside?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk