Boost C++ Libraries: Ticket #3506: Graph's Tour / Dijkstra's parent nodes https://svn.boost.org/trac10/ticket/3506 <p> In the tour (<a href="http://www.boost.org/doc/libs/1_40_0/libs/graph/doc/quick_tour.html">http://www.boost.org/doc/libs/1_40_0/libs/graph/doc/quick_tour.html</a>), the last step has me going through and finding all the parents of nodes in Dijkstra algorithm. However, the way the default constructor of Vertex() was set up, it could not find vertex 0 when the parent is 0. Specifically, p[*vi] == Vertex() returned true, when the parent was zero and when there is no parent. </p> <p> There are two ways to look at this problem. </p> <p> First, it is not a bug. Whoever uses the library should get used to working around this. </p> <p> Second, the default Vertex() should be denoted with an invalid id such that no valid vertex can be Vertex(). </p> <p> I would prefer the latter, or another way to work around this issue. </p> <p> Vertex is typedef boost::graph_traits&lt;Graph&gt;::vertex_descriptor Vertex; </p> <p> I used MSVC 9.0, Win32(Windows7), Intel x2 processors, ... what else? </p> <ul><li>Jeff Kunkel </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3506 Trac 1.4.3 Jeremiah Willcock Sun, 04 Oct 2009 01:48:19 GMT <link>https://svn.boost.org/trac10/ticket/3506#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3506#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/56563" title="Changed from Vertex() to null_vertex() in examples; refs #3506">[56563]</a>) Changed from Vertex() to null_vertex() in examples; refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/3506" title="#3506: Bugs: Graph's Tour / Dijkstra's parent nodes (closed: fixed)">#3506</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Jeremiah Willcock</dc:creator> <pubDate>Sun, 04 Oct 2009 01:50:49 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/3506#comment:2 https://svn.boost.org/trac10/ticket/3506#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> <p> This does appear to be a bug in the example -- there is a special null_vertex() value that is used to mark invalid vertices. I changed the code to use that, but it is probably not a good idea to look at the predecessor of the start vertex anyway. I do not believe the visitor ever sets the predecessor since it never has an edge coming in that is discovering the start vertex. </p> Ticket JDKunkMailing@… Sun, 04 Oct 2009 12:46:37 GMT severity changed https://svn.boost.org/trac10/ticket/3506#comment:3 https://svn.boost.org/trac10/ticket/3506#comment:3 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Not Applicable</span> </li> </ul> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/3506#comment:2" title="Comment 2">jewillco</a>: </p> <blockquote class="citation"> <p> This does appear to be a bug in the example -- there is a special null_vertex() value that is used to mark invalid vertices. I changed the code to use that, but it is probably not a good idea to look at the predecessor of the start vertex anyway. I do not believe the visitor ever sets the predecessor since it never has an edge coming in that is discovering the start vertex. </p> </blockquote> <p> I discovered that if a parent does not exist, it does not set anything to the property map. Therefore, algorithms (maybe just dijkstra) will not change an element if there is nothing to set it to. I recommend that all users should place default values into the analysis from algorithms, but this is just good application programming practice. </p> Ticket