1. Gyanastra
  2. Algorithms
  3. Minimum Spanning Trees: Kruskal, Prim and Union-Find
  4. Spanning Trees, MSTs and the Cut and Cycle Properties
Free lesson, no account needed 9 min read 10 practice questions after it
Asked in past papers8 times
  • GATE CSE201620122005200019971996
  • UGC NET20172008

Algorithms · Minimum Spanning Trees: Kruskal, Prim and Union-Find

Spanning Trees, MSTs and the Cut and Cycle Properties

Let G=(V,E)G=(V,E) be a connected, undirected graph with ∣V∣=n|V|=n vertices and ∣E∣=m|E|=m edges. Each edge ee carries a weight w(e)w(e) (can be negative; can be equal to another edge's weight).

Spanning tree. A spanning tree TT of GG is a subgraph that

  1. is connected,
  2. is acyclic (a tree), and
  3. contains all nn vertices of GG.

Equivalently, TT is a set of exactly n−1n-1 edges of GG that connects all vertices.

Minimum spanning tree (MST). A spanning tree TT whose total weight w(T)=∑e∈Tw(e)w(T)=\sum_{e\in T} w(e) is minimum over all spanning trees of GG.

Facts you must be able to quote:

FactStatementWhy
Edge countEvery spanning tree has exactly n−1n-1 edgesA tree on nn vertices has n−1n-1 edges
ExistenceA spanning tree exists iff GG is connectedStandard
UniquenessIf all edge weights are distinct, the MST is unique (the converse is false: ties may or may not give several MSTs)Distinct weights make every cut/cycle comparison strict; tied edges can be swapped but need not be on a common cut or cycle
Number of spanning treesCayley: nn−2n^{n-2} for KnK_nNot needed for MST weight, only for counting questions
MST of a treeThe tree itselfOnly one spanning tree exists

Convention note (important for GATE). Two indexing conventions appear in textbooks:

  • 1-based style (CLRS, most GATE questions): vertices numbered 1,…,n1,\dots,n; adjacency matrix A[1..n][1..n]A[1..n][1..n]; A[i][j]=∞A[i][j]=\infty if no edge.
  • 0-based style (most program code): vertices 0,…,n−10,\dots,n-1; matrix A[0..n−1][0..n−1]A[0..n-1][0..n-1].

GATE questions almost always use 1-based vertex labels (v1,…,vnv_1,\dots,v_n) and distinct integer weights. When weights tie, the question either asks "which of the following is an MST" (any valid answer) or specifies a tie-breaking rule. Always state your tie-break.


2. The Two Structural Properties

These two lemmas are the entire theoretical foundation of every MST algorithm. Learn the proofs — they are two lines each and are asked as "prove or state".

2.1 Cut Property

Definition. A cut (S,V∖S)(S, V\setminus S) is a partition of VV into two non-empty sets. An edge crosses the cut if one endpoint is in SS and the other in V∖SV\setminus S.

Cut Property. For any cut (S,V∖S)(S, V\setminus S), the minimum-weight edge crossing the cut belongs to some MST. If that edge is unique (strictly lightest), it belongs to every MST.

Proof (two lines). Let e=(u,v)e=(u,v) be a lightest edge crossing the cut, and let TT be any MST. If e∈Te\in T we are done. Otherwise T+eT+e contains a unique cycle; that cycle must cross the cut an even number of times, so it contains some other crossing edge e′e'. Then T′=T+e−e′T' = T+e-e' is a spanning tree with w(T′)=w(T)−w(e′)+w(e)≤w(T)w(T')=w(T)-w(e')+w(e)\le w(T), so T′T' is also an MST and contains ee. □\square

2.2 Cycle Property

Cycle Property. For any cycle CC in GG, if ee is a strictly heaviest edge on CC, then ee belongs to no MST.

Proof (two lines). Suppose an MST TT contains ee. Removing ee from TT splits TT into two components; the cycle CC must contain some other edge e′e' with endpoints in different components (since CC crosses the cut made by removing ee). Then T−e+e′T-e+e' is a spanning tree with w(T−e+e′)=w(T)−w(e)+w(e′)<w(T)w(T-e+e')=w(T)-w(e)+w(e')<w(T), contradicting minimality of TT. □\square

How to use them in one line each:

  • Cut property → "the cheapest edge leaving any set of already-chosen vertices is safe to add" — this is exactly Prim's rule.
  • Cycle property → "the heaviest edge on any cycle can be discarded" — this is exactly Kruskal's rejection rule and reverse-delete.
Pages 1–2 of 2