{"id":493,"date":"2014-10-03T18:39:02","date_gmt":"2014-10-04T02:39:02","guid":{"rendered":"http:\/\/www.tech.dimprash.com\/?p=493"},"modified":"2014-10-03T18:41:58","modified_gmt":"2014-10-04T02:41:58","slug":"algorithms-on-graphs","status":"publish","type":"post","link":"http:\/\/www.tech.dimprash.com\/?p=493","title":{"rendered":"Algorithms on Graphs"},"content":{"rendered":"<p>1) DFS<br \/>\nRemember its recursive <\/p>\n<p>2) BFS<br \/>\nQueue based <\/p>\n<p>3) Shortest Path in unweighted  graph. <\/p>\n<p>4) Shortest Path in weighted graph. <\/p>\n<p>5) Determine if directed graph has a cycle<br \/>\nKarumanchi , pg 236 <\/p>\n<p>If a node is seen a second time before all of its descendants are visited then there is a cycle. <\/p>\n<pre>\r\nDetect Cycle(G) {\r\n  Initialize Visited array and Predecessor array; \r\n  call HasCycle\r\n}\r\n\r\nHasCycle(G, u) {\r\n Visited[u] = true; \r\n Loop i over all vertices v\r\n   Check if edge present in Adjacency Matrix \r\n      If Predecessor P[i] != u and Visited[u] then \r\n          Cycle exists; \r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1) DFS Remember its recursive 2) BFS Queue based 3) Shortest Path in unweighted graph. 4) Shortest Path in weighted graph. 5) Determine if directed graph has a cycle Karumanchi , pg 236 If a node is seen a second time before all of its descendants are visited then there is a cycle. Detect Cycle(G) &hellip; <a href=\"http:\/\/www.tech.dimprash.com\/?p=493\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Algorithms on Graphs<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-493","post","type-post","status-publish","format-standard","hentry","category-algorithms"],"_links":{"self":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=493"}],"version-history":[{"count":4,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/493\/revisions"}],"predecessor-version":[{"id":497,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=\/wp\/v2\/posts\/493\/revisions\/497"}],"wp:attachment":[{"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=493"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.tech.dimprash.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}