{"id":279,"date":"2018-06-01T14:24:57","date_gmt":"2018-06-01T21:24:57","guid":{"rendered":"http:\/\/blogs.reed.edu\/compbio\/?p=279"},"modified":"2018-06-01T14:24:57","modified_gmt":"2018-06-01T21:24:57","slug":"yens-k-shortest-paths","status":"publish","type":"post","link":"https:\/\/blogs.reed.edu\/compbio\/2018\/06\/01\/yens-k-shortest-paths\/","title":{"rendered":"Yen&#8217;s k shortest paths"},"content":{"rendered":"<p>This week, we split up to delve further into the PathLinker paper according to our aims. I was assigned to research Yen&#8217;s k-shortest paths algorithm and present to the lab on Wednesday.<\/p>\n<p>I&#8217;m now going to attempt to explain this algorithm&#8211;bear with me.<\/p>\n<p>Some caveats: first, this is an algorithm for computing the k-shortest loopless paths from one node to another, and this algorithm only considers simple paths, where nodes may not be repeated.<\/p>\n<p>To compute the k-shortest paths (where k is a user-defined parameter, say 10 or 4), we first find\u00a0<strong><em>the\u00a0<\/em><\/strong>shortest path (k=1) using some sort of algorithm, say Dijkstra&#8217;s.<\/p>\n<p>Here&#8217;s our wonderful graph from <a href=\"http:\/\/graphspace.org\/index\">Graphspace<\/a>:<img loading=\"lazy\" decoding=\"async\" class=\"wp-image-280 alignright\" src=\"https:\/\/blogs.reed.edu\/compbio\/files\/2018\/06\/Screen-Shot-2018-06-01-at-2.14.08-PM-300x232.png\" alt=\"\" width=\"309\" height=\"239\" srcset=\"https:\/\/blogs.reed.edu\/compbio\/files\/2018\/06\/Screen-Shot-2018-06-01-at-2.14.08-PM-300x232.png 300w, https:\/\/blogs.reed.edu\/compbio\/files\/2018\/06\/Screen-Shot-2018-06-01-at-2.14.08-PM-768x595.png 768w, https:\/\/blogs.reed.edu\/compbio\/files\/2018\/06\/Screen-Shot-2018-06-01-at-2.14.08-PM.png 930w\" sizes=\"auto, (max-width: 309px) 85vw, 309px\" \/><\/p>\n<table style=\"width: 247px;height: 304px\">\n<tbody>\n<tr>\n<th>Start Node<\/th>\n<th>End Node<\/th>\n<th>Weight<\/th>\n<\/tr>\n<tr>\n<td>a<\/td>\n<td>b<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>a<\/td>\n<td>c<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>a<\/td>\n<td>e<\/td>\n<td>9<\/td>\n<\/tr>\n<tr>\n<td>b<\/td>\n<td>e<\/td>\n<td>3<\/td>\n<\/tr>\n<tr>\n<td>b<\/td>\n<td>c<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>c<\/td>\n<td>e<\/td>\n<td>2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>So, using our graph, let&#8217;s find the shortest path from a to e (P_1). Looking at the graph, we can see that it is a-&gt;c-&gt;e, with cost 4. Now what we do is loop through all paths using this first path as a guide, because intuitively, there might be some obvious edges that we use in many of the shortest paths.<\/p>\n<p>Let&#8217;s call what we&#8217;re using from P_1 the <strong>root path,\u00a0<\/strong>and call what we use when we diverge from it the\u00a0<strong>spur path.<\/strong> To find P_2 (the 2nd shortest path), we must go through the graph differently this time to make sure we just don&#8217;t get the shortest path again. Because we&#8217;re using P_1 as a guide, let&#8217;s pretend that the edge from a-&gt;c has infinite cost, so that we can never take that edge.<\/p>\n<p>The paths that result from the root path being (a) is then [a -&gt;b-&gt;e (4), a-&gt;e(9), a-&gt;b-&gt;c-&gt;e(7)].<\/p>\n<p>Then, we expand our root path to be a-&gt;c,\u00a0 and pretend that the edge c-&gt;e has infinite cost, so the next path is [a-&gt;c-&gt;b-&gt;e (8)].<\/p>\n<p>We combine the two lists of potential paths and look at their costs. [a-&gt;b-&gt;e (4), a-&gt;e(9),a-&gt;b-&gt;c-&gt;e(7), a-&gt;c-&gt;b-&gt;e(8)]. a-&gt;b-&gt;e is the 2nd shortest path (P_2)!<\/p>\n<p>Then, we can simply search through the rest of the list for the next shortest path (P_3,&#8230;,P_k).<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week, we split up to delve further into the PathLinker paper according to our aims. I was assigned to research Yen&#8217;s k-shortest paths algorithm and present to the lab on Wednesday. I&#8217;m now going to attempt to explain this algorithm&#8211;bear with me. Some caveats: first, this is an algorithm for computing the k-shortest loopless &hellip; <a href=\"https:\/\/blogs.reed.edu\/compbio\/2018\/06\/01\/yens-k-shortest-paths\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Yen&#8217;s k shortest paths&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1725,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,11],"tags":[],"class_list":["post-279","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-summer-research-2018"],"_links":{"self":[{"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/users\/1725"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/comments?post=279"}],"version-history":[{"count":1,"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/posts\/279\/revisions"}],"predecessor-version":[{"id":281,"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/posts\/279\/revisions\/281"}],"wp:attachment":[{"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/media?parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/categories?post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.reed.edu\/compbio\/wp-json\/wp\/v2\/tags?post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}