Computer ScienceAlgorithmsAdvanced

Minimum Spanning Tree

Also known as:MSTMinimum Weight Spanning TreeMinimum Connector

A Minimum Spanning Tree (MST) of a connected, undirected, weighted graph is a spanning subgraph that connects all vertices with the minimum possible total edge weight, containing exactly V-1 edges for V vertices and no cycles. The MST is not necessarily unique if multiple edges have equal weights. MSTs are used in network design (telecom, power grids), cluster analysis, approximation algorithms for the Travelling Salesman Problem, and Euclidean geometry.

Key Formula

MST cost = sum of edge weights in tree T, where tree has (|V| - 1) edges

LaTeX: \text{MST cost} = \sum_{e \in T} w(e), \quad |E_T| = |V| - 1

SymbolMeaningUnit
TSet of edges in the minimum spanning treedimensionless
w(e)Weight of edge ecost units
|V|Number of vertices in the graphdimensionless
|E_T|Number of edges in the spanning treedimensionless

Worked Example

Problem

Find the MST of a graph with 4 vertices and edges: A-B=1, A-C=4, B-C=2, B-D=5, C-D=3. Use Kruskal's algorithm.

Solution

Step 1: Sort edges by weight: A-B=1, B-C=2, C-D=3, A-C=4, B-D=5. Step 2: Initialize each vertex as its own component: {A}, {B}, {C}, {D}. Step 3: Add A-B=1. Merges {A} and {B} → {A,B}. MST edges: {A-B}. Step 4: Add B-C=2. Merges {A,B} and {C} → {A,B,C}. MST edges: {A-B, B-C}. Step 5: Add C-D=3. Merges {A,B,C} and {D} → {A,B,C,D}. MST edges: {A-B, B-C, C-D}. Step 6: We have V-1=3 edges. Stop. Skip remaining edges (would form cycles).

Answer

MST = {A-B (1), B-C (2), C-D (3)}. Total MST cost = 1 + 2 + 3 = 6.

MST Algorithms: Kruskal's vs Prim's

PropertyKruskal'sPrim's
ApproachSort edges, add greedilyGrow tree from a vertex
Data StructureUnion-Find (Disjoint Set)Priority Queue (min-heap)
Time ComplexityO(E log E)O(E log V) with binary heap
Best forSparse graphsDense graphs
Handles disconnected?Finds MSF (forest)No — requires connected graph
Edge sorting needed?YesNo

Interactive Tools

VisuAlgo – Minimum Spanning Tree

Interactive step-by-step visualization of Kruskal's and Prim's algorithms

Open Tool

Brilliant.org – Minimum Spanning Tree

Guided problem sets on MST theory and algorithms

Open Tool

Khan Academy – Graph Algorithms

Conceptual coverage of spanning trees and greedy graph algorithms

Open Tool
Diagram of a minimum spanning tree highlighted within a weighted undirected graph

Wikimedia Commons, CC BY-SA

Related Terms

"Spanning" comes from the English verb "to span" (Old English spannan, to stretch across), meaning connecting all vertices. "Minimum" is from Latin minimus (smallest). The concept was studied by Otakar Borůvka in 1926 for the Moravian electrical grid. Kruskal's algorithm was published by Joseph Kruskal in 1956, and Prim's algorithm by Robert Prim in 1957.

graphspanning-treegreedynetworkalgorithmscomputer-science