Eroxl's Notes
Kruskal's Algorithm

Kruskal's algorithm is a greedy algorithm that finds a minimum spanning tree for a connected, weighted graph. The algorithm sorts edges by weight and iteratively adds the smallest weight edge that does not create a cycle.

The algorithm performs the following steps:

Usage

Kruskal's algorithm is particularly effective for sparse graphs where the number of edges is much smaller than . The algorithm's edge-based approach makes it naturally parallelizable, as independent edges can be processed simultaneously.

When to use Kruskal's:

  • Graphs with few edges relative to vertices
  • When edges are already sorted or can be efficiently sorted
  • When implementing parallel or distributed algorithms
  • Network design problems with linear cost structures

Analysis

Looking at the main operations in Kruskal's algorithm:

  1. Sorting edges: The algorithm sorts all edges by weight using a comparison-based sort, which takes time.
  2. Processing edges: For each edge, the algorithm performs a find operation (twice) and possibly a unionSets operation on the union-find data structure.

With path compression and union by rank optimizations, each union-find operation takes amortized time, where is the inverse Ackermann function. For all practical purposes, .

Processing all edges thus takes time, which is nearly linear.

Combining these operations:

Since for simple graphs, we have , so: