BGL: Vertex or Vertex& ?
I've just started using the Boost Graph Library (which is proving to be a very nice tool) and I've encountered an issue: When vertex descriptors are passed as parameters, stored in vectors, etc., is it better to use Vertex&, or is Vertex alone okay. I've been assuming that a vertex descriptor is probably a pointer, so I've been using Vertex. But then is occurred to me that my assumption could be all wrong and I should be using Vertex&. Here are the Graph, Vertex, and Edge definitions I've been using: typedef adjacency_list < vecS, // edge container type vecS, // vertex container type undirectedS, VertexProperties, EdgeProperties, GraphProperties
Graph;
typedef graph_traits<Graph>::vertex_descriptor Vertex; typedef graph_traits<Graph>::edge_descriptor Edge; Roger House
I've just started using the Boost Graph Library (which is proving to be a very nice tool) and I've encountered an issue: When vertex descriptors are passed as parameters, stored in vectors, etc., is it better to use Vertex&, or is Vertex alone okay. I've been assuming that a vertex descriptor is probably a pointer, so I've been using Vertex. But then is occurred to me that my assumption could be all wrong and I should be using Vertex&. Here are the Graph, Vertex, and Edge definitions I've been using:
Surprise... it's an integer :) But only if you use vecS to select your VertexSet. Otherwise, you're right. It's a pointer. Unless it's an edge descriptor, and then it can be a pair of vertex descriptors (which are int's or pointers). Unless you're using the PBGL (parallel version) and then I think they're something different altogether. However it works, it is convention to pass descriptors by value. Andrew Sutton andrew.n.sutton@gmail.com
participants (2)
-
Andrew Sutton
-
Roger House