Boost C++ Libraries: Ticket #4793: copy_component does not work for graphs with edges. https://svn.boost.org/trac10/ticket/4793 <p> copy_component operates via a BFS visitor. The visitor adds vertices in examine_vertex and edges in examine_edge. The examine_edge routine assumes that examine_vertex has already been called for both sides of the edges, i.e., that both the source and target vertex have already been added to the copy graph. However, the BFS algorithm calls examine_edge *before* calling examine_vertex for its target. As a result, the target of the added edge is incorrect. </p> <p> Concretely, in 1.44, graph/copy.hpp, line 365, the result of get(orig2copy, target(e,g_in)) will not be defined. I'll attach a simple program that attempts to copy a graph with 2 vertices and 1 edge before them and ends up with the wrong result. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4793 Trac 1.4.3 Christopher Alfeld <calfeld@…> Tue, 26 Oct 2010 17:45:02 GMT attachment set https://svn.boost.org/trac10/ticket/4793 https://svn.boost.org/trac10/ticket/4793 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">copy_component_kaput.cpp</span> </li> </ul> <p> Simple test. </p> Ticket Christopher Alfeld <calfeld@…> Tue, 26 Oct 2010 17:47:53 GMT <link>https://svn.boost.org/trac10/ticket/4793#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4793#comment:1</guid> <description> <p> One possibly fix would be to have tree_edge(e,g) create a vertex for target(e,g) and the edge for e, and have non_tree_edge(e,g) create an edge for e using the already existing target(e,g). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Tue, 26 Oct 2010 17:59:21 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/4793#comment:2 https://svn.boost.org/trac10/ticket/4793#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Andrew Sutton</span> to <span class="trac-author">Jeremiah Willcock</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Jeremiah Willcock Tue, 26 Oct 2010 18:11:30 GMT <link>https://svn.boost.org/trac10/ticket/4793#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4793#comment:3</guid> <description> <p> With the method you suggested, you only need to specifically copy the source vertex since every other vertex in the component is the target of some tree or non-tree edge. Thus, your approach actually simplifies the code further by removing the examine_vertex hook. I am working on fixing this bug the way you suggested. </p> </description> <category>Ticket</category> </item> <item> <author>Christopher Alfeld <calfeld@…></author> <pubDate>Tue, 26 Oct 2010 18:18:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4793#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4793#comment:4</guid> <description> <p> Great! Thank you for the incredibly rapid response. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Tue, 26 Oct 2010 18:24:03 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4793#comment:5 https://svn.boost.org/trac10/ticket/4793#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</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/66203" title="Repaired copy_component() using suggestion from Christopher Alfeld; ...">[66203]</a>) Repaired copy_component() using suggestion from Christopher Alfeld; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4793" title="#4793: Bugs: copy_component does not work for graphs with edges. (closed: fixed)">#4793</a> </p> Ticket Jeremiah Willcock Tue, 26 Oct 2010 18:25:57 GMT <link>https://svn.boost.org/trac10/ticket/4793#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4793#comment:6</guid> <description> <p> Could you please try your code again with the version I just committed to the trunk? Please try valgrind on it as well if you have a platform that supports it. </p> </description> <category>Ticket</category> </item> <item> <author>Christopher Alfeld <calfeld@…></author> <pubDate>Tue, 26 Oct 2010 18:32:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4793#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4793#comment:7</guid> <description> <p> Code does not compile. On line 404, you call copy_one_vertex with a single argument, when it takes two. </p> <p> After fixing that error (adding g_in as the second argument) code runs correctly and valgrind reports no errors. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Tue, 26 Oct 2010 18:37:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4793#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4793#comment:8</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66204" title="Fixed signature of copy_one_vertex(); refs #4793">[66204]</a>) Fixed signature of copy_one_vertex(); refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4793" title="#4793: Bugs: copy_component does not work for graphs with edges. (closed: fixed)">#4793</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Tue, 26 Oct 2010 20:37:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4793#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4793#comment:9</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66206" title="Merged r66203 and r66204 from trunk; refs #4793">[66206]</a>) Merged <a class="changeset" href="https://svn.boost.org/trac10/changeset/66203" title="Repaired copy_component() using suggestion from Christopher Alfeld; ...">r66203</a> and <a class="changeset" href="https://svn.boost.org/trac10/changeset/66204" title="Fixed signature of copy_one_vertex(); refs #4793">r66204</a> from trunk; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4793" title="#4793: Bugs: copy_component does not work for graphs with edges. (closed: fixed)">#4793</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>