0% found this document useful (0 votes)
30 views

Minimum Spanning Trees: Correctness of Prim's Algorithm (Part I)

Prim's algorithm outputs a spanning tree by maintaining the invariant that the growing tree T spans the set of vertices X. It cannot get stuck with X not equal to the full vertex set V, since that would imply the graph is disconnected by the Empty Cut Lemma. Additionally, the algorithm cannot create cycles in T, since whenever a new edge e is added that crosses the cut (X, V-X), e must be the only such edge by the Lonely Cut Corollary and therefore cannot create a cycle.

Uploaded by

sirj0_hn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Minimum Spanning Trees: Correctness of Prim's Algorithm (Part I)

Prim's algorithm outputs a spanning tree by maintaining the invariant that the growing tree T spans the set of vertices X. It cannot get stuck with X not equal to the full vertex set V, since that would imply the graph is disconnected by the Empty Cut Lemma. Additionally, the algorithm cannot create cycles in T, since whenever a new edge e is added that crosses the cut (X, V-X), e must be the only such edge by the Lonely Cut Corollary and therefore cannot create a cycle.

Uploaded by

sirj0_hn
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Minimum

Spanning Trees

Correctness of Prim’s
Algorithms: Design
and Analysis, Part II Algorithm (Part I)
Cuts
Claim: Prim’s algorithm outputs a spanning tree.

Definition: A cut of a graph G = (V , E ) is a partition of V into 2


non-empty sets.

A B

Edges that
cross (A, B)

Tim Roughgarden
Quiz on Cuts
Question: Roughly how many cuts does a graph with n vertices
have?

A) n C) 2n (for each vertex, choose whether in A or in B)


B) n2 D) nn

Tim Roughgarden
Empty Cut Lemma
Empty Cut Lemma: A graph is not connected ⇐⇒ ∃ cut (A, B)
with no crossing edges.
Proof: (⇐) Assume the RHS. Pick any u ∈ A and v ∈ B. Since no
edges cross (A, B) there is no u, v path in G . ⇒ G not connected.
A B

u v

No crossing edges, so no u − v path

(⇒) Assume the LHS. Suppose G has no u − v path. Define


A = {Vertices reachable from u in G } (u’s connected component)
B = {All other vertices} (all other connected components)
Note: No edges cross cut (A, B) (otherwise A would be bigger!)
A B

u v

QED!

Tim Roughgarden
Two Easy Facts
Double-Crossing Lemma: Suppose the cycle C ⊆ E has an edge
crossing the cut (A, B): then so does some other edge of C .

A B
e

Lonely Cut Corollary: If e is the only edge crossing some cut


(A, B), then it is not in any cycle. [If it were in a cycle, some other
edge would have to cross the cut!]

Tim Roughgarden
Proof of Part I
Claim: Prim’s algorithm outputs a spanning tree.
[Not claiming MST yet]
Proof: (1) Algorithm maintains invariant that T spans X
[straightforward induction - you check]
T lonely in this cut!

X V −X
e

(2) Can’t get stuck with X 6= V


[otherwise the cut (X , V − X ) must be empty; by Empty Cut
Lemma input graph G is disconnected]
(3) No cycles ever get created in T . Why? Consider any iteration,
with current sets X and T . Suppose e gets added.
Key point: e is the first edge crossing (X , V − X ) that gets added
to T ⇒ its addition can’t create a cycle in T (by Lonely Cut
Corollary). QED!
Tim Roughgarden

You might also like