{"id":6261,"date":"2025-09-13T12:29:56","date_gmt":"2025-09-13T06:59:56","guid":{"rendered":"https:\/\/study.madeeasy.in\/?p=6261"},"modified":"2025-09-15T09:20:27","modified_gmt":"2025-09-15T03:50:27","slug":"dijkstra-algorithm","status":"publish","type":"post","link":"https:\/\/www.madeeasy.in\/study\/cs-it\/algorithms\/dijkstra-algorithm","title":{"rendered":"Dijkstra Algorithm"},"content":{"rendered":"<p style=\"text-align: justify;\">Dijkstra\u2019s algorithm, named after its discoverer, Dutch computer scientist Edsger Dijkstra, is a greedy algorithm that solves the single-source shortest path problem for a directed graph G = (V, E) with non-negative edge weights i.e. we assume that w(u, v) \u2265 0 for each edge (u, v) \u2208 E.<\/p>\n<p style=\"text-align: justify;\">Dijkstra\u2019s algorithm maintains a set of S of vertices whose final shortest-path weights from the source have already been determined. That is, all vertices v \u2208 S, we have d[v] = \u03b4(s, v) the algorithm repeatedly selects the vertex u \u2208 V-S with the minimum shortest-path estimate, inserts u into S and relaxes all edges leaving u. We maintain a min-priority queue Q that contains all the vertices in V \u2013 s keyed by their d values. Graph G is represented by adjacency lists.<\/p>\n<p><strong> DIJKSTRA (G, w, s)<\/strong><\/p>\n<p>1. INITIALIZE-SINGLE-SOURCE (G, s)<br \/>\n2. S \u2190 \u03c6<br \/>\n3. Q \u2190 V[G]<br \/>\n4. while Q \u2260 \u03c6<br \/>\n5. do u \u2190 EXTRACT-MIN (Q)<br \/>\n6. S \u2190 S \u222a {u}<br \/>\n7. for each vertex v \u2208 Adj[u]<br \/>\n8. do RELAX (u, v, w)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Dijkstra\u2019s algorithm, named after its discoverer, Dutch computer scientist Edsger Dijkstra, is a greedy algorithm that solves the single-source shortest<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1831,3],"tags":[1846,1845],"class_list":["post-6261","post","type-post","status-publish","format-standard","hentry","category-algorithms","category-cs-it","tag-dijkstra","tag-dijkstra-algorithm"],"_links":{"self":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts\/6261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/comments?post=6261"}],"version-history":[{"count":0,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/posts\/6261\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/media?parent=6261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/categories?post=6261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.madeeasy.in\/study\/wp-json\/wp\/v2\/tags?post=6261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}