|
Boost Users : |
Subject: [Boost-users] dynamic_properties and std::vector attributes
From: Dominik Dahlem (Dominik.Dahlem_at_[hidden])
Date: 2010-06-11 09:38:09
Hi guys,
the boost graph library has an example on using bundled properties. I
would like to serialise the resulting graph into graphml. Using
dynamic_properties for the std::vector attribute fails to compile with
boost 1.41. Is there a way to get this example below to work? I would
greatly appreciate it.
Thanks,
Dominik
#include <vector>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/property_map/dynamic_property_map.hpp>
struct City
{
std::string name;
int population;
std::vector<int> zipcodes;
};
struct Highway
{
std::string name;
double miles;
int speed_limit;
int lanes;
bool divided;
};
int main()
{
typedef boost::adjacency_list<
boost::listS, boost::vecS, boost::bidirectionalS,
City, Highway> Graph;
Graph g;
Graph::vertex_descriptor v = *vertices(g).first;
g[v].name = "Troy";
g[v].population = 49170;
g[v].zipcodes.push_back(12180);
Graph::edge_descriptor e = *out_edges(v, g).first;
g[e].name = "I-87";
g[e].miles = 10;
g[e].speed_limit = 65;
g[e].lanes = 4;
g[e].divided = true;
boost::dynamic_properties dp;
// dp.property("zip_codes", boost::get(&City::zipcodes, g));
dp.property("name", boost::get(&City::name, g));
return EXIT_SUCCESS;
}
-- Dominik Dahlem <Dominik.Dahlem_at_[hidden]> ------------------------------------------------------- Trinity College Dublin School of Computer Science and Statistics, Dublin 2, Ireland tel: (+353) 1-896 3789 fax: (+353) 1-677 2204 www: http://www.cs.tcd.ie/Dominik.Dahlem/ -------------------------------------------------------
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