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


Hi,

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[v].zipcodes.push_back(12180);
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?

suresh

That example uses bundled properties (http://www.boost.org/doc/libs/1_41_0/libs/graph/doc/bundles.html) 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_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

      



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