[BGL/PM] Composition of two property maps

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. best regards Matthias Walter

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
participants (2)
-
Jeremiah Willcock
-
Matthias Walter