Skip to content

Instantly share code, notes, and snippets.

@wkdalsgh192
Created January 4, 2021 01:53
Show Gist options
  • Save wkdalsgh192/d3b79b330401c15595a6b6c7cf228a3f to your computer and use it in GitHub Desktop.
Save wkdalsgh192/d3b79b330401c15595a6b6c7cf228a3f to your computer and use it in GitHub Desktop.
KRUSKAL(G):
A = ∅
For each vertex v ∈ G.V:
MAKE-SET(v)
For each edge (u, v) ∈ G.E ordered by increasing order by weight(u, v):
if FIND-SET(u) ≠ FIND-SET(v):
A = A ∪ {(u, v)}
UNION(u, v)
return A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment