$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2005-05-18 21:28:23
On May 13, 2005, at 4:53 AM, Martin Magnusson wrote:
> I am sometimes getting segmentation faults (using gcc 3.3.4 under 
> Cygwin) in calls to add_vertex( g ), where g is of the following type:
>   boost::adjacency_list
>     < boost::setS,
>       boost::vecS,
>       boost::undirectedS,
>       Vertex_Properties,
>       Edge_Length >
>
> This happens when I try to merge two graphs with repeated calls to 
> add_vertex (not updating edges or anything, just adding new vertices), 
> and usually when the returned index from add_vertex is around 
> 40000-50000, but it depends on the data. Creating a single graph with 
> more than 50000 vertices in one go is not a problem.
>
> Does anyone have an idea of what is going on in add_vertex, and what 
> could be the problem here?
That's really strange... add_vertex is essentially just a push_back on 
the vector. Are you iterating over the vertices while calling 
add_vertex? You mention automatic resizing below: if the resizing did 
happen, it could invalidate the vertex_iterators into the graph, and 
might cause a crash.
>  I suspect it has something to do with the automatic resizing of the 
> internal vector used to store the vertices. Is there a way to reserve 
> memory in advance for this?
No "real" way, but the the "m_vertices" member of adjacency_list stores 
the vector of vertices, so you could call reserve() on it. In theory, 
the name could change in future releases, but it's unlikely to happen 
for a very long time :)
        Doug