Kruskal's Algorithm

Minimum spanning tree on an undirected, weighted graph. Toggle between Parallel Fill (edges fill from the middle, sorted by weight) and a basic Step Mode.

500ms
Graph G
vertex
tree edge (MST)
filling / current
rejected (cycle)
Status
Press  Step  or  Play  to begin.
⏱ TIME 0.00
Sorted edges
Connected components
none yet
MST edges
Edit / paste a graph
Format: first line is the number of vertices V and edges E, then E lines each holding an undirected edge u v weight. Vertices are 0 … V−1. Weights are positive numbers (decimals ok).

Optional fixed layout: after the edges, add exactly V more lines of x y — one pair per vertex, in order — to pin down your own layout instead of the automatic one. Any numeric scale works; it's auto-centred and scaled to fit, preserving relative position and aspect ratio. Loading a graph always fills the box back in with its current layout's coordinates so you can nudge them; tick the box above to see the plain format instead.

Mixed-format tolerant: each edge occupies exactly one line. Pasting an unweighted graph here (only two numbers per edge line) just defaults each missing weight to 1, instead of failing to parse.