Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-11-17 01:35:53


Manas Singh wrote:

> Is it possible to convert other Property Maps to Vector Property Map?
>
> My requirement is that the property map should be able to grow/expand
> (as I am using it with a dynamic graph which also grows). But I want
> to make it generic so that it works for any kind of property map. So I
> think if I am able to convert any type of property map to vector
> property map then I can grow the property map, when I add new vertices
> to the graph.

Hi Manas,
I don't think it's possible in general, just because Property Map does not
provide any method to iterate over elements.

In the likely case that you have the list of vertices, you can try the
following:

   ...... pm = .......
   vector_property_map<unsigned> vpm;
   BGL_FORALL_VERTICES(v, g, Graph) {
      vpm[v] = pm[v];
   }

(the BGL_FORALL_VERTICES macro is defined in
<boost/graph/iteration_macros.hpp>)

- Volodya


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