A few questions about the chart in the BGL documentation labeled "Summary of Descriptor and Iterator Invalidation":
Thanks!
All of these effects follow from the usual Iterator invalidation rules
- Why does adding an edge invalidate the edge and adjacency iterators; why isn't every column of the add_edge() row "OK"? Wouldn't the in/out edge lists simply be appended?
Yes they would be appended. And, seeing that they might reallocate doing so, they invalidate iterators.
- Why does removing an edge only invalidate an edge iterator if the graph is directed
The notation in the matrix is more than a little confusing.
Docs: "This operation causes any outstanding edge descriptors or iterators that point to edge (u,v)
to become invalid. In addition, if the OutEdgeList
selector is vecS
then this operation will invalidate any iterators that point into the edge-list for vertex u
and also for vertex v
in the undirected and bidirectional case. Also, for directed graphs this invalidates any edge_iterator
."
So you misread: it doesn't only invalidate "if the graph is directed". It also invalidates any iterators that point into the edge-list for the target vertex (v
) in the undirected and bidirectional case. This makes sense if you realize how the back-edged are stored.