{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/kruskalsAlgorithm","result":{"data":{"blog":{"frontmatter":{"title":"KRUSKAL'S ALGORITHM","thumbnail":"blog75","date":"June 20, 2021","dsaCppCodeFile":null},"excerpt":"<div class=\"my-2 p-2\">\n              <h4>Introduction</h4>\n              <div class=\"m-2\">\n                <p>\n                  Kruskal's algorithm is used to solve the minimum spanning\n                  tree(MST) problem. It looks for a MST of a weighted connected\n                  graph as an acyclic subgraph with V-1 number of edges(where V is\n                  the number of vertices) for which the the sum of edge weights\n                  is the smallest.\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_E[] be the set of edges that are to be included in the\n                  minimum spanning tree. Let edgeCount be the number of edges\n                  that are included in MST.\n                </li>\n                <li>\n                  Let V and E be the no. of vertices and edges in the given\n                  graph.\n                </li>\n                <li>\n                  First, sort all the edges in the increasing order of their\n                  weights.\n                </li>\n                <li>\n                  Loop until edgeCount < V - 1.\n                  <ul class=\"pl-4\">\n                    <li>Let edge e = E[edgeCount].</li>\n                    <li>\n                      If adding edge e to MST_E[] makes the resultant MST an\n                      acyclic, then add it and increment the edgeCount.\n                    </li>\n                    <li>Else ignore this edge and move on to next edge.</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                  Kruskal's algorithm is used to solve the minimum spanning\n                  tree(MST) problem. It looks for a MST of a weighted connected\n                  graph as an acyclic subgraph with V-1 number of edges(where V is\n                  the number of vertices) for which the the sum of edge weights\n                  is the smallest.\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_E[] be the set of edges that are to be included in the\n                  minimum spanning tree. Let edgeCount be the number of edges\n                  that are included in MST.\n                </li>\n                <li>\n                  Let V and E be the no. of vertices and edges in the given\n                  graph.\n                </li>\n                <li>\n                  First, sort all the edges in the increasing order of their\n                  weights.\n                </li>\n                <li>\n                  Loop until edgeCount < V - 1.\n                  <ul class=\"pl-4\">\n                    <li>Let edge e = E[edgeCount].</li>\n                    <li>\n                      If adding edge e to MST_E[] makes the resultant MST an\n                      acyclic, then add it and increment the edgeCount.\n                    </li>\n                    <li>Else ignore this edge and move on to next edge.</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='M23%2094l-1%209c0%206%200%206%202%206%203%200%203%200%203-3s0-3%202-1l2%203h4c0%203%204%200%205-2l1-3%201%203c2%203%202%203%204%202s2-1%201-4c-2-2-2-3%200-4v-8H34c-1-1-2-1-3%201-3%203-4%203-3%200%200-2%200-2-2-2-3%200-3%200-3%203m27%200v14c2%202%206%201%209-1%202-1%202-3%203-9v-7h-2c-3%200-3%200-3%206-1%209-3%209-3%201%200-6%200-7-2-7-1%200-2%201-2%203m15-1c-3%203-2%206%201%209l4%203h-4c-3-1-5%201-2%203s7%201%208-1l2-2v2c0%201%201%202%203%202s2%200%202-3v-2l2%202c2%203%203%203%204%201h2c0%201%201%202%203%202l2-1%202-2%202%202%203%201c2%200%203-2%201-10-1-6-2-8-5-8-2%200-6%206-7%2012%200%203%200%203-2%201-3-2-3-5-1-8%202-2%202-2%201-4-2-1-2-1-4%201l-3%202v-2c0-3-4-3-4%200v3l-2-3c-2-3-6-3-8%200m38%201l-1%209v6h6c5%200%205%200%205-2%200-3%200-3-3-3h-3v-6c0-6%200-7-2-7-1%200-2%201-2%203m11%200c0%202%200%202%202%202%201-1%202%200%202%201l3%204c4%204%204%204%200%204-3-1-5%201-2%203%207%203%2013-3%208-8-2-2-2-2%200-2%202-1%203-4%201-6s-6-1-8%201l-2%202v-2l-2-2c-1%200-2%201-2%203m28-1l-5%2015%203%201%202-1%202-2%202%202%203%201c2%200%202%200%202-5-2-11-6-17-9-11m11-1l-1%209v8h5c3%200%205%200%206-2h2c3%204%2010%200%2010-5-1-4-6-4-5%200%200%203-1%204-2%202-1-1%201-9%202-8v1l2%201c3%200%204-4%202-6-4-3-10%201-11%208%200%204-1%204-3%204-3%200-3%200-3-6s0-7-2-7l-2%201m26%200c-3%202-4%2012-1%2015%206%206%2013-6%209-14-1-2-5-3-8-1m11%201l-1%209c0%206%200%207%202%207l2-2%201-3c1%200%202%201%202%203%201%202%202%203%204%201v-4c-1-1-1-3%201-5%201-3%201-6-1-7-3-2-9-1-10%201m13-1v9l-1%208h2c3%200%203%200%203-4%200-7%201-9%203-9s2%201%202%207c-1%206-1%206%202%206%202%200%202%200%202-4%200-7%201-10%203-10l2-2c0-2-1-2-9-2l-9%201m19%204c-2%2011-1%2013%202%2013%202%200%202%200%202-3s0-4%202-4l1%204c0%203%200%203%202%203%203%200%203%200%203-9s0-9-2-9-2%201-2%203l-1%203c-2%201-3-1-3-4%201-2%201-2-1-2s-3%201-3%205m14-3l-1%209c0%207%200%207%203%207l2-2h1c2%201%202%201%203-1%201-1%201-1%201%201%200%201%201%202%203%202h2v-9c0-7-1-9-2-9l-4%204-1%204-1-4c-2-4-5-5-6-2m63%2013l-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-92%209c-1%202-4%202-4%201l-1-1-1%202h-1l-5-1h-5l-3-1c-3%200-3%200-3%203s0%203%201%202l3-1%202-1c1-1%201%200%201%201%200%202%202%203%202%201l1-2%201%202c1%201%205%202%205%200h10c2%202%205%201%205-1%200-3-3-4-4-2-2%201-2%201-2-1s-1-2-2-1m61%2019l1%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/137ac460b69ba2c77d34b80bb2733979/ee604/blog75.png","srcSet":"/static/137ac460b69ba2c77d34b80bb2733979/69585/blog75.png 200w,\n/static/137ac460b69ba2c77d34b80bb2733979/497c6/blog75.png 400w,\n/static/137ac460b69ba2c77d34b80bb2733979/ee604/blog75.png 800w,\n/static/137ac460b69ba2c77d34b80bb2733979/f3583/blog75.png 1200w,\n/static/137ac460b69ba2c77d34b80bb2733979/e4d72/blog75.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"kruskalsAlgorithm","thumbnail":"thumbnails/blog75.png"}},"staticQueryHashes":["2987289216","63159454"]}