Kruskal’s algorithm
What is Kruskal’s algorithm?
Kruskal's algorithm is a popular method in greedy graph theory used to find the Minimum Spanning
Tree (MST) for a connected, weighted graph. The MST is a subgraph that connects all the vertices of the
graph with the minimum possible total edge weight, without any cycles.
How to find MST using Kruskal’s algorithm?
•Sort all the edges in a non-decreasing order of their weight.
•Pick the smallest edge. Check if it forms a cycle with the spanning tree formed so far. If the cycle is
not formed, include this edge. Else, discard it.
Graph
Graph
Time Complexity:
O(E * log E) or O(E * log V)
Disadvantages of Kruskal's Algorithm:
•Inefficient for dense graphs due to the O(E log E) sorting time.
•Requires an efficient cycle detection method, adding complexity.
•Not suitable for dynamic graphs with frequent edge updates.
•High memory consumption for storing all edges in large graphs.
•No continuous path generation since it merges components instead of growing a single tree.