Boost C++ Libraries: Ticket #1622: Adjacency list needs to handle self-edges correctly https://svn.boost.org/trac10/ticket/1622 <p> The following short program crashes as of boost 1.35: </p> <p> #include &lt;boost/graph/adjacency_list.hpp&gt; </p> <p> int main() { </p> <blockquote> <p> using namespace boost; typedef adjacency_list&lt;vecS, vecS, undirectedS &gt; graph_t; graph_t g(5); add_edge(2, 2, g); remove_edge(2, 2, g); </p> </blockquote> <p> } </p> <p> The problem is that (2,2) is stored once in the list of edges in the graph and twice in the list of adjacent edges to the vertex 2. When remove_edge is called, the global graph edge (2,2) is deleted twice, causing a segfault. This problem is discussed in the following thread: <a class="ext-link" href="http://lists.boost.org/Archives/boost/2007/02/116547.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2007/02/116547.php</a>. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1622 Trac 1.4.3 Aaron Windsor Sun, 10 Feb 2008 21:11:28 GMT status changed https://svn.boost.org/trac10/ticket/1622#comment:1 https://svn.boost.org/trac10/ticket/1622#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Andrew Sutton Mon, 08 Dec 2008 15:39:54 GMT owner, status changed https://svn.boost.org/trac10/ticket/1622#comment:2 https://svn.boost.org/trac10/ticket/1622#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Aaron Windsor</span> to <span class="trac-author">Andrew Sutton</span> </li> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">new</span> </li> </ul> <p> Removing the loop using remove_edge(e, g) does not seem to trigger the same segfault. </p> Ticket Andrew Sutton Mon, 08 Dec 2008 19:03:22 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1622#comment:3 https://svn.boost.org/trac10/ticket/1622#comment:3 <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">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/50206" title="Fixed #1622. A viable solution relies on the fact that incident edges ...">[50206]</a>) Fixed <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/1622" title="#1622: Bugs: Adjacency list needs to handle self-edges correctly (closed: fixed)">#1622</a>. A viable solution relies on the fact that incident edges in a loop are stored adjacently in the out edge list of the vertex. A simple modification of the global edge erasing loop for undirected graphs will skip the next iterator if both the current and next contain the same iterator. </p> Ticket