Boost logo

Boost :

Subject: Re: [boost] [BGL] How to provide a vertex_index property for my graph
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-11-02 16:46:39


On Wed, 2 Nov 2011, ShNaYkHs ShNaYkHs wrote:

> Hello,
>
> Since my graph use setS as a VertexList, I have to either provide a
> vertex_index property map for my graph to be able to use some functions
> requiring a vertex_index (e.g. write_graphviz). My graph is defined as:
> typedef adjacency_list<setS, setS, undirectedS, NodeData, EdgeData> Graph;
> Where NodeData and EdgeData are structures. Can you please give me a very
> simple example of how to provide a vertex_index property map for my graph ?
> I mean, since an adjacency_list that uses listS or setS as the vertex
> container does not automatically provide this vertex_id property, how can I
> add it to the code bellow ?
>
> I tried to use an associative_property_map to include index for vertices,
> but it doesn't work (errors):

If you are going to use an associative_property_map, the key type of the
map needs to be your graph's vertex_descriptor type, not vecS (which
probably doesn't have any data members and is just a tag). You can then
pass that property map to algorithms. Alternatively, as stated in the
other reply to your post, you can add a vertex index member (with whatever
name) into your NodeData structure and use that as the property map (e.g.,
using syntax such as "get(&NodeData::index, g)").

-- Jeremiah Willcock


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