Boost C++ Libraries: Ticket #10231: [graph] finish_edge seems never to get called in depth_first_search https://svn.boost.org/trac10/ticket/10231 <p> The subject says everything. </p> <p> Attached is a MWE. It implements a dfs-visitor that should output something each time an edge is finished, but it doesn't. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10231 Trac 1.4.3 Alex <alxlaus@…> Wed, 23 Jul 2014 11:19:22 GMT attachment set https://svn.boost.org/trac10/ticket/10231 https://svn.boost.org/trac10/ticket/10231 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">finish_edge_bug.cpp</span> </li> </ul> <p> MWE showing that finish_edge never gets called. </p> Ticket Alex <alxlaus@…> Fri, 25 Jul 2014 13:03:32 GMT <link>https://svn.boost.org/trac10/ticket/10231#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10231#comment:1</guid> <description> <p> Hard-wiring the call to finish_edge actually shows that the logic behind it in depth_first_visit is buggy. In the MWE above, the edge (1,2) gets finished two times, for example. </p> </description> <category>Ticket</category> </item> <item> <author>edwin.carlinet@…</author> <pubDate>Fri, 15 Aug 2014 09:49:26 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10231#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10231#comment:2</guid> <description> <p> Look like a duplicate of <a class="new ticket" href="https://svn.boost.org/trac10/ticket/9770" title="#9770: Bugs: Finish_edge event misbehavior. (new)">#9770</a> (ticket). Does the patch given in <a class="new ticket" href="https://svn.boost.org/trac10/ticket/9770#comment:1" title="#9770: Bugs: Finish_edge event misbehavior. (new)">ticket:9770#comment:1</a> solve your problem? </p> </description> <category>Ticket</category> </item> <item> <author>Alex <alxlaus@…></author> <pubDate>Sat, 16 Aug 2014 09:11:31 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10231#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10231#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10231#comment:2" title="Comment 2">edwin.carlinet@…</a>: </p> <blockquote class="citation"> <p> Look like a duplicate of <a class="new ticket" href="https://svn.boost.org/trac10/ticket/9770" title="#9770: Bugs: Finish_edge event misbehavior. (new)">#9770</a> (ticket). Does the patch given in <a class="new ticket" href="https://svn.boost.org/trac10/ticket/9770#comment:1" title="#9770: Bugs: Finish_edge event misbehavior. (new)">ticket:9770#comment:1</a> solve your problem? </p> </blockquote> <p> It might (partly), but I didn't try (see below for the reason). </p> <p> First, the main point of this bug is that the code making finish_edge optional to the visitor seems to be broken, at least in my quite old environment (Ubuntu 12.10 and gcc 4.7.2). As far as I can see, the implementation using BOOST_TTI_HAS_MEMBER_FUNCTION(finish_tree_edge) does not work. Testing it in an minimal example showed that it claims there is no finish_tree_edge member function even though there is. So the problem probably actually does not lie in the Graph library itself, but in the TTI library it uses. I had a look into that, but it is quite convoluted macro-code and I gave up on fixing that properly. Should I file a new bug to get the attention of the TTI developers? </p> <p> Second, I didn't try the patch, because I think the problem lies elsewhere: The call of finish_tree_edge is dislocated. It should be right after the pop of the edge (think of the 'pop' of the edge as 'returning' (in the original recursive implementation) back over the edge). This is solved in this pull request: <a class="ext-link" href="https://github.com/boostorg/graph/pull/16"><span class="icon">​</span>https://github.com/boostorg/graph/pull/16</a> </p> </description> <category>Ticket</category> </item> <item> <author>Alex <alxlaus@…></author> <pubDate>Fri, 22 Aug 2014 12:23:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10231#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10231#comment:4</guid> <description> <p> I just noticed I should have mentioned: I'm using Ubuntu 12.10 with gcc 4.7.2. </p> </description> <category>Ticket</category> </item> <item> <author>Alex <alxlaus@…></author> <pubDate>Mon, 25 Aug 2014 08:34:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10231#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10231#comment:5</guid> <description> <p> "finish_edge" is meant wherever "finish_tree_edge" is said, of course. </p> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10231#comment:3" title="Comment 3">Alex &lt;alxlaus@…&gt;</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10231#comment:2" title="Comment 2">edwin.carlinet@…</a>: </p> <blockquote class="citation"> <p> Look like a duplicate of <a class="new ticket" href="https://svn.boost.org/trac10/ticket/9770" title="#9770: Bugs: Finish_edge event misbehavior. (new)">#9770</a> (ticket). Does the patch given in <a class="new ticket" href="https://svn.boost.org/trac10/ticket/9770#comment:1" title="#9770: Bugs: Finish_edge event misbehavior. (new)">ticket:9770#comment:1</a> solve your problem? </p> </blockquote> <p> It might (partly), but I didn't try (see below for the reason). </p> <p> First, the main point of this bug is that the code making finish_edge optional to the visitor seems to be broken, at least in my quite old environment (Ubuntu 12.10 and gcc 4.7.2). As far as I can see, the implementation using BOOST_TTI_HAS_MEMBER_FUNCTION(finish_tree_edge) does not work. Testing it in an minimal example showed that it claims there is no finish_tree_edge member function even though there is. So the problem probably actually does not lie in the Graph library itself, but in the TTI library it uses. I had a look into that, but it is quite convoluted macro-code and I gave up on fixing that properly. Should I file a new bug to get the attention of the TTI developers? </p> <p> Second, I didn't try the patch, because I think the problem lies elsewhere: The call of finish_tree_edge is dislocated. It should be right after the pop of the edge (think of the 'pop' of the edge as 'returning' (in the original recursive implementation) back over the edge). This is solved in this pull request: <a class="ext-link" href="https://github.com/boostorg/graph/pull/16"><span class="icon">​</span>https://github.com/boostorg/graph/pull/16</a> </p> </blockquote> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 09 Nov 2014 00:08:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10231#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10231#comment:6</guid> <description> <p> I just pushed a fix to develop for this. Can you please check that finish_edge is now getting called correctly? </p> </description> <category>Ticket</category> </item> <item> <author>alxlaus@…</author> <pubDate>Tue, 11 Nov 2014 10:53:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10231#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10231#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/10231#comment:6" title="Comment 6">anonymous</a>: </p> <blockquote class="citation"> <p> I just pushed a fix to develop for this. Can you please check that finish_edge is now getting called correctly? </p> </blockquote> <p> It doesn't. I hard-coded the finish_edge-call to work around that it never gets called at all. Then it outputs the following, which is clearly wrong as the edge (1,2) gets finished twice. </p> <p> The example graph:<br /> 0 --&gt; 1 2 <br /> 1 --&gt; 2 <br /> 2 --&gt; 0 <br /> finish_edge: (2,0)<br /> finish_edge: (1,2)<br /> finish_edge: (1,2)<br /> finish_edge: (0,2)<br /> finish_edge: (0,1)<br /> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Noel Belcourt</dc:creator> <pubDate>Tue, 11 Nov 2014 19:42:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10231#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10231#comment:8</guid> <description> <p> I just pushed this test case (slightly modified) to develop. Once we fix where the finish_edge event point is called, we'll update this test to check for correctness, right now we know the output is incorrect. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Noel Belcourt</dc:creator> <pubDate>Sun, 01 May 2016 20:14:16 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10231#comment:9 https://svn.boost.org/trac10/ticket/10231#comment:9 <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> I just pushed your github PR, the output is now correct: </p> <p> kbelco$ ./finish_edge_bug </p> <p> The example graph: 0 --&gt; 1 2 1 --&gt; 2 2 --&gt; 0 finish_edge: (2,0) finish_edge: (1,2) finish_edge: (0,1) finish_edge: (0,2) </p> <p> We'll have to monitor tests and fix older compilers that can't handle this code. Thanks for the bug report. </p> Ticket