Minimum Spanning Tree Calculator
Work out minimum spanning tree instantly with clear inputs, formula shown and shareable results.
About Minimum Spanning Tree Calculator
Kruskal's algorithm sorts the edges by weight and adds each one that joins two different components, tracked with a union-find structure. A spanning tree on n vertices always has exactly n − 1 edges.
Formulas
Kruskal
sort edges ascending, add an edge whenever it connects two distinct components
Tree size
a spanning tree on n vertices has n − 1 edges
Worked example
With the default values below, Minimum Spanning Tree Calculator returns Total weight of the tree of 11.000000. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Edges as from,to,weight triples
- 1,2,4 1,3,2 2,3,1 2,4,5 3,4,8 4,5,3
- Algorithmone of Kruskal (sort edges), Prim (grow from a vertex)
- Kruskal (sort edges)
Results
- Total weight of the tree
- 11.000000
- Edges in the tree
- 2-3 (1), 1-3 (2), 4-5 (3), 2-4 (5)
- Edges chosen
- 4
- Connectivity
- Spanning tree found, the graph is connected
Step by step
- 1Values used
- 2Kruskal
- 3Tree size
- 4Total weight of the tree= 11.000000
- 5Edges in the tree= 2-3 (1), 1-3 (2), 4-5 (3), 2-4 (5)
- 6Edges chosen= 4
- 7Connectivity= Spanning tree found, the graph is connected
Assumptions and limits
- The result is derived only from the 2 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 6 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
For the sample graph?
Edges 2-3 (1), 1-3 (2), 4-5 (3) and 2-4 (5) total 11 across five vertices.
Does Prim give the same weight?
Yes. Any correct algorithm finds a minimum total, though the specific edges can differ when weights tie.
Related Calculators
You might also need
- Binary Tree Nodes CalculatorAlso in Discrete Math, Logic & Number Theory
- Discrete Logarithm CalculatorAlso in Discrete Math, Logic & Number Theory
- Tree Height And Nodes CalculatorAlso in Discrete Math, Logic & Number Theory
- Adjacency Matrix CalculatorAlso in Discrete Math, Logic & Number Theory
- Base 64 Value CalculatorAlso in Discrete Math, Logic & Number Theory
- Bell Number CalculatorAlso in Discrete Math, Logic & Number Theory
