Hi,
What you are missing is a color map. One solution is to use bundled
properties:
#include
#include <vector>
#include <map>
#include <iostream> // for std::cout
#include <algorithm> // for std::for_each
#include // for boost::tie
#include // for boost::graph_traits
#include
#include
using namespace boost;
struct Node
{
int index;
//****color property******************************
boost::default_color_type m_algo_color;
//****color property******************************
};
struct Boundary
{
double something;
};
typedef boost::adjacency_list<
boost::setS, boost::listS, boost::undirectedS,
Node, Boundary, boost::setS> Graph;
int main(int argc, char*argv[])
{
Graph g(5);
boost::graph_traits<Graph>::vertex_iterator vi, viend;
std::vector< int > c( num_vertices(g) );
int num;
// manually intialize the vertex index,
// because we have listS as vertex list type
int n = 0;
for (tie(vi, viend) = vertices(g); vi != viend; ++vi, ++n) {
g[*vi].index = n;
}
//****modified call******************************
num = connected_components(g, make_iterator_property_map(c.begin(),
get(&Node::index, g)), boost::color_map( get(&Node::m_algo_color, g) ));
//****modified call******************************
return 0;
}
Detlef