[BGL,Graph] bundle and property maps
Hi,
I'm (still) trying to use the strong components algorithm with
a graph storing vertices as a list (listS).
I've learned thanks to this mailing list that I had to explicitely
declare and intialize a vertex_index map.
The declaration of my graph type should
therefore look like that:
typedef adjacency_list
On 11/17/05, Stephane Grabli
Hi,
I'm (still) trying to use the strong components algorithm with a graph storing vertices as a list (listS). I've learned thanks to this mailing list that I had to explicitely declare and intialize a vertex_index map. The declaration of my graph type should therefore look like that:
typedef adjacency_list
> Graph; and the component map should be declared this way: typedef graph_traits<Graph>::vertices_size_type v_size_t; //the range of ComponentMap vector_property_map< v_size_t, property_map
::type> componentMap(num_vertices(g), get(vertex_index,g) ); //g is an instance of Graph I would like to know if there is a way to combine this with the use of bundles. In practice, I used to have this declaration for my graph type:
typedef adjacency_list
Graph; with: struct VertexBundle{ int id; };
How should I merge these two types of declarations? Is there a way to define the required vertex_index as a bundle property and to use it to define my component map afterward? Thanks!
Yes, there is a way... see my answer to your previous thread on the
same subject...
With your example:
strong_components ("your previous arguments",
vertex_index_map (get (&VertexBundle::id, g)))
So the algorithm strong_components uses your property id as a
map
Stephane Grabli wrote:
typedef adjacency_list
Graph; with: struct VertexBundle{ int id; };
How should I merge these two types of declarations? Is there a way to define the required vertex_index as a bundle property and to use it to define my component map afterward?
yes use : struct Node{ int id; int index; } then you can access the vertex property map using get(&Node::index, g)) instead of get (vertex_index,g). Also have a look at http://www.boost.org/libs/graph/doc/bundles.html HTH, -- Grégoire Dooms
participants (3)
-
Grégoire Dooms
-
Johan Oudinet
-
Stephane Grabli