<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Shortest-Path on BoilTask's Blog</title><link>https://boiltask.com/en/tags/shortest-path/</link><description>Recent content in Shortest-Path on BoilTask's Blog</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Wed, 17 Feb 2016 14:49:25 +0800</lastBuildDate><atom:link href="https://boiltask.com/en/tags/shortest-path/index.xml" rel="self" type="application/rss+xml"/><item><title>Shortest Path — Minimum Total Weight Between Two Vertices</title><link>https://boiltask.com/en/knowledge/shortest-path/</link><pubDate>Wed, 17 Feb 2016 14:49:25 +0800</pubDate><guid>https://boiltask.com/en/knowledge/shortest-path/</guid><description>&lt;h2 id="single-source-shortest-path"&gt;&lt;a href="#single-source-shortest-path" class="header-anchor"&gt;&lt;/a&gt;Single-source shortest path
&lt;/h2&gt;&lt;p&gt;Finding the shortest path from one vertex to every other vertex.&lt;/p&gt;
&lt;h3 id="shortest-path-with-bfs"&gt;&lt;a href="#shortest-path-with-bfs" class="header-anchor"&gt;&lt;/a&gt;Shortest path with BFS
&lt;/h3&gt;&lt;p&gt;&lt;em&gt;Competitive Programming&lt;/em&gt;&lt;br&gt;
&lt;a class="link" href="http://blog.csdn.net/zzyafyj/article/details/39323369#t2" target="_blank" rel="noopener"&gt;Chapter 6, the graph part — zzyafyj&amp;rsquo;s column&lt;/a&gt;&lt;/p&gt;
&lt;h3 id="dijkstra"&gt;&lt;a href="#dijkstra" class="header-anchor"&gt;&lt;/a&gt;Dijkstra
&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="http://ahalei.blog.51cto.com/4767671/1387799" target="_blank" rel="noopener"&gt;Algorithms on the toilet, part 7: Dijkstra&amp;rsquo;s shortest path&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;We find dis[3] = 12, while dis[2] + e[2][3] = 1 + 9 = 10. Since dis[3] &amp;gt; dis[2] + e[2][3], dis[3] must be updated to 10. This process has a name: &amp;ldquo;relaxation&amp;rdquo;. The distance from vertex 1 to vertex 3 — dis[3] — is successfully relaxed through the edge 2-&amp;gt;3. That is the main idea of Dijkstra: relax the distances from vertex 1 to all the other vertices through edges.&lt;br&gt;
Each time, take the vertex closest to the source (vertex 1 in the example), expand from it as the new centre, and you eventually get the shortest paths from the source to all remaining vertices.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="all-pairs-shortest-paths"&gt;&lt;a href="#all-pairs-shortest-paths" class="header-anchor"&gt;&lt;/a&gt;All-pairs shortest paths
&lt;/h2&gt;&lt;p&gt;Finding the shortest path between every pair of vertices.&lt;/p&gt;
&lt;h3 id="floydwarshall"&gt;&lt;a href="#floydwarshall" class="header-anchor"&gt;&lt;/a&gt;Floyd–Warshall
&lt;/h3&gt;&lt;p&gt;&lt;a class="link" href="http://ahalei.blog.51cto.com/4767671/1383613" target="_blank" rel="noopener"&gt;Algorithms on the toilet: Floyd&amp;rsquo;s shortest path in five lines&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;At first only vertex 1 may be used as an intermediate point, then only vertices 1 and 2, … and finally all vertices 1..n. Put in one sentence: the shortest path from vertex i to vertex j using only the first k vertices as intermediates.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Reference:&lt;br&gt;
&lt;em&gt;Programming Contest Challenge Book&lt;/em&gt;&lt;br&gt;
&lt;a class="link" href="http://developer.51cto.com/art/201403/433874.htm" target="_blank" rel="noopener"&gt;Algorithms on the toilet: Floyd&amp;rsquo;s shortest path in five lines&lt;/a&gt;&lt;br&gt;
&lt;a class="link" href="http://ahalei.blog.51cto.com/4767671/1387799" target="_blank" rel="noopener"&gt;Algorithms on the toilet, part 7: Dijkstra&amp;rsquo;s shortest path&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>