
Hi,
In order to understand bundled properties better, I tried to compile
Hi suresh, Actually in the example you gave, there is no vertex in Map. Therefore vertices( map ).first is an iterator pointing to the end of vertices( map ) and accessing this element results in a segmentation violation. You first need to add some vertices by Map::vertex_descriptor v = add_vertex( map ); Then v is a vertex of your graph and you may assign properties to it: map[v].name = "Troy"; Regards Tobias On Tuesday 15 December 2009 08:36:46 am List User wrote: 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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- __________________________ Tobias Columbus t.columbus@gmx.de