Boost C++ Libraries: Ticket #7869: boost::in_edges bug https://svn.boost.org/trac10/ticket/7869 <p> The following code will generate an exception in Visual Studio 2010: </p> <pre class="wiki">#include &lt;boost/graph/adjacency_list.hpp&gt; #include &lt;iostream&gt; int main() { typedef boost::adjacency_list&lt; boost::listS, boost::vecS, boost::bidirectionalS&gt; graph_t; graph_t myGraph; graph_t::vertex_descriptor v1 = boost::add_vertex(myGraph); graph_t::vertex_descriptor v2 = boost::add_vertex(myGraph); boost::remove_vertex(v1, myGraph); boost::graph_traits&lt;graph_t&gt;::in_edge_iterator itEdge, itEnd; boost::tie(itEdge, itEnd) = boost::in_edges(v2, myGraph); for(; itEdge != itEnd; ++itEdge) { std::cout &lt;&lt; boost::source(*itEdge, myGraph) &lt;&lt; std::endl; } return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7869 Trac 1.4.3 Jeremiah Willcock Tue, 08 Jan 2013 20:55:33 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7869#comment:1 https://svn.boost.org/trac10/ticket/7869#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> When you remove the vertex <code>v1</code>, the vertex descriptor <code>v2</code> is invalidated and thus no longer usable in operations such as <code>in_edges</code>. See the <strong>"Iterator and Descriptor Stability/Invalidation"</strong> section of <a href="http://www.boost.org/libs/graph/doc/adjacency_list.html">http://www.boost.org/libs/graph/doc/adjacency_list.html</a> for more information. One fix is to set your vertex container to <code>listS</code> instead of <code>vecS</code>. </p> Ticket