Labs / Computer Science
Minimum Spanning Tree
A minimum spanning tree connects every node using the least total edge weight possible. Press Play to watch the algorithm consider edges cheapest-first — green when an edge joins the tree, red when it would close a wasteful cycle. Drag nodes to reshape the graph, or switch to Connect mode to wire up your own edges.
weight 0accepted 0rejected 0step 0 / 0
What to try
- Run Kruskal, then Prim on the same graph. Do they accept edges in the same order? Do they end up with the same total weight?
- Why does an edge turn red? What do its two endpoints have in common at that moment?
- Drag one node far away from the rest. Which edges does the tree drop, and which cheap new ones does it grab?
- Add a brand-new node with Connect mode. Can a single expensive edge ever be worth adding to the tree?
- Kruskal rejects more edges than Prim on the same graph. What is each algorithm doing differently to avoid cycles?