Boost C++ Libraries: Ticket #6033: Lowpoint map calculated by biconnected_components(...) is sometimes wrong https://svn.boost.org/trac10/ticket/6033 <p> The lowpoint map calculated by the function biconnected_components(...) is sometimes wrong. </p> <p> The current implementation seems to relink the predecessor map as an indicator that an articulation point has been found. So even though the real parent in the dfs tree of a node u might be the node v, the predecessor map may temporarily claim that w is u's parent. However, this can lead to instances where the if-statement in line 81 of boost/graph/biconnected_components.hpp fails to recognize tree edges from u to its parent v (since it believes w is the parent). Therefore the body of the if-statement is executed and the lowpoint value is updated when it shouldn't, resulting in wrong lowpoint values. </p> <p> To reproduce the problem create an undirected graph with 4 vertices (numbered from 0 to 3) and 4 edges, linked in the following way and start the dfs at node 1: </p> <p> 2-3 1-3 1-2 0-1 </p> <p> Clearly, the lowpoint value of node 1 should be 2 but is computed to be 1. I discovered this bug when trying to find bridges in the graph using those lowpoint values. </p> <p> Attached is working code which exhibits the bug as well as a suggested fix (although in the long term the implementation should not use the hack with the relinking since it could lead to other unwanted behavior). </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6033 Trac 1.4.3 andre.dau@… Wed, 19 Oct 2011 11:51:24 GMT attachment set https://svn.boost.org/trac10/ticket/6033 https://svn.boost.org/trac10/ticket/6033 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">biconnected_components.patch</span> </li> </ul> <p> Suggested patch </p> Ticket andre.dau@… Wed, 19 Oct 2011 11:51:48 GMT attachment set https://svn.boost.org/trac10/ticket/6033 https://svn.boost.org/trac10/ticket/6033 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bug_biconnected_components.cpp</span> </li> </ul> <p> Small program which shows the bug </p> Ticket anonymous Wed, 19 Oct 2011 17:31:01 GMT <link>https://svn.boost.org/trac10/ticket/6033#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6033#comment:1</guid> <description> <p> Someone jsut pointed out, that my fix is not working for multigraphs. Therefore I revoke the fix. But the issue still remains. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Wed, 19 Oct 2011 20:04:00 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6033#comment:2 https://svn.boost.org/trac10/ticket/6033#comment:2 <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/75067" title="Fixed strange use of pred map, and changed algorithm to be more ...">[75067]</a>) Fixed strange use of pred map, and changed algorithm to be more similar to Tarjan paper cited in bibliography; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6033" title="#6033: Bugs: Lowpoint map calculated by biconnected_components(...) is sometimes wrong (closed: fixed)">#6033</a> </p> Ticket jan.hazla@… Thu, 20 Oct 2011 09:20:08 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/6033#comment:3 https://svn.boost.org/trac10/ticket/6033#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">fixed</span> </li> </ul> <p> I don't think you fixed it correctly. </p> <p> Note that when a non-root articulation vertex separates more than two biconnected components, it will be sent to the output iterator more than once. I believe this weird predecessor trick was there exactly to avoid this. </p> <p> I see two possible fixes to this: 1) I believe that if you </p> <blockquote> <p> a) change underlying traversal algorithm from depth_first_search to undirected_dfs (why do you use a directed version for undirected algorithm anyway?), b) completely delete the if statement that Andre modified in his patch, since now undirected_dfs magically takes care of that for us; </p> </blockquote> <p> then the predecessor trick will work correctly. 2) The whole problem stems from the output format insisting on outputting the range of articulation points instead of a map (vertex -&gt; bool) indicating if the vertex is articulating. I guess you won't like changing the interface now, but what you can do is to implement such a map internally and compute the range from it at the very end. In that case you can also get rid of predecessor map, since it's not really necessary in classical Tarjan algorithm implementation. I believe it to be a cleaner solution, but both those changes would be visible in the public interface. </p> Ticket jan.hazla@… Thu, 20 Oct 2011 09:21:55 GMT <link>https://svn.boost.org/trac10/ticket/6033#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6033#comment:4</guid> <description> <p> Sorry for broken formatting, hope it's still readable. </p> </description> <category>Ticket</category> </item> <item> <author>Jan Hazla <jan.hazla@…></author> <pubDate>Sun, 23 Oct 2011 22:26:52 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6033 https://svn.boost.org/trac10/ticket/6033 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">75067_counterexample.cpp</span> </li> </ul> <p> Counterexample that breaks the fix in rev. 75067 </p> Ticket Jan Hazla <jan.hazla@…> Sun, 23 Oct 2011 22:27:36 GMT attachment set https://svn.boost.org/trac10/ticket/6033 https://svn.boost.org/trac10/ticket/6033 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">patchfile.patch</span> </li> </ul> <p> Proposed patch for fixing the lowpoint problem </p> Ticket Jan Hazla <jan.hazla@…> Sun, 23 Oct 2011 22:39:31 GMT <link>https://svn.boost.org/trac10/ticket/6033#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6033#comment:5</guid> <description> <p> I attached: 1) The minimal counterexample that breaks the fix from revision 75067 2) The patch which fixes the problem correctly. </p> <p> It implements the second idea from my comment above - the algorithm creates internally boolean map indicating if the given point is articulating. When the vertex's processing is finished, the map is checked and the vertex is output at most once. The map is implemented as a vector utilizing vertex_index_map, which is needed anyway for the purpose of depth_first_search. Therefore, the change is invisible for the user. </p> <p> This is still incorrect in case of multigraph (ie. parallel edges), which is a shame, because Tarjan's algorithm naturally extends to this case. This issue could be solved with implementation using undirected_dfs instead of depth_first_search. Unfortunately, this would require the user to provide the algorithm with the edge color map, which would be a significant interface change breaking most of the existing user code. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Sat, 03 Mar 2012 20:06:17 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/6033#comment:6 https://svn.boost.org/trac10/ticket/6033#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</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/77186" title="Applied new patch from #6033 from Jan Hazla; fixes #6033">[77186]</a>) Applied new patch from <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6033" title="#6033: Bugs: Lowpoint map calculated by biconnected_components(...) is sometimes wrong (closed: fixed)">#6033</a> from Jan Hazla; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6033" title="#6033: Bugs: Lowpoint map calculated by biconnected_components(...) is sometimes wrong (closed: fixed)">#6033</a> </p> Ticket