[BGL] Vertex removal without iterator invalidation?
Yet another question from the BGL newbie... I understand that performing remove_vertex() on graphs with vertexList=vecS will result in invalidated itarors and descriptors for the graph. However, some toy examples i made suggest that if I remove a vertex in such a graph, the vertex descriptors and vertex iterators for vertices with *lower* ID than the removed vertex remain valid after removal, while those for higher ID vertices are invalidated. Is this a true feature of a graph with Vertexlist=vecS, or is my observation a mere coincidence? Is it safe to write code that exploits this "feature"? If it indeed is a feature, I can construct a sorted list of vertices to remove, and remove the vertices in descending order in an easy fashion. If it is not a feature, any suggestions on how to perform this task i.e. removing a list of vertices while keeping the VertexList type vecS? Thanks, Erik
Hi Erik, On Thu, 1 Aug 2002, Erik Arner wrote: yg-boo> yg-boo> Yet another question from the BGL newbie... yg-boo> yg-boo> I understand that performing remove_vertex() on graphs with yg-boo> vertexList=vecS will result in invalidated itarors and descriptors for yg-boo> the graph. yg-boo> yg-boo> However, some toy examples i made suggest that if I remove a vertex in yg-boo> such a graph, the vertex descriptors and vertex iterators for vertices yg-boo> with *lower* ID than the removed vertex remain valid after removal, yg-boo> while those for higher ID vertices are invalidated. yg-boo> yg-boo> Is this a true feature of a graph with Vertexlist=vecS, or is my yg-boo> observation a mere coincidence? Is it safe to write code that exploits yg-boo> this "feature"? Yes, that is indeed a true feature. yg-boo> If it indeed is a feature, I can construct a sorted list of vertices to yg-boo> remove, and remove the vertices in descending order in an easy fashion. That sounds plausible. Cheers, Jeremy ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------
Jeremy Siek wrote:
On Thu, 1 Aug 2002, Erik Arner wrote:
yg-boo> Is this a true feature of a graph with Vertexlist=vecS, or is my yg-boo> observation a mere coincidence? Is it safe to write code that exploits yg-boo> this "feature"?
Yes, that is indeed a true feature.
Great! Saves me alot of headache... I'll have my hands on the book in a few days, so hopefully I won't have to bother you so much in the future :-) Thanks, Erik
participants (2)
-
Erik Arner
-
Jeremy Siek