what is kruskal algorithm

11 months ago 17
Nature

Kruskals algorithm is a minimum spanning tree algorithm that finds the subset of edges of a graph that form a tree that includes every vertex and has the minimum possible total edge weight. It is a greedy algorithm that starts with a forest consisting of the individual nodes of the graph and then finds the cheapest edge from each node and adds it to the forest. This process is repeated until only one tree is in the forest, the minimum spanning tree. The algorithm sorts all edges of the given graph in increasing order and keeps on adding new edges and nodes in the MST if the newly added edge does not form a cycle. Kruskals algorithm can be used to design networks with the least cost and to find the shortest path between two points in a connected weighted graph. The time complexity of Kruskals algorithm is O(E log E), where E is the number of edges in the graph, and the space complexity is O(E) .