Boost logo

Boost Users :

Subject: Re: [Boost-users] BGL: Get a bundled property for a particular edge_descriptor
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-06-22 16:35:14


On Wed, 22 Jun 2011, David Doria wrote:

> Consider this setup:
>
> struct MyProperty
> {
> int MyIntProperty;
> };
>
> typedef adjacency_list<vecS, vecS, undirectedS, MyProperty, MyProperty> Graph;
>
> Graph g;
>
> Graph::vertex_descriptor v0 = add_vertex(g);
> Graph::vertex_descriptor v1 = add_vertex(g);
> Graph::vertex_descriptor v2 = add_vertex(g);
>
> std::pair<Graph::edge_descriptor, bool> e01 = add_edge(v0, v1, g);
>
> Now I want to get the bundled propery corresponding to e01. I tried this:
>
> property_map<Graph, int MyProperty::*>::type MyIntPropertyMap =
> get(&MyProperty::MyIntProperty, g);
> cout << MyIntPropertyMap[e01.first];

Try g[e01.first].MyIntProperty for direct access; if you want to use get()
with a separate property map, you will need to use the non-bundled syntax
"cout << get(MyIntPropertyMap, e01.first);".

-- Jeremiah Willcock


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net