Second-Best Minimum Spanning Tree — Interactive Visualization

MST edge non-tree edge candidate cycle path swapped-out max

Controls

Speed
How it works: build the MST (green), then for each non-tree edge (dashed) close its fundamental cycle, find the maximum edge on the tree path (red), and compute the swap delta w − max. The smallest delta added to the MST weight is the second-best MST.

Swap candidates

edgewpathMaxδ
δ rule: w>max → w−max; w==max → 0; w<max → w−2ndMax.
MST weight
best δ
second-best

Step log

Ready. Press Step to build the MST, then evaluate non-tree-edge swaps one at a time.