Boost C++ Libraries: Ticket #4731: Documentation for dijkstra shortest path is wrong https://svn.boost.org/trac10/ticket/4731 <p> In the documentation for dijkstra_shortest_paths, you can read: </p> <p> "The predecessor map records the edges in the minimum spanning tree. Upon completion of the algorithm, the edges (p[u],u) for all u in V are in the minimum spanning tree." </p> <p> I would say, that this is wrong: Dijkstra won't give you a minimum spanning tree in all cases. </p> <p> One counterexample would be a undirected graph with the vertices (0,1,2) and the following edges (format is start,point, endpoint, weight): </p> <p> (0, 1, 2) (0, 2, 3) (1, 2, 4) </p> <p> This graph has only one minimum spanning tree with the predecessors map (2,0,2) - which is what you get with prim. If you execute dijkstra shortest path on this graph, you will get (2,2,2) - and this is not a minimum spanning tree (since the weight of this tree is 7, while the weight of the minimum spanning tree is 5). </p> <p> Find attached an example which calculates both algorithms on these two graphs. I really think this should be fixed in the documentation. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4731 Trac 1.4.3 Markus Pilman <mpilman@…> Wed, 13 Oct 2010 10:36:29 GMT attachment set https://svn.boost.org/trac10/ticket/4731 https://svn.boost.org/trac10/ticket/4731 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bug.cpp</span> </li> </ul> <p> Implementation of the example described in the bug report </p> Ticket Andrew Sutton Wed, 13 Oct 2010 13:47:57 GMT <link>https://svn.boost.org/trac10/ticket/4731#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4731#comment:1</guid> <description> <p> I agree. The search tree computed by SP algorithm is not guaranteed to be a MST. Updated the documentation to describe the results in terms of a "search tree" with a statement claiming that it is not guaranteed to be an MST. </p> <p> Changes in <a class="changeset" href="https://svn.boost.org/trac10/changeset/65939" title="Clarifying references to MST in Dijkstra's SP algorithm. ">r65939</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrew Sutton</dc:creator> <pubDate>Wed, 13 Oct 2010 13:48:20 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4731#comment:2 https://svn.boost.org/trac10/ticket/4731#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> Ticket andresbuehlmann@… Thu, 14 Oct 2010 14:35:33 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/4731#comment:3 https://svn.boost.org/trac10/ticket/4731#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> The term "search tree" used in the current fix is misleading/imprecise depending how you define "search tree". Either use a term like "fully relaxed search tree" or another term like "spanning tree describing all shortest paths from the specified start vertex". </p> <p> Observe that the spanning tree encoded in the predecessor map describes the shortest path to every vertex in the graph from the defined start vertex. This is usually NOT equal to the "search tree" describing the order in which dijkstra explored the edges (without applying relaxation to this tree). </p> <p> To observe the difference between "fully relaxed search tree" and "search tree" the following example: </p> <p> Given a graph on vertices {0, 1, 2} and edges (0, 1, 2), (1, 2, 4), (0, 2, 3) where the format is (start point, end point, weight). </p> <p> For running dijkstra on it with start vertex 1: </p> <ul><li>The "Search tree" in my eyes would be (1, 1, 0) (to be read as the predecessor map) </li><li>The predecessor map (result of dijkstra) is: (1, 1, 1) </li></ul> Ticket Andrew Sutton Thu, 14 Oct 2010 15:38:20 GMT <link>https://svn.boost.org/trac10/ticket/4731#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4731#comment:4</guid> <description> <p> It may be the case that such descriptions are more precise, but I feel that they are unnecessary. I may consider redefining it as "the tree computed by the algorithm" rather than "traversal", but I'm not going to try to be more specific. </p> <p> The reason is that those specific properties of the tree are imposed by the completion of the algorithm--not guaranteed by tree itself. If the algorithm fails to complete or is terminated early, by exception for example, neither description would be correct. However, a search tree on input will still be a search tree on output, regardless of the termination state of the algorithm. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Thu, 14 Oct 2010 19:02:06 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4731#comment:5 https://svn.boost.org/trac10/ticket/4731#comment:5 <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/65964" title="Clarified docs further; fixes #4731">[65964]</a>) Clarified docs further; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4731" title="#4731: Bugs: Documentation for dijkstra shortest path is wrong (closed: fixed)">#4731</a> </p> Ticket Jeremiah Willcock Tue, 19 Oct 2010 15:28:59 GMT <link>https://svn.boost.org/trac10/ticket/4731#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4731#comment:6</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66093" title="Merged changes r65193, r65939, r65963, and r65964 from trunk; refs ...">[66093]</a>) Merged changes <a class="changeset" href="https://svn.boost.org/trac10/changeset/65193" title="Fixed page titles">r65193</a>, <a class="changeset" href="https://svn.boost.org/trac10/changeset/65939" title="Clarifying references to MST in Dijkstra's SP algorithm. ">r65939</a>, <a class="changeset" href="https://svn.boost.org/trac10/changeset/65963" title="Fixed documentation of distance map; fixes #4737">r65963</a>, and <a class="changeset" href="https://svn.boost.org/trac10/changeset/65964" title="Clarified docs further; fixes #4731">r65964</a> from trunk; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4731" title="#4731: Bugs: Documentation for dijkstra shortest path is wrong (closed: fixed)">#4731</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4737" title="#4737: Bugs: Documentation for Prim MST concerning distance_map is wrong (closed: fixed)">#4737</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>