Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying vertex properties in a Boost::Graph

I am trying to figure out how to use boost::graph to store some information. However, there is information I want tied to each vertex. Staring at the documentation for the library reveals either(a)badly written documentation, or (b), I'm obviously not as good at C++ as I thought. Pick two.

I am looking for a simple example use.

like image 932
Paul Nathan Avatar asked Mar 22 '09 22:03

Paul Nathan


1 Answers

Bundled properties are straightforward to use:

using namespace boost;  struct vertex_info {      std::string whatever;      int othervalue;      std::vector<int> some_values;  };  typedef adjacency_list<vecS, vecS, undirectedS, vertex_info> graph_t;  graph_t g(n);  g[0].whatever = "Vertex 0";  [...] 

and so on.

Please also refer to the docs.

The other type of vertex property that are very useful are external properties. You can declare std::vectors of the appropriate size and use them as properties.

like image 187
baol Avatar answered Sep 22 '22 02:09

baol