[BGL] Issue using connected_components

Hi, here is a simplified code sample that I cannot get to work. I use bundled properties for an undirected graph and I do not find what should be the type of the component map (or property map) that should be passed as the second argument of the connected_components function. The sample is useless since only integers are for vertices. #include <boost/graph/adjacency_list.hpp> #include <boost/shared_ptr.hpp> #include <boost/graph/connected_components.hpp> using namespace boost; using namespace std; struct FeatureTrajectory { int id; }; struct FeatureConnection { float minDistance; float maxDistance; }; struct VertexInformation { shared_ptr<FeatureTrajectory> feature; }; typedef adjacency_list < listS, listS, undirectedS, VertexInformation, FeatureConnection> FeatureGraph; int main() { FeatureGraph g; FeatureGraph::vertex_descriptor u, v; FeatureGraph::edge_descriptor e; u = add_vertex(g); v = add_vertex(g); bool unused; tie(e, unused) = add_edge(u, v, g); g[e].minDistance = 0.; g[e].maxDistance = 1.; g[u].feature = shared_ptr<FeatureTrajectory>(new FeatureTrajectory()); g[u].feature->id =11; g[v].feature = shared_ptr<FeatureTrajectory>(new FeatureTrajectory()); g[v].feature->id =12; cout << num_vertices(g) << " " << num_edges(g) << endl; vector_property_map< graph_traits<FeatureGraph>::vertices_size_type > components(num_vertices(g)); int num = connected_components(g, &components[0]); return 0; } The final error is: /usr/include/boost/graph/connected_components.hpp:46: error: no matching function for call to ‘put(long unsigned int*&, void*&, long unsigned int&)’ Can someone help me get it to work and to understand property maps? Thanks! Nicolas -- Nicolas Saunier, ing. jr, Ph.D. Professeur Adjoint / Assistant Professor Département des génies civil, géologique et des mines (CGM) École Polytechnique de Montréal http://nicolas.saunier.confins.net

On Wed, 7 Dec 2011, Nicolas Saunier wrote:
Hi,
here is a simplified code sample that I cannot get to work. I use bundled properties for an undirected graph and I do not find what should be the type of the component map (or property map) that should be passed as the second argument of the connected_components function. The sample is useless since only integers are for vertices.
The normal vector_property_map class does not work for adjacency_list graphs with a listS vertex container unless you define a vertex_index_map. Is there a reason you can't use vecS as the vertex container in your graph? If you truly need listS, you will need to create a vertex index map, fill it in before you create the property map, and pass it to the vector_property_map constructor (and as a type argument to that class). -- Jeremiah Willcock
participants (2)
-
Jeremiah Willcock
-
Nicolas Saunier