The question is about the Boost Graph Library.
Suppose that we store an object with each vertex of the graph and there is a one-to-one correspondence between the vertices and the objects. Suppose further that we maintain an std::map
to enable looking up a vertex descriptor that corresponds to a given object.
However, this solution seems to be prone to invalidation of vertex descriptors in the case of a vertex being deleted. Is there a way to get around this problem?
In this question, the following sentence appears:
I want to store vertex descriptors in a way that they wont invalidate in case I remove a vertex, so I use boost::listS
It seems like the author of that question has a solution to the problem of vertex invalidation, but I do not understand what it is.
EDIT: to clarify the reason for maintaining a map. The need to look up a vertex based on an object arises in the following scenario. Suppose that we have generated an object. We need to look up a vertex that corresponds to an object that's equal (in the sense of operator==
) to an object that we've just generated.