[BGL] How to add a vertex_descriptor in a graph property
Hello, I want to make tree class with the BGL and so I need to specify the root of the tree. Previously I did that by deriving a graph and adding a graph_descriptor member like the code below: typedef boost::adjacency_list< boost::listS, boost::listS, boost::directedS, int
Graph;
class Tree : public Graph { public: typedef typename boost::graph_traits< Graph >::vertex_descriptor root; Tree(); }; The constructor create a Vertex then defines root equal to that first vertex. But with bundled property I wanted to know if it is possible to define the root in the graph property. In fact I tried it but I am a bit embarrassed by the cyclic problem: - graph property needs to know what a vertex_descriptor is, - graph needs to know what a graph property is, - graph defines what a vertex_descriptor is. I tried the Barton-Nackman trick but I failed. Is it a proper way to do that ? Some advices, or pointers will be really apreciated. Thanks, Manuel Yguel.
On Aug 19, 2006, at 9:59 AM, Manuel Yguel wrote:
The constructor create a Vertex then defines root equal to that first vertex. But with bundled property I wanted to know if it is possible to define the root in the graph property. In fact I tried it but I am a bit embarrassed by the cyclic problem: - graph property needs to know what a vertex_descriptor is, - graph needs to know what a graph property is, - graph defines what a vertex_descriptor is.
I tried the Barton-Nackman trick but I failed.
Is it a proper way to do that ? Some advices, or pointers will be really apreciated.
Use adjacency_list_traits to get the vertex descriptor type: http://www.boost.org/libs/graph/doc/adjacency_list_traits.html Cheers, Doug
participants (2)
-
Doug Gregor
-
Manuel Yguel