{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/primsAlgorithm","result":{"data":{"blog":{"frontmatter":{"title":"PRIM'S ALGORITHM","thumbnail":"blog74","date":"June 18, 2021","dsaCppCodeFile":"https://drive.google.com/file/d/1Zsvh_SpDmrF7REoSSuC9FaF-Vh2Kytln/view?usp=sharing"},"excerpt":"<div class=\"my-2 p-2\">\n              <h4>Introduction</h4>\n              <div class=\"m-2\">\n                <p>\n                  Given a weighted graph, we need to connect the nodes in the\n                  smallest possible way such that there will be a path between\n                  every pair nodes. This algorithm is one of the solution for\n                  the minimum spanning tree(MST) problem.\n                </p>\n                <p>\n                  It has direct applications to the design of all kinds of\n                  networks such communication, computer, transportation,\n                  electrical etc. by providing the cheapest way to achieve\n                  connectivity.\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 MST_V[] store the vertices and let E[] store the edges\n                  that are included in MST.\n                </li>\n                <li>\n                  Initially MST_V[0]=0(first vertex that shall be the source).\n                </li>\n                <li>Loop from i =1 to V-1 (V is the no. of vertices).\n                  <ul class=\"pl-4\">\n                      <li>\n                        Find a minimum weighted edge e=(v,u) among all the edges such\n                        that vertex v is in MST_V[] and vertex u is not in\n                        MST_V[].\n                      </li>\n                      <li>Then add this edge e to E[] and vertex u to MST_V[].</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                  Given a weighted graph, we need to connect the nodes in the\n                  smallest possible way such that there will be a path between\n                  every pair nodes. This algorithm is one of the solution for\n                  the minimum spanning tree(MST) problem.\n                </p>\n                <p>\n                  It has direct applications to the design of all kinds of\n                  networks such communication, computer, transportation,\n                  electrical etc. by providing the cheapest way to achieve\n                  connectivity.\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 MST_V[] store the vertices and let E[] store the edges\n                  that are included in MST.\n                </li>\n                <li>\n                  Initially MST_V[0]=0(first vertex that shall be the source).\n                </li>\n                <li>Loop from i =1 to V-1 (V is the no. of vertices).\n                  <ul class=\"pl-4\">\n                      <li>\n                        Find a minimum weighted edge e=(v,u) among all the edges such\n                        that vertex v is in MST_V[] and vertex u is not in\n                        MST_V[].\n                      </li>\n                      <li>Then add this edge e to E[] and vertex u to MST_V[].</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='M25%2092c-2%200-2%201-2%204l-1%208c0%205%200%205%202%205s3%200%203-2l2-4c4-1%206-3%206-6%200-5-3-7-10-5m12%202l-1%209c0%205%200%206%202%206l2-2%201-3c1%200%202%201%202%203%201%202%202%203%204%201v-4c-1-1-1-3%201-5%202-5%200-8-6-8-3%200-4%200-5%203m13-2v9l-1%208h5c4%200%205%200%206-2h2c1%201%201%201%202-1%201-1%201-1%201%201%200%201%201%202%203%202h2v-9c0-7-1-9-2-9-2%200-3%201-4%204l-1%204-1-3-2-4H50m21%202l2%202%202%201%203%204c4%203%204%204%200%204-3-1-5%201-2%203%208%204%2013-3%207-9l-3-4%202%202c2%202%204%200%204-3-1-4-8-4-10%200-1%202-1%202-1%200%200-4-4-4-4%200m27%201l-4%2013c0%202%205%201%205%200l2-2%202%202%203%201c2%200%203-2%201-10-2-10-6-11-9-4m12%200l-1%209v5h6c5%200%205%200%205-2v-2l2%202c2%204%2010%202%2010-3l2%202c2%204%206%204%209%201%202-3%203-13%201-15-3-3-9-1-10%204h-1c0-3-3-5-5-5-4%200-7%204-8%209%200%203-1%204-3%204h-3v-6c0-6%200-7-2-7-1%200-2%201-2%204m38-3l-2%209c0%208%200%208%202%208l2-2c0-4%202-4%203-1%202%203%201%203%203%202%202%200%203-3%201-5-1%200-1-2%201-4%202-5%200-8-5-8l-5%201m12%208v9h2c3%200%203%200%203-6s0-7%202-7%202%201%202%207c0%205%200%206%202%206s2-1%203-7c0-6%201-7%202-7l2-2c0-2-1-2-9-2h-9v9m19-5l-1%209c0%205%200%205%202%205%203%200%203%200%203-3s0-4%202-4l1%204c0%203%200%203%203%203%202%200%202%200%202-5l1-9c0-4%200-4-2-4-3%200-3%200-3%203s-1%203-3%203v-3c0-3%200-3-2-3-3%200-3%200-3%204m14%200l-1%209c0%205%200%205%202%205s3-1%203-2c0-2%200-2%201-1%201%202%201%202%203%200%202-1%202-1%202%201%200%201%200%202%202%202%203%200%203-2%202-10-1-9-3-11-5-5-2%205-2%205-4%201-1-5-5-5-5%200m106%2011l-1%208v7h9c8%200%209%201%209%203%200%201%200%202-2%202l-2-1c0-2-8%207-13%2015-4%208-8%2017-8%2026-1%207-1%207%205-1%204-5%206-7%209-8%206-3%207-2%207%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%206-14%200-20l-5-3-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%208v6h22v-3l1-3v-1l-1-3v-3h-22v7m-31%2027l1%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/ba7a78968fbe8fa9c484cb7c7e156f6c/ee604/blog74.png","srcSet":"/static/ba7a78968fbe8fa9c484cb7c7e156f6c/69585/blog74.png 200w,\n/static/ba7a78968fbe8fa9c484cb7c7e156f6c/497c6/blog74.png 400w,\n/static/ba7a78968fbe8fa9c484cb7c7e156f6c/ee604/blog74.png 800w,\n/static/ba7a78968fbe8fa9c484cb7c7e156f6c/f3583/blog74.png 1200w,\n/static/ba7a78968fbe8fa9c484cb7c7e156f6c/e4d72/blog74.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"primsAlgorithm","thumbnail":"thumbnails/blog74.png"}},"staticQueryHashes":["2987289216","63159454"]}