accessing internal graph properties via vertex-iterators directly?
Hello there!
First of all thanks a lot for the rapid response of my last question. I
got another question concerning the access of internal graph properties:
To access a bundeled vertice internal properties of a graph one has to
use the following syntax:
struct VertStruct {
int stuff;
};
typedef adjacency_list
On Nov 29, 2004, at 9:17 AM, Sebastian Weber wrote:
(*vi).stuff = 4;
With this, one would save a lookup in the data-structures and the vertice-iterator concept would be far more logic to me, concernig internal property handling. [snip]
I don't know the BGL internals and how this behaviour is optimally programmed with the BGL. [snip] I hope my point is clear.
We considered this syntax (you might be able to find the discussion on the Boost developers list; GMane is running a bit slow for me at the moment). The basic problem is that we would need both const- and non-const vertex and edge descriptors (because the constness of the internal properties is now tied to the descriptors), which then means that we need const vertex iterators, const edge iterators, const out iterators, etc... it would very quickly become a nightmare for users and developers alike, because we would have twice as many iterator and descriptor types to deal with. On the performance side, it would make copying descriptors more expensive (e.g., with VertexListS=vecS, a vertex descriptor is just an integer; it would have to go to _at least_ a pointer). On the other side, I don't see that this would help performance much when accessing internal properties. Doug
We considered this syntax (you might be able to find the discussion on the Boost developers list; GMane is running a bit slow for me at the moment). The basic problem is that we would need both const- and
actually I do not unterstand that point, but well, I guess I am to new to the BGL to get that.
On the performance side, it would make copying descriptors more expensive (e.g., with VertexListS=vecS, a vertex descriptor is just an integer; it would have to go to _at least_ a pointer). On the other side, I don't see that this would help performance much when accessing internal properties.
Well, it does help! Since I got a workaround to that problem: I checked the code of the adjacency_list.hpp a bit and got the idea how I can save the boost_graph[vertex_descriptor] lookup to my desired internal property object: by storing pointers to just that returned object, which is of type Spot* in my example. This works great and speeds up my application at least a bit. If you are interested in some code, you are surely welcome. Greetings, Sebastian Weber
participants (2)
-
Doug Gregor
-
Sebastian Weber