CalcWorldHub
Free online calculator · no signup

Undirected minimum spanning tree calculator

Connect all nodes with the minimum total edge weight while excluding cycles.

4,000 tools
Undirected minimum spanning tree calculator — Node count, Undirected edges as first second weight and calculation method
Undirected minimum spanning tree calculator: inputs and calculation method.

How to use this calculator

Connect all nodes with the minimum total edge weight while excluding cycles.

  1. Enter Node count, Undirected edges as first second weight. Match the units shown beside each field and review the result together with the assumptions below.
  2. Read the worked example below to check the expected input format and result.
  3. Compare another scenario by changing one input at a time. Use Reset to return to the starting values.
Calculation guide

Undirected minimum spanning tree explained

Find the minimum total edge weight that connects every node in a weighted undirected graph without forming a cycle. Negative edge weights are permitted.

Minimum spanning-tree weight7weight units
Minimum spanning-tree weight: 7 weight units in the worked scenario.

How the calculation works

Kruskal sorted-edge union-find selection

Sort undirected edges by weight and keep an edge only when it joins two previously separate components. Union-find tracks those components. A connected result has exactly n−1 selected edges, whose weights form the reported tree cost.

Set up the calculation

n — Node count
Node count. Enter a whole number.
e — Undirected edges as first second weight
Enter one undirected edge per row as endpoint, endpoint, weight; endpoint labels must match the declared node set.

Limits of this model

The graph must be connected; edge direction is ignored and negative weights are allowed. This is not the shortest route through all nodes.

Check this example

Node count = 4; Undirected edges as first second weight = 1 2 3, 1 3 1, 2 3 2, 2 4 4, 3 4 5.

  • Minimum spanning-tree weight: 7 weight units
  • Selected edges: 1—3 (1); 2—3 (2); 2—4 (4)

Interpreting the result

The total is the sum of the selected connecting edges, not a route length through every node. If several trees share the same minimum weight, a different edge order may return another equally optimal tree.

Frequently asked questions

Can a spanning tree contain a cycle?

No.

Does it choose a travel order?

No, it selects connecting edges.

Are multiple equally light trees possible?

Yes; original edge order breaks tied weights.

How do I use the Undirected minimum spanning tree calculator?

Enter Node count, Undirected edges as first second weight. Match the units shown beside each field and review the result together with the assumptions below.

What is a worked example of Undirected minimum spanning tree?

Node count = 4; Undirected edges as first second weight = 1 2 3, 1 3 1, 2 3 2, 2 4 4, 3 4 5. Minimum spanning-tree weight: 7 weight units Selected edges: 1—3 (1); 2—3 (2); 2—4 (4)