Algorithm visualizer
Pick an algorithm, enter your own numbers or use a preset, then step through the run. The pseudocode and the explanation follow each step.
Sort the edges lightest first and keep each edge that joins two different components. Skipping the rest avoids cycles.
Precondition: The graph must be undirected.
Change one weight so the lightest edge is no longer taken. Which edge replaces it in the tree?
Step 1 of 16
Total weight so far0
Sort the edges from lightest to heaviest. Each node starts in its own component.