← Back

Kruskal Algorithm

Greedy add edges by weight avoiding cycles via DSU.

graphsmstgreedyUpdated 2025-09-01

Steps

  • Sort edges
  • Iterate & union if diff sets

DSU

  • Union by rank
  • Path compression