Boost C++ Libraries: Ticket #7398: edge weights equal to distance_inf not correctly supported in dijkstra https://svn.boost.org/trac10/ticket/7398 <p> The way that the relax() function works in relax.hpp is such that an edge_weight of distance_inf will not be consider for a shortest path. </p> <p> The can lead to the false conclusion that vertices connected only through infinite cost edge are not connected at all. </p> <p> This bug is related to <a class="new ticket" href="https://svn.boost.org/trac10/ticket/7387" title="#7387: Patches: marginal improvements to dijkstra_shortest_paths (new)">#7387</a> and <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7226" title="#7226: Bugs: relax() in relax.hpp can return false even if predecessor map is changed (closed: fixed)">#7226</a>. The patch of <a class="new ticket" href="https://svn.boost.org/trac10/ticket/7387" title="#7387: Patches: marginal improvements to dijkstra_shortest_paths (new)">#7387</a> also solves this problem. </p> <p> I am attaching an example with failing assertion. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7398 Trac 1.4.3 Alex Hagen-Zanker <ahh34@…> Fri, 21 Sep 2012 09:47:21 GMT attachment set https://svn.boost.org/trac10/ticket/7398 https://svn.boost.org/trac10/ticket/7398 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">main.cpp</span> </li> </ul> <p> example of failing assert </p> Ticket Alex Hagen-Zanker <ahh34@…> Fri, 21 Sep 2012 09:53:03 GMT summary changed https://svn.boost.org/trac10/ticket/7398#comment:1 https://svn.boost.org/trac10/ticket/7398#comment:1 <ul> <li><strong>summary</strong> <span class="trac-field-old">edge weights equal to distance_inf lead not correctly supported in dijkstra</span> → <span class="trac-field-new">edge weights equal to distance_inf not correctly supported in dijkstra</span> </li> </ul> Ticket Jeremiah Willcock Fri, 21 Sep 2012 14:42:26 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7398#comment:2 https://svn.boost.org/trac10/ticket/7398#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">invalid</span> </li> </ul> <p> This is the intended behavior -- the graph logically is assumed to have all edges, with some of those (the ones that are not connected in the graph's topology) having infinite weight. See <a class="ext-link" href="http://cpsc.ualr.edu/srini/DM/chapters/review5.3.html"><span class="icon">​</span>http://cpsc.ualr.edu/srini/DM/chapters/review5.3.html</a> for an example; it is commonly used for shortest path algorithms. Thus, infinite-weight edges are treated as not existing at all since they are the same in the matrix representation. If you want an edge to be treated as active, give it a weight less than infinity. A scheme such as the one described at <a class="ext-link" href="http://tex.stackexchange.com/questions/21022/what-is-the-difference-between-fil-and-fill"><span class="icon">​</span>http://tex.stackexchange.com/questions/21022/what-is-the-difference-between-fil-and-fill</a> will give you multiple levels of "infinity" to use for edge weights and path lengths. </p> Ticket Alex Hagen-Zanker <ahh34@…> Fri, 21 Sep 2012 15:50:27 GMT <link>https://svn.boost.org/trac10/ticket/7398#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7398#comment:3</guid> <description> <p> Ok.It does not seem like a very robust way of ignoring edges. It feels wrong to me to not filter out non-edges at the outer-loop of the algorithm but to do at the most detailed levels of computation. Even having to redefine the plus operations. Do you not use filtered_graph for that? How about measures like in-degree and out-degree, won't you get the wrong numbers? How about the visitors that are called along the way won't they get issued with mis-information? For instance vertices may now be discovered even when they are not reachable. The documentation says that "each reachable vertex is discovered exactly once". But it does not tell us that unreachable vertices may also be discovered. </p> <p> <a href="http://www.boost.org/doc/libs/1_51_0/libs/graph/doc/dijkstra_shortest_paths.html">http://www.boost.org/doc/libs/1_51_0/libs/graph/doc/dijkstra_shortest_paths.html</a> </p> <p> Anyway the use of edge weights invalidates quite a bit of my comments in <a class="new ticket" href="https://svn.boost.org/trac10/ticket/7387" title="#7387: Patches: marginal improvements to dijkstra_shortest_paths (new)">#7387</a>, but I suppose you figured that already. </p> <p> Sorry to ramble, it just seems very wrong to me. </p> </description> <category>Ticket</category> </item> <item> <author>Alex Hagen-Zanker <ahh34@…></author> <pubDate>Fri, 21 Sep 2012 16:14:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7398#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7398#comment:4</guid> <description> <p> The following is also not correct: </p> <p> "... only those vertices in V - S that are discovered and therefore have a distance less than infinity..." </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Sat, 22 Sep 2012 19:21:41 GMT</pubDate> <title>resolution changed https://svn.boost.org/trac10/ticket/7398#comment:5 https://svn.boost.org/trac10/ticket/7398#comment:5 <ul> <li><strong>resolution</strong> <span class="trac-field-old">invalid</span> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/80637" title="Added wording that infinite-weight edges are not guaranteed to work ...">[80637]</a>) Added wording that infinite-weight edges are not guaranteed to work correctly; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7398" title="#7398: Bugs: edge weights equal to distance_inf not correctly supported in dijkstra (closed: fixed)">#7398</a> </p> Ticket