He Folks,
I'm using bundled properties in order to attach multiple attributes
to graph nodes. Using only basic data types like integers, strings
etc. the following example code works well. However I would like
to also use vectors or similar containers (like in the example about
bundled properties at
http://www.boost.org/doc/libs/1_39_0/libs/graph/doc/bundles.html).
However I don't know how to use this field for my dynamic_property map.
In the following code the single commented-out line is the point where
I most probably didn't understand some kind of vital concept.
Maybe you could enlighten me or at least point me in the right direction,
thanks in advance
Richard Vock
---
Here's the example code:
#include <iostream>
#include
#include
#include
struct NodeProperties {
int test;
std::vector<int> ints;
};
int main(int argc, char* argv[]) {
typedef std::pair Edge;
std::vector< Edge > connections;
// create simple edge loop for testing purposes
for (int i=0; i<10; ++i)
connections.push_back( Edge(i,(i+1)%10) );
typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS,
NodeProperties> Graph;
Graph g(connections.begin(), connections.end(), 10);
boost::graph_traits<Graph>::vertex_iterator v, v_end;
for (tie(v,v_end) = vertices(g); v != v_end; ++v) {
Graph::vertex_descriptor desc = *v;
g[desc].test = 10;
for (int i=0; i<5; ++i) g[desc].ints.push_back(i);
}
boost::dynamic_properties dp;
dp.property("test", get(&NodeProperties::test, g));
//dp.property("testInts", get(&NodeProperties::ints, g));
boost::write_graphml(std::cout, g, dp, true);
}