Boost logo

Boost :

From: Rob Smallshire (robert_at_[hidden])
Date: 2001-07-24 09:49:01


Two questions regarding the use of the connected_components algorithm
in the Boost Graph library :

Q1:

Compiling the following two lines:

std::vector<int> component(boost::num_vertices(G));
int num = boost::connected_components(G, &component[0]);

in my program causes the following error with MSVC6sp5 on the second
line:

C:/users/rob/dev/utils/boost/boost_1_22_0\boost/property_map.hpp
(185) : error C2664: 'void __cdecl boost::put(int *,int,const int
&)' : cannot convert parameter 2 from 'void *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or
function-style cast
        C:/users/rob/dev/utils/boost/boost_1_22_0
\boost/property_map.hpp(183) : while compiling class-template member
function 'void __thiscall boost::WritablePropertyMapConcept<int
*,void *>::constraints(void)'

The code is almost identical to that in
boost/libs/graph/examples/connected_components.cpp

~~~~~~~~~~~~~~~~~~~~~~

Q2.

Is it possible to use an internal property map with this algorithm ?
I don't like using an arbitrary mix of internal and external maps.

I tried to define a new property:

struct component_t
{
   enum { num = 4564 };
   typedef boost::vertex_property_tag kind;
};

typedef boost::property<component_t, int, VertexSetProperty>
VertexComponentProperty;

...

typedef boost::property_map<Graph, component_t>::type
ComponentPropertyMap;

and later in the code to get a property map object...

ComponentPropertyMap component = boost::get(component_t(), G);

up to this point works fine. But what is the syntax for using this
internal property with the connected_components() algorithm ?

I want to be able to write something like :

int num = boost::connected_components(G, component);

but I can't work out what the syntax is.

Thanks in advance for any pointers.

Rob Smallshire


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