{"componentChunkName":"component---src-templates-blog-post-jsx","path":"/blogs/warshallsAlgorithm","result":{"data":{"blog":{"frontmatter":{"title":"WARSHALL'S ALGORITHM","thumbnail":"blog70","date":"June 6, 2021","dsaCppCodeFile":"https://drive.google.com/file/d/1rSHBwWvTspdpTDXZUFA1hVpDKSLI46vK/view?usp=sharing"},"excerpt":" <div class=\"my-2 p-2\">\n              <h4>Introduction</h4>\n              <div class=\"m-2\">\n                <p>\n                  Warshall’s algorithm is used for computing the transitive\n                  closure of a directed graph. From the relations concept, w.k.t\n                  that if a relates to b and b relates to c and a relates to c\n                  then there is a transitive relation.\n                </p>\n                <p>\n                  Recall from the adjacency matrix of a digraph, the entry in\n                  i<sup>th</sup> row and j<sup>th</sup> column is 1 if and only\n                  if there exists an edge from vertex i to j. So here, we are\n                  interested to find a matrix that holds the information about\n                  the existence of directed paths of arbitrary lengths between\n                  vertices of a given graph.\n                </p>\n                <p>\n                  Such a matrix, called the transitive closure of the digraph,\n                  would allow us to determine in constant time whether the j<sup\n                    >th</sup\n                  >\n                  vertex is reachable from the i<sup>th</sup> vertex.\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                  Loop from k=0 to n-1.\n                  <ul class=\"pl-4 list-unstyled\">\n                    <li>\n                      Loop from i=0 to n-1.\n                      <ul class=\"pl-4 list-unstyled\">\n                        <li>\n                          If R[i][k]==1 then loop from j=0 to n-1.\n                          <ul class=\"pl-4 list-unstyled\">\n                            <li>If R[k][j]==1 then R[i][j]=1.</li>\n                          </ul>\n                        </li>\n                      </ul>\n                    </li>\n                  </ul>\n                </li>\n              </ul>\n              <p>\n                It simply means that, if R[i,k]==1 and R[k,j]==1 then assign\n                R[i,j]=1 and this says that we can reach vertex j starting from\n                vertex i.\n              </p>\n            </div>\n            <div class=\"m-2\">\n              <h4>Time Complexity: O(n<sup>3</sup>)</h4>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/dynamicProgramming\">Dynamic Programming</a> |\n              <a href=\"/blogs/floydsAlgorithm\">Floyd's Algorithm</a> |\n              <a href=\"/blogs/knapsackProblem\">Knapsack problem</a>\n            </div>\n","html":" <div class=\"my-2 p-2\">\n              <h4>Introduction</h4>\n              <div class=\"m-2\">\n                <p>\n                  Warshall’s algorithm is used for computing the transitive\n                  closure of a directed graph. From the relations concept, w.k.t\n                  that if a relates to b and b relates to c and a relates to c\n                  then there is a transitive relation.\n                </p>\n                <p>\n                  Recall from the adjacency matrix of a digraph, the entry in\n                  i<sup>th</sup> row and j<sup>th</sup> column is 1 if and only\n                  if there exists an edge from vertex i to j. So here, we are\n                  interested to find a matrix that holds the information about\n                  the existence of directed paths of arbitrary lengths between\n                  vertices of a given graph.\n                </p>\n                <p>\n                  Such a matrix, called the transitive closure of the digraph,\n                  would allow us to determine in constant time whether the j<sup\n                    >th</sup\n                  >\n                  vertex is reachable from the i<sup>th</sup> vertex.\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                  Loop from k=0 to n-1.\n                  <ul class=\"pl-4 list-unstyled\">\n                    <li>\n                      Loop from i=0 to n-1.\n                      <ul class=\"pl-4 list-unstyled\">\n                        <li>\n                          If R[i][k]==1 then loop from j=0 to n-1.\n                          <ul class=\"pl-4 list-unstyled\">\n                            <li>If R[k][j]==1 then R[i][j]=1.</li>\n                          </ul>\n                        </li>\n                      </ul>\n                    </li>\n                  </ul>\n                </li>\n              </ul>\n              <p>\n                It simply means that, if R[i,k]==1 and R[k,j]==1 then assign\n                R[i,j]=1 and this says that we can reach vertex j starting from\n                vertex i.\n              </p>\n            </div>\n            <div class=\"m-2\">\n              <h4>Time Complexity: O(n<sup>3</sup>)</h4>\n            </div>\n            <div class=\"my-2 p-2\">\n              <strong>Similar posts:</strong>\n              <a href=\"/blogs/dynamicProgramming\">Dynamic Programming</a> |\n              <a href=\"/blogs/floydsAlgorithm\">Floyd's Algorithm</a> |\n              <a href=\"/blogs/knapsackProblem\">Knapsack problem</a>\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='M28%2093h-1l-3-1c-2%200-2%201-1%207l1%209c0%202%203%201%205-1h1l2%202c2%200%202-1%204-8l2-7c0-3-4-3-5-1l-1%202v-2c-1-2-3-3-4%200m16%200c-3%203-6%2014-5%2015%200%202%204%201%204%200%200-3%204-3%204-1l3%202c2%200%202%200%202-5-2-11-5-16-8-11m12-1c-2%200-3%203-3%2011%200%205%200%206%202%206%201%200%202-1%202-3l1-3%202%203c1%203%202%203%203%202%202-1%202-2%201-4v-4c2-3%201-7-1-8h-7m13%201c-3%202-3%206%201%209%203%202%203%203%200%203-4-1-5%201-2%203%202%201%205%201%207-1h2c2%203%205%202%205-1%201-4%203-5%203-1%200%203%202%205%204%203l1-8c0-8%200-9-2-9-1%200-2%200-2%203-1%205-3%205-3%201s0-4-2-4-3%201-3%208l-1%205-2-4-2-2h2c3%200%203-5%200-6-2-1-3-1-6%201m28-1l-5%2014c-1%203-1%203%201%203l3-1%202-2c1-1%202%200%202%201%200%202%201%202%2012%202%2016-1%2015-1%2015-3%200-3%200-3-3-3h-3v-6c0-5%200-6-2-6s-2%200-2%206c0%207%200%207-4%206-3%200-3%200-3-6%200-5%200-6-2-6s-2%200-2%208c0%209-1%209-2%201-2-8-3-10-7-8m39%200c-4%201-5%207-1%209%203%203%203%204%200%204-4-1-5%201-2%203%202%202%205%201%207-1%203-2%202-6%200-8-2%200-3-2-3-3h1c2%203%204%202%204%200s-3-5-4-5l-2%201m20%200l-6%2013c0%204%200%204%202%204l3-1c0-2%204-2%204-1%200%202%2015%202%2016%200h2c2%203%205%202%208%200%203-4%203-4%203-1%201%203%206%204%209%201%203-4%203-12%200-14-3-3-7-2-8%202l-2%203v-3c-2-8-12-2-12%206%200%202-1%203-3%203h-3v-7c0-5%200-6-2-6-1%200-2%201-3%208v9l-2-7c-1-9-3-11-6-9m48%200c-4%200-4%202-4%2010%200%206%200%207%202%207l2-4%201-2%202%203c1%203%202%203%204%202v-8c3-6%200-10-7-8m10%202l-1%209c0%206%200%206%202%206s3-1%203-7c0-5%200-6%202-6s2%201%202%207c0%205%200%206%202%206s2-1%202-5c0-6%201-9%203-9l1-2c0-2%200-2-8-2h-8v3m18%200l-1%209c0%206%200%206%202%206s3-1%203-4l1-3c1%200%202%201%202%203%200%203%200%204%202%204s2%200%202-4l1-9c0-5%200-5-2-5s-3%201-3%203c-1%205-3%205-3%201%200-5-3-6-4-1m21%201l-1%204-1-4c-1-2-2-3-4-3s-2%201-2%203l-1%209c0%205%200%205%202%205l3-2%201-1%201%201%202-1c1-1%201%200%201%201s1%202%203%202%202%200%202-8c0-10-3-13-6-6m46%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/2e2be12828f9995b107bb22d598f2735/ee604/blog70.png","srcSet":"/static/2e2be12828f9995b107bb22d598f2735/69585/blog70.png 200w,\n/static/2e2be12828f9995b107bb22d598f2735/497c6/blog70.png 400w,\n/static/2e2be12828f9995b107bb22d598f2735/ee604/blog70.png 800w,\n/static/2e2be12828f9995b107bb22d598f2735/f3583/blog70.png 1200w,\n/static/2e2be12828f9995b107bb22d598f2735/e4d72/blog70.png 1280w","sizes":"(max-width: 800px) 100vw, 800px"}}}},"pageContext":{"blog":"warshallsAlgorithm","thumbnail":"thumbnails/blog70.png"}},"staticQueryHashes":["2987289216","63159454"]}