Data Structure
Definition
在 中,找尋一組的subset 使 ,且為acyclic
,所以必定是一顆tree。
Growing a MST
找尋MST的做法,可以用greedy的方式,演算法如下:
GENERIC-MST(G, w)
A = ∅
while A does not form a spanning tree
find an edge (u, v) that is safe for A
A = A ∪ {(u, v)}
return A
我們要證明的就是在這個步驟做完,形成的spanning tree就是一顆MST。
Proofs
在證明GENERIC-MST之前,我們先定義幾個term:cut & light edge。
Cut
一個undirected grpah 的一個Cut ,代表的一個partition,也就是說 , or 。
另外對於一個edge set ,如果裡面的edge不cross (有一個edge ,其中 and ) 一個cut ,則我們稱 respects 。
Light edge
如果一個edge 是 cross 一個 cut 的edge裡面,weight 最低的edge,則被稱為light edge。
Theorem 1
Statement: Let be a connected, unidrected graph with a real-valued weight function defined on . Let A be a subset of that is included in some minimum spanning tree for , let be any cut of that respects , and let be a light edge crossing . Then, edge is safe for .
Proof:
我們可以利用反證法(proof by contradiction)來證明。我們定義light edge 加入形成的tree為,如果edge 不safe,則存在一個crossing edge ,加入形成,使得。
但,而,因為,可得到,而已知是light edge,故任一crossing edge ,,因此與已知矛盾,故假設錯誤,因此light edge 對A safe。
Corollary 1
Statement: Let be a connected, undirected graph with a real-valued weight function defined on . Let A be a subset of that is included in some minimum spanning tree for , and let be a connected component (tree) in the forest . If is a light edge connecting to some other component in , then is safe for .
Proof:
The cut respect ,所以根據theorem 1,light edge is safe for 。