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-03 12:02:45

On Thu, 3 Nov 2011, ShNaYkHs ShNaYkHs wrote:

> Thanks for your answer, now after adding this associative property map,
> should I care about any problem with the vertex/edge iterator stability or
> invalidation (like it is the case for vecS) if I use the method described
> here
> next etc) ?

If you are adding or removing vertices, you will need to regenerate the
vertex numbering each time you call an algorithm that needs the vertex
index map (mostly to make sure the numbers are contiguous). If you are
just adding vertices, you can give them consecutive numbers without any
trouble. I think listS vertex descriptors are stable when other vertices
are added or removed, so invalidation of the descriptors themselves is not
likely to be a problem.

-- Jeremiah Willcock

> 2011/11/2 Jeremiah Willcock <jewillco_at_[hidden]>
>> 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
>> ______________________________**_________________
>> Unsubscribe & other changes:**
>> mailman/listinfo.cgi/boost<>
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at