{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/dijkstrasAlgorithm","result":{"data":{"blog":{"frontmatter":{"title":"DIJKSTRA'S ALGORITHM","thumbnail":"blog76","date":"June 22, 2021","dsaCppCodeFile":"https://drive.google.com/file/d/1HtSzz2kuV4GBLC8AtXmNWzTIrv3rLFDc/view?usp=sharing"},"excerpt":"<div class=\"my-2 p-2\">\n              <h4>Introduction</h4>\n              <div class=\"m-2\">\n                <p>\n                  Dijkstra's algorithm is used to solve the single source\n                  shortest paths problem. For a given source vertex in a\n                  connected weighted graph, we need to find the shortest path\n                  from source vertex to all other vertices.\n                </p>\n                <p>\n                  It applications in transportation planning and packet routing\n                  in communication networks, including the Internet. This\n                  algorithm is applicable to undirected and directed graphs with\n                  nonnegative weights only.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Working Procedure</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  Let the array D[] store the distances of the path from source\n                  to vertex i. Initially the all will be infinity(or some\n                  maximum number).\n                  <br />\n                  Let Q[] be the set of all vertices.\n                </li>\n                <li>\n                  Initially D[0]=0 i.e. the distance of source from source is\n                  0(obviously).\n                </li>\n                <li>\n                  Loop until Q is not empty\n                  <ul class=\"pl-4\">\n                    <li>\n                      Remove the vertex which has minimum distance from source\n                      and store it as vertex u.\n                    </li>\n                    <li>\n                      For each adjacent vertex v to vertex u, perform\n                      relaxation(u,v).\n                    </li>\n                  </ul>\n                </li>\n                <li>\n                  <strong>Relaxation(u,v):</strong>\n                  <ul class=\"pl-4\">\n                    <li>\n                      Let new distance be the sum of distance from source vertex\n                      to u(source -> u) and distance from u to v(u -> v).\n                    </li>\n                    <li>\n                      If new distance is less than the distance from source\n                      vertex to v then this distance(source -> v) shall be equal\n                      to new distance.\n                    </li>\n                  </ul>\n                </li>\n              </ul>\n            </div>\n            <div class=\"m-2\">\n              <h4>Time Complexity: O(E * logV)</h4>\n            </div>\n","html":"<div class=\"my-2 p-2\">\n              <h4>Introduction</h4>\n              <div class=\"m-2\">\n                <p>\n                  Dijkstra's algorithm is used to solve the single source\n                  shortest paths problem. For a given source vertex in a\n                  connected weighted graph, we need to find the shortest path\n                  from source vertex to all other vertices.\n                </p>\n                <p>\n                  It applications in transportation planning and packet routing\n                  in communication networks, including the Internet. This\n                  algorithm is applicable to undirected and directed graphs with\n                  nonnegative weights only.\n                </p>\n              </div>\n            </div>\n            <div class=\"my-2 p-2\">\n              <h4>Working Procedure</h4>\n              <ul class=\"pl-4\">\n                <li>\n                  Let the array D[] store the distances of the path from source\n                  to vertex i. Initially the all will be infinity(or some\n                  maximum number).\n                  <br />\n                  Let Q[] be the set of all vertices.\n                </li>\n                <li>\n                  Initially D[0]=0 i.e. the distance of source from source is\n                  0(obviously).\n                </li>\n                <li>\n                  Loop until Q is not empty\n                  <ul class=\"pl-4\">\n                    <li>\n                      Remove the vertex which has minimum distance from source\n                      and store it as vertex u.\n                    </li>\n                    <li>\n                      For each adjacent vertex v to vertex u, perform\n                      relaxation(u,v).\n                    </li>\n                  </ul>\n                </li>\n                <li>\n                  <strong>Relaxation(u,v):</strong>\n                  <ul class=\"pl-4\">\n                    <li>\n                      Let new distance be the sum of distance from source vertex\n                      to u(source -> u) and distance from u to v(u -> v).\n                    </li>\n                    <li>\n                      If new distance is less than the distance from source\n                      vertex to v then this distance(source -> v) shall be equal\n                      to new distance.\n                    </li>\n                  </ul>\n                </li>\n              </ul>\n            </div>\n            <div class=\"m-2\">\n              <h4>Time Complexity: O(E * logV)</h4>\n            </div>"},"thumbnail":{"childImageSharp":{"fluid":{"tracedSVG":"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='400'%20height='225'%20viewBox='0%200%20400%20225'%20preserveAspectRatio='none'%3e%3cpath%20d='M24%2092l-1%209-1%208h3c4%200%207-1%208-5l2-2v3c0%204%200%204%203%204%202%200%202%200%202-3v-2l1%202c3%205%2010%203%2011-3%201-2%201-1%201%202%200%204%200%204%203%204%202%200%202%200%202-3v-2l2%202c2%202%203%203%204%202h12c2-2%201-7-1-9-2%200-3-2-3-3l1%201h4c4-2%205-1%205%206%200%205%200%206%202%206s2-1%203-7c0-6%201-7%202-7l2-2c0-2-1-2-6-2-6%200-7%200-7%202h-2c-3-4-9-1-9%204%200%202%201%204%203%205%203%202%203%203-2%203-5-1-7-5-4-8%202-3%202-3%201-5-2-1-2-1-4%201l-3%202v-2c0-3-4-3-4%200l-1%203v-3l-2-2c-3%200-3%200-3%206s-1%209-3%206l-3-1c-2%201-2%201-1-5%200-6%200-6-2-6s-3%200-3%205c0%206-1%208-1%202s-6-9-11-6m69%200l-2%209c0%208%200%208%202%208l2-1a19%2019%200%20011-5l2%203c2%202%202%203%204%202s2-1%201-4c-2-2-2-3%200-5%202-4%200-8-5-8l-5%201m18%200c-2%202-6%2014-6%2016l3%201%202-1%202-2%202%202%203%201%202-2-3-15h-5m16%201c-3%203-2%207%201%209s3%203-1%203c-2-1-4%202-2%203h9c2-2%201-6-1-8v-2c3%200%203-2%202-5s-6-3-8%200m21%202l-5%2014%206-1c0-2%204-2%204%200l8%201c6%200%208-1%208-2%200-2%202-1%202%201%202%203%2010%200%2010-3%200-2%202-1%203%201%201%204%206%204%209%201%202-4%203-10%201-14-3-3-8-3-10%202-2%203-2%203-2%201%200-5-5-7-10-3l-2%207c0%204%200%204-4%204h-3v-6l1-7h-2c-3%200-3%200-3%206%200%209-1%2011-2%204-1-8-3-10-5-10s-3%201-4%204m49-3l-1%209-1%208h2c2%200%203-1%203-3l1-3%201%203c2%203%202%203%204%202s2-1%201-4V92h-10m13%200l-1%209v8h2c3%200%203%200%203-6s0-7%202-7%202%201%202%207%200%206%203%206c2%200%202%200%202-7%200-6%200-7%202-7l2-2c0-2-1-2-8-2l-9%201m19%200l-1%209c0%207%200%208%202%208s3-1%203-4c0-4%203-4%203%201%200%203%200%203%202%203s3-1%203-9v-9h-2c-3%200-3%200-3%203l-1%203c-2%201-2%200-2-3s-3-5-4-2m14%200l-1%209c0%207%200%208%202%208l2-2c0-2%200-2%202%200h3c1-2%201-2%201%200%200%201%201%202%203%202h2v-9c0-7-1-9-2-9l-4%203-1%204-2-3c-1-3-4-5-5-3m56%2014l-1%208v7h9c8%200%209%201%209%203s0%202-2%202c-5-1-16%2013-21%2026l-3%2020%206-7c4-5%206-7%2010-8%206-3%206-2%206%201%200%202%200%202%201%201h3l-2-5-2-7-1-3v-3c3-2%2013-2%2013%200l-1%201h-2c0%202%203%202%204%201h1l-1%202-1%203-2%207-2%204h3c2%200%202-1%201-3%200-2%200-2%207%200%204%201%205%202%207%205l3%204%201%203%202%206%202%204%201%204c2%207-1%2010-9%208h-4v-24h-15v-3l-1-3-1%203v3h-17v7l-1%208c-2%202-2%203-1%203%202%200%203%204%202%206h-15c-2-3-2-5%201-8%204-6%202-7-2-2-3%203-4%205-4%207%200%203%200%203-9%204-9%200-9%200-9%202s1%203%205%203h5l-1%204v3h97l1-4c1-2%202-3%205-3%205-1%205-4%200-5h-3v-14c0-14-1-21-4-21l-2-2c-1-2-1-2-1%200%200%203-8%203-8-1%200-2%200-2%202-2%202%201%203%200%201-1-2-2-1-4%203-12%206-11%205-17-1-20l-3-2-1-1-1-4-1-5c-1-1-1%201-1%204v5l-3-1c-3-1-22%200-24%201-1%201-1-1-1-4v-5l-14-1-13%201m2%207v7h22v-3l1-3v-1l-1-3v-3h-22v6m-31%2028l1%209h12v-18h-13v9m3%2023l-1%205c0%203%200%204-1%203%200-4-2-3-3%200l2%204%202%203%203%201c2%200%202%200%202-3%200-2%200-3%202-3s2-1%202-4l-1-4-1%203c0%203-2%202-2-2%200-3-1-4-4-3'%20fill='%23d3d3d3'%20fill-rule='evenodd'/%3e%3c/svg%3e","aspectRatio":1.7699115044247788,"src":"/static/caf3d3d90b4c20ceec1d637d9d6652a3/ee604/blog76.png","srcSet":"/static/caf3d3d90b4c20ceec1d637d9d6652a3/69585/blog76.png 200w,\n/static/caf3d3d90b4c20ceec1d637d9d6652a3/497c6/blog76.png 400w,\n/static/caf3d3d90b4c20ceec1d637d9d6652a3/ee604/blog76.png 800w,\n/static/caf3d3d90b4c20ceec1d637d9d6652a3/f3583/blog76.png 1200w,\n/static/caf3d3d90b4c20ceec1d637d9d6652a3/e4d72/blog76.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"dijkstrasAlgorithm","thumbnail":"thumbnails/blog76.png"}},"staticQueryHashes":["2987289216","63159454"]}