
On 29 December 2011 15:16, Kelvin Chung <kelvSYC@mac.com> wrote:
Suppose I have the following:
template <class T> class Graph { // Adapter class that I use for my purposes typedef typename boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, T> innerGraph; typedef typename boost::graph_traits<innerGraph>::vertex_descriptor VertexDescriptor;
innerGraph G; public: void addVertex(const T& vertex); bool containsVertex(const T& vertex) const;
void addEdge(const T& from, const T& to); // More stuff here };
The intent of this adapter class is to basically abstract out all the mentions of stuff like the descriptors and such. So a good helper function to this end would be a function that retrieves the VertexDescriptor for a given T, if it exists. Is there such a function already in the BGL, or do I have to manage that separately (ie. having an external map)?
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
How about storing the descriptor in the T object, by having a member like VertexDescriptor descriptor; ? Constant-time retrieval is guaranteed, but then you have to typedef VertexDescriptor in your T. Alternatively, you can have it globally defined. Best regards, Nicholas