Boost logo

Boost :

Subject: Re: [boost] [BGL/PM] Composition of two property maps
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-02-16 10:19:38


On Tue, 16 Feb 2010, Matthias Walter wrote:

> Hi,
>
> I currently have a function which gets a graph plus an index-map and
> want's to call a BFS. Therefore it needs to build a color-map which maps
> vertex_descriptors to colors. As the user already gives a way to map
> vertex_descriptor to index, I'd like to use this mapping. What I need is
> a way to define a property map as a composition:
>
> composed-map (vertex_descriptor) -> color
>
> via
>
> color-map (index-map (vertex_descriptor)) -> color
>
> whereas index-map (vertex_descriptor) -> index and color-map (index) ->
> color
>
> Of course this should not be too difficult to implement, so I'd just
> like to ask whether there already exists some kind of implementation,
> because I neither found a hint by looking in the docs, nor by digging
> through some of the code.
>
> The actual reason I ask is because there might be other ways to come
> around the problem, e.g. making the color-map itself use
> vertex_descriptors as keys, so maybe my suggested solution is not the best.

Having a vertex index and needing to build a property map from that is the
common case. Note that BFS normally makes its own color map from a vertex
index map you give it. If you cannot use that, you can build one by hand
using vector_property_map or iterator_property_map, both of which take an
index map as an argument.

-- Jeremiah Willcock


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