Greedy edge selection for MST construction with cycle avoidance feedback.
Easy Explanation
Kruskal builds a minimum spanning tree by taking the cheapest edges that do not create cycles.
Nodes / Edges
0 / 0
Accepted
0
Total Weight
0
Result
Processing
Press Play or Step to start execution.
Progress
considered 0, accepted 0, cycle skips 0
Components
0
MST Edges
n/a
function kruskalMst(nodeCount, edges):
sort edges by ascending weight
parent <- [0..nodeCount-1]
rank <- array(nodeCount, 0)
mst <- []
totalWeight <- 0
for each edge (u, v, w) in sorted edges:
rootU <- find(parent, u)
rootV <- find(parent, v)
if rootU == rootV:
continue
union(parent, rank, rootU, rootV)
append edge to mst
totalWeight <- totalWeight + w
if length(mst) == nodeCount - 1:
break
return { mst, totalWeight }