BGL: Get a bundled property for a particular edge_descriptor
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]; but the compiler complains about no matching operator[]. Any suggestions? I thought I had examples of all of these simple things, but I guess I'm missing at least one :) David
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
participants (2)
-
David Doria
-
Jeremiah Willcock