Boost logo

Boost Users :

Subject: Re: [Boost-users] [BGL] Finding the descriptor for a given vertex
From: Nicholas Mario Wardhana (mario.wardhana_at_[hidden])
Date: 2011-12-29 10:00:10


On 29 December 2011 15:16, Kelvin Chung <kelvSYC_at_[hidden]> 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_at_[hidden]
> 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


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