Boost C++ Libraries: Ticket #11838: contribution: Yen k-shortest paths https://svn.boost.org/trac10/ticket/11838 <p> I wanna contribute the implementation of the Yen k-shortest paths algorithm. Please find attached the implementation and the unit test. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11838 Trac 1.4.3 Irek Szcześniak <irek@…> Thu, 10 Dec 2015 21:11:00 GMT attachment set https://svn.boost.org/trac10/ticket/11838 https://svn.boost.org/trac10/ticket/11838 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">yen_ksp.hpp</span> </li> </ul> <p> the implementation </p> Ticket Irek Szcześniak <irek@…> Thu, 10 Dec 2015 21:11:28 GMT attachment set https://svn.boost.org/trac10/ticket/11838 https://svn.boost.org/trac10/ticket/11838 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">yen_ksp.cc</span> </li> </ul> <p> the unit test </p> Ticket Irek Szcześniak <irek@…> Thu, 10 Dec 2015 21:13:25 GMT component, severity, type changed; cc, owner set https://svn.boost.org/trac10/ticket/11838#comment:1 https://svn.boost.org/trac10/ticket/11838#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">irek@…</span> added </li> <li><strong>owner</strong> set to <span class="trac-author">Jeremiah Willcock</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">graph</span> </li> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Not Applicable</span> </li> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Library Submissions</span> </li> </ul> Ticket Irek Szcześniak <irek@…> Thu, 10 Dec 2015 21:22:50 GMT attachment set https://svn.boost.org/trac10/ticket/11838 https://svn.boost.org/trac10/ticket/11838 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">custom_dijkstra_call.hpp</span> </li> </ul> Ticket Irek Szcześniak <irek@…> Thu, 10 Dec 2015 21:23:19 GMT attachment set https://svn.boost.org/trac10/ticket/11838 https://svn.boost.org/trac10/ticket/11838 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">exclude_filter.hpp</span> </li> </ul> Ticket Jürgen Hunold Fri, 11 Dec 2015 10:21:07 GMT <link>https://svn.boost.org/trac10/ticket/11838#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:2</guid> <description> <p> New features should be submitted as pull requests on github See <a class="ext-link" href="https://github.com/boostorg/graph"><span class="icon">​</span>https://github.com/boostorg/graph</a> And make sure you make your PR against the "develop" branch. </p> </description> <category>Ticket</category> </item> <item> <author>Irek Szcześniak <irek@…></author> <pubDate>Fri, 11 Dec 2015 10:52:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:3</guid> <description> <p> Will do! Thanks for the info! </p> </description> <category>Ticket</category> </item> <item> <author>Irek Szcześniak <irek@…></author> <pubDate>Mon, 14 Mar 2016 22:00:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:4</guid> <description> <p> Compile the unit test like this: </p> <pre class="wiki">g++ -std=c++11 yen_ksp.cc -l boost_unit_test_framework -l boost_test_exec_monitor -o yen_ksp </pre> </description> <category>Ticket</category> </item> <item> <author>Irek Szcześniak <irek@…></author> <pubDate>Mon, 14 Mar 2016 22:05:00 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/11838 https://svn.boost.org/trac10/ticket/11838 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">yen_ksp.2.hpp</span> </li> </ul> <p> the implementation - v2 </p> Ticket Irek Szcześniak <irek@…> Mon, 14 Mar 2016 22:07:08 GMT <link>https://svn.boost.org/trac10/ticket/11838#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:5</guid> <description> <p> I added a simpler and improved implementation (yen_ksp.2.hpp), which doesn't use the exclude_filter that I implemented. Instead, the filter provided by filtered_graph are used. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 24 Jun 2016 09:58:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:6</guid> <description> <p> Thank you, I was looking for something like that for some time. Did you implement the Martins and Pascoal? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 24 Jun 2016 10:17:38 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:7</guid> <description> <p> Glad to hear! No, I didn't work on Martins and Pascoal, nor many other algorithms like that. </p> <p> You may want to have a look at the edge-disjoint KSP: </p> <p> <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/11804"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/11804</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 28 Jun 2016 18:26:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:8</guid> <description> <p> Hi again. Sorry, I think that there is a bug in yen_ksp.2.hpp. Basically I tested your program with a graph in which several composite paths have equal lengths, and where I could easily check by hand all the KSPs. What happens is that previously already identified KSPs reappear somewhere down the list of shortest paths. Of course they were all properly ordered and weights were correctly computed. </p> <p> Below are the relevant snippets for the reproduction of the issue, for a KSP from O to D, and the weight-path output. As you can see, some repeated paths occur, which should not happen. </p> <p> Best, Rytis </p> <div class="wiki-code"><div class="code"><pre> <span class="n">Vertex</span> <span class="n">X</span> <span class="o">=</span> <span class="o">*</span><span class="n">i</span><span class="o">++</span><span class="p">;</span> <span class="n">Vertex</span> <span class="n">O</span> <span class="o">=</span> <span class="o">*</span><span class="n">i</span><span class="o">++</span><span class="p">;</span> <span class="n">Vertex</span> <span class="n">D</span> <span class="o">=</span> <span class="o">*</span><span class="n">i</span><span class="o">++</span><span class="p">;</span> <span class="n">Vertex</span> <span class="n">L</span> <span class="o">=</span> <span class="o">*</span><span class="n">i</span><span class="o">++</span><span class="p">;</span> <span class="n">Vertex</span> <span class="n">R</span> <span class="o">=</span> <span class="o">*</span><span class="n">i</span><span class="p">;</span> <span class="n">tie</span><span class="p">(</span><span class="n">ab</span><span class="p">,</span> <span class="n">ba</span><span class="p">)</span> <span class="o">=</span> <span class="n">aue</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">O</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="mi">16</span><span class="p">);</span> <span class="n">tie</span><span class="p">(</span><span class="n">ae</span><span class="p">,</span> <span class="n">ea</span><span class="p">)</span> <span class="o">=</span> <span class="n">aue</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="mi">4</span> <span class="p">);</span> <span class="n">tie</span><span class="p">(</span><span class="n">ac</span><span class="p">,</span> <span class="n">ca</span><span class="p">)</span> <span class="o">=</span> <span class="n">aue</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">L</span><span class="p">,</span> <span class="mi">25</span><span class="p">);</span> <span class="n">tie</span><span class="p">(</span><span class="n">be</span><span class="p">,</span> <span class="n">eb</span><span class="p">)</span> <span class="o">=</span> <span class="n">aue</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">X</span><span class="p">,</span> <span class="n">R</span><span class="p">,</span> <span class="mi">9</span> <span class="p">);</span> <span class="n">tie</span><span class="p">(</span><span class="n">cd1</span><span class="p">,</span> <span class="n">dc1</span><span class="p">)</span> <span class="o">=</span> <span class="n">aue</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">O</span><span class="p">,</span> <span class="n">R</span><span class="p">,</span> <span class="mi">25</span><span class="p">);</span> <span class="n">tie</span><span class="p">(</span><span class="n">cd2</span><span class="p">,</span> <span class="n">dc2</span><span class="p">)</span> <span class="o">=</span> <span class="n">aue</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">R</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="mi">13</span><span class="p">);</span> <span class="n">tie</span><span class="p">(</span><span class="n">ce</span><span class="p">,</span> <span class="n">ec</span><span class="p">)</span> <span class="o">=</span> <span class="n">aue</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">L</span><span class="p">,</span> <span class="mi">29</span><span class="p">);</span> <span class="n">tie</span><span class="p">(</span><span class="n">aa</span><span class="p">,</span><span class="n">bb</span><span class="p">)</span> <span class="o">=</span> <span class="n">aue</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">L</span><span class="p">,</span> <span class="n">O</span><span class="p">,</span> <span class="mi">41</span><span class="p">);</span> </pre></div></div><pre class="wiki">20.000 O -- X -- D 38.000 O -- R -- D 38.000 O -- X -- R -- D 38.000 O -- R -- X -- D 70.000 O -- L -- D 70.000 O -- L -- D 70.000 O -- X -- L -- D 70.000 O -- L -- D 70.000 O -- L -- X -- D 70.000 O -- L -- X -- D 70.000 O -- L -- X -- D 88.000 O -- R -- X -- L -- D 88.000 O -- L -- X -- R -- D 88.000 O -- L -- X -- R -- D 88.000 O -- L -- X -- R -- D </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 28 Jun 2016 18:33:45 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:9</guid> <description> <p> Hi Rytis, </p> <p> Thank you for the info! I'll look into it and definitely fix it within a few days. </p> <p> Best, Irek </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 28 Jun 2016 18:41:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:10</guid> <description> <p> I'll be looking forward to it. Too bad I am not proficient enough with boost, otherwise I'd try to help. Thank you! </p> </description> <category>Ticket</category> </item> <item> <author>Ireneusz Szcześniak <irek@…></author> <pubDate>Mon, 13 Feb 2017 13:07:56 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:11</guid> <description> <p> Hi Rytis, </p> <p> I fixed the implementation. Sorry it took me so long. The problem was that the algorithm can find the same tentative path many times, which is pushed into the list B of tentative paths many times, and then it is moved to the list A of shortest paths many times. </p> <p> I came up with a simple test case: </p> <pre class="wiki"> /-----4-----\ a--1--b---1---c \--2--/ </pre><p> Finding the shortest paths between a and c should give 3 paths, while before the implementation would return 4. I implemented this example as a unit test. </p> <p> I improved the implementation and the performance a bit, and added more comments. I also took advantage of the move semantics. </p> <p> I'm going to attach the new implementation and the unit tests. This time I'm including a compressed archive, not separate files. Please find it below. </p> <p> Best, Irek </p> </description> <category>Ticket</category> </item> <item> <author>Ireneusz Szcześniak <irek@…></author> <pubDate>Mon, 13 Feb 2017 13:11:59 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/11838 https://svn.boost.org/trac10/ticket/11838 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">yen.tar.gz</span> </li> </ul> <p> This implementation does not return the same path many times. </p> Ticket Ireneusz Szcześniak <irek@…> Tue, 14 Feb 2017 06:36:14 GMT <link>https://svn.boost.org/trac10/ticket/11838#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:12</guid> <description> <p> Here is the repository: </p> <p> <a class="ext-link" href="https://github.com/iszczesniak/yen"><span class="icon">​</span>https://github.com/iszczesniak/yen</a> </p> <p> Or you can clone: </p> <pre class="wiki">git clone git@github.com:iszczesniak/yen.git </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 12 Jun 2018 14:21:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:13</guid> <description> <p> Is it not added yet? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Tue, 12 Jun 2018 14:24:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:14</guid> <description> <p> Very nice algorithm for boost, because just Dijkstra's algorithm not enough in case, when you need chose path among several nearest paths. </p> </description> <category>Ticket</category> </item> <item> <author>irek@…</author> <pubDate>Tue, 12 Jun 2018 15:35:02 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:15</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11838#comment:13" title="Comment 13">anonymous</a>: </p> <blockquote class="citation"> <p> Is it not added yet? </p> </blockquote> <p> It's not added, because I just don't have time to do it. Please feel free to submit the code, and be a coauthor. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>andrewmw94</dc:creator> <pubDate>Tue, 17 Jul 2018 14:09:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:16</guid> <description> <p> I'm interested in getting this added. What still needs to be done? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>andrewmw94</dc:creator> <pubDate>Tue, 17 Jul 2018 15:55:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:17 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:17</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11838#comment:16" title="Comment 16">andrewmw94</a>: </p> <blockquote class="citation"> <p> I'm interested in getting this added. What still needs to be done? </p> </blockquote> <p> More specifically is this just fixing the algorithm or is there extra paperwork / API change stuff that I would need to do? </p> <p> I think the issue (or at least one issue) with the algorithm is that the Kth shortest path is not guaranteed to be a variant of the K-1th shortest path. The loop needs to consider all previous shortest paths. So we have to do more than just loop through the edges of psp. </p> </description> <category>Ticket</category> </item> <item> <author>irek@…</author> <pubDate>Wed, 18 Jul 2018 20:58:48 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11838#comment:18 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11838#comment:18</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11838#comment:17" title="Comment 17">andrewmw94</a>: </p> <blockquote class="citation"> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/11838#comment:16" title="Comment 16">andrewmw94</a>: </p> <blockquote class="citation"> <p> I'm interested in getting this added. What still needs to be done? </p> </blockquote> <p> More specifically is this just fixing the algorithm or is there extra paperwork / API change stuff that I would need to do? </p> </blockquote> <p> I'm happy to hear you want to submit the code! Good luck! </p> <p> The implementation is already fixed, and is available at: </p> <p> ​<a class="ext-link" href="https://github.com/iszczesniak/yen"><span class="icon">​</span>https://github.com/iszczesniak/yen</a> </p> <p> I don't know what should be exactly done to submit the code to Boost. I think the documentation, the right files in the right place, I guess. </p> <p> Best, Irek </p> </description> <category>Ticket</category> </item> </channel> </rss>