
Andrew Sutton escribió:
In the provided example g.m_vertices.reserve(6) helps.
You're right... That should work - unless you're adding more than 6 vertices.
Maybe we should provide a reserve_vertices(g, n) function for the vertex set on adjacency lists. It's a nice optimization and apparently can help avoid some invalidation. Obviously it only applies to VertexSet == vecS || listS. Thoughts?
Looks like everything works fine with undirected graph, i.e., this code does not lead to segfault: #include <iostream> #include <boost/graph/adjacency_list.hpp> using namespace boost; typedef adjacency_list<listS, vecS, undirectedS > Graph; int main() { Graph g(3); add_edge( 0, 1, g ); add_edge( 1, 2, g ); add_edge( 2, 0, g ); Graph::edge_iterator ei, ei_end; for( tie( ei, ei_end ) = edges( g ); ei != ei_end; ++ei ) { add_vertex( g ); } } Regards, Dmitry