Boost C++ Libraries: Ticket #11137: Bug in graph/dijkstra_shortest_paths_no_color_map.hpp https://svn.boost.org/trac10/ticket/11137 <p> Hi, </p> <p> I'm a new user to Boost Graph Library and I'm just start to figure out how to use it. So I apologize if I'm wrong. </p> <p> While testing dijkstra algorithm, I found a possible bug in graph/dijkstra_shortest_paths_no_color_map.hpp. </p> <p> In function dijkstra_shortest_paths_no_color_map_no_init, the code does not initialize distance_map[start_vertex] to 0 before push it into vertex_queue, as the document says here <a href="http://www.boost.org/doc/libs/1_57_0/libs/graph/doc/dijkstra_shortest_paths_no_color_map.html">http://www.boost.org/doc/libs/1_57_0/libs/graph/doc/dijkstra_shortest_paths_no_color_map.html</a> </p> <p> So this will always return at the start vertex if the distance_map is initialized to infinity: </p> <pre class="wiki">if (!distance_compare(min_vertex_distance, distance_infinity)) { // This is the minimum vertex, so all other vertices are unreachable return; } </pre><p> Hui Xiao </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11137 Trac 1.4.3 anonymous Tue, 24 Mar 2015 13:11:14 GMT <link>https://svn.boost.org/trac10/ticket/11137#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11137#comment:1</guid> <description> <p> Replying to <a class="new ticket" href="https://svn.boost.org/trac10/ticket/11137" title="#11137: Bugs: Bug in graph/dijkstra_shortest_paths_no_color_map.hpp (new)">hokix@…</a>: </p> <blockquote class="citation"> <p> Hi, </p> <p> I'm a new user to Boost Graph Library and I'm just start to figure out how to use it. So I apologize if I'm wrong. </p> <p> While testing dijkstra algorithm, I found a possible bug in graph/dijkstra_shortest_paths_no_color_map.hpp. </p> <p> In function dijkstra_shortest_paths_no_color_map_no_init, the code does not initialize distance_map[start_vertex] to 0 before push it into vertex_queue, as the document says here <a href="http://www.boost.org/doc/libs/1_57_0/libs/graph/doc/dijkstra_shortest_paths_no_color_map.html">http://www.boost.org/doc/libs/1_57_0/libs/graph/doc/dijkstra_shortest_paths_no_color_map.html</a> </p> <p> So this will always return at the start vertex if the distance_map is initialized to infinity: </p> <pre class="wiki">if (!distance_compare(min_vertex_distance, distance_infinity)) { // This is the minimum vertex, so all other vertices are unreachable return; } </pre><p> Hui Xiao </p> </blockquote> <p> I'm sorry, I didn't notice that the initialization is in function dijkstra_shortest_paths_no_color_map and I have to init distance_map[start_vertex] to 0 myself. </p> </description> <category>Ticket</category> </item> </channel> </rss>