Boost logo

Boost Users :

Subject: Re: [Boost-users] newbie - graph library - vertex properties
From: List User (listuser_at_[hidden])
Date: 2009-12-15 02:36:46


In order to understand bundled properties better, I tried to compile the example given in the link below. the code is pasted here: it gives a segmentation violation...

using namespace std;
using namespace boost;

struct City
  string name;
  int population;
  vector<int> zipcodes;

struct Highway
  string name;
  double miles;
  int speed_limit;
  int lanes;
  bool divided;
typedef boost::adjacency_list< boost::listS, boost::vecS, boost::bidirectionalS,City, Highway> Map;

int main(){
Map map; // load the map
Map::vertex_descriptor v = *vertices(map).first;
map[v].name = "Troy";
map[v].population = 49170;
Map::edge_descriptor e = *out_edges(v, map).first;
map[e].name = "I-87";
map[e].miles = 10;
map[e].speed_limit = 65;
map[e].lanes = 4;
map[e].divided = true;

How do I add memory for vertices in the above example?


That example uses bundled properties ( which remove the need for the operations you named.

> 3. In the kevin-bacon2.cpp approach for adding new properties to the graph, the vertex_properties are read as
> adjacency_list[vertex_descriptior]. How will have a read only access in such a case? When I use this in a function which is
> defined as const in c++, the compiler cribs :)

A function defined as const, or taking the graph as const? What error do you get?

-- Jeremiah Willcock
Boost-users mailing list


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at