算法導論 Exercises 23.1

轉載:http://blog.csdn.net/anye3000/article/details/12091125算法

Exercises 23.1 - 算法導論.英文第3版 安全

若有不足或疑問, 歡迎指正. 

 

 

Exercises 23.1-1
Let (u, v) be a minimum-weight edge in a connected graph G. Show that (u, v)  belongs to some minimum spanning tree of G.
 
根據定理 Theorem 23.1  可知, 利用 cut (S, V-S) 將 u, v 兩點分割開來, 因爲 (u, v) 是最輕邊, 因此 (u, v) 屬於最小生成樹.  
 
 
Exercises 23.1-2
Professor Sabatier conjectures the following converse of Theorem 23.1. Let G = (V, E) be a connected, undirected graph with a real-valued weight function w defined on E. Let A be a subset of E that is included in some minimum spanning tree for G, let (S, V - S) be any cut of G that respects A, and let (u, v) be a safe edge for A crossing (S, V - S). Then, (u, v) is a light edge for the cut. Show that the professor's conjecture is incorrect by giving a counterexample.
 
由分析可得知, 任何無向連通圖, 穿過 cut 的最輕邊必定是安全的, 但非最輕邊一樣有可能安全, 以下.

 

 

對於該 cut 來講, 雖然 (A, C) 是安全的, 但不是最輕邊. 
 
 
Exercises 23.1-3
Show that if an edge (u, v) is contained in some minimum spanning tree, then it is a light edge crossing some cut of the graph.
 
(u, v) 屬於最小生成樹 A, 假設 cut 不影響 A 中除 (u, v) 外的其餘邊, 既 A 中只有 (u, v) 穿過該 cut,    
因此 (u, v) 對該 cut 是最輕邊, 不然 (u, v) 不屬於 A. 
 
 
Exercises 23.1-4
Give a simple example of a connected graph such that the set of edges { (u, v) : there exists a cut (S, V - S) such that (u, v) is a light edge crossing (S, V - S) } does not form a minimum spanning tree.
 
三角形三條邊權重相同的狀況, 每條邊在某種 cut 中均是最輕, 既結果中存在環, 因此不是最小生成樹.  
 
 
Exercises 23.1-5
Let  e be a maximum-weight edge on some cycle of connected graph G = (V, E). Prove that there is a minimum spanning tree of G' = (V, E - { e}) that is also a minimum spanning tree of G. That is, there is a minimum spanning tree of G that does not include  e.
 
由於在某些圈中 e 是權重最大的邊, 去掉 e 後圈中的頂點仍然可連通. 假設最小生成樹 A 中不包含 e, 邊集合 是 T, 一樣假設包含 e 的狀況, 邊集合爲 T', 既 T' 是 T 去除某條邊 x, 並加入 e. (最小生成樹邊數是常量 V-1)
w(T') = w(T) - w(x) + w(e),
          >= w(T)
因此可知最小生成樹 A 不包含 e.
 

Exercises 23.1-6
Show that a graph has a unique minimum spanning tree if, for every cut of the graph, there is a unique light edge crossing the cut. Show that the converse is not true by giving a counterexample.
 
假設存在兩個最小生成樹 T 和 T'. 任何邊 e 屬於 T, 若是從 T 中移除 e, 則 T 變得不連通, 造成 cut (S, V - S), 根據練習 23.1-3 可知, e 是穿過 cut(S, V - S) 最輕邊. 假設邊 x 屬於 T', 並穿過 cut (S, V - S), 則 x 一樣是最輕邊. 因爲穿過 cut(S, V - S) 的最輕邊惟一. 既 e 和 x 是同一條邊. 因此 e 也屬於 T', 因爲咱們選擇 e 是任意的, 全部在 T 中的邊, 一樣在 T' 中. 既最小生成樹惟一.  
將條件和結論調換則不成立, 以下.

 

 

 

Exercises 23.1-7
Argue that if all edge weights of a graph are positive, then any subset of edges that connects all vertices and has minimum total weight must be a tree. Give an example to show that the same conclusion does not follow if we allow some weights to be nonpositive.
 
假設邊的子集 T 中存在環, 則某兩點之間存在多條通路, 移除其中一條通路, 子集 A' 仍然連通全部點. 由於邊的權重爲正, 既 w(A') < w(A), 結論與條件矛盾, 因此 T 是樹. 
若是邊的權重准許爲負, 則子集 T 不必定是樹, 圖中三條邊總權重最小, 以下.

 

 

 
Exercises 23.1-8
Let T be a minimum spanning tree of a graph G, and let L be the sorted list of the edge weights of T . Show that for any other minimum spanning tree T' of G, the list L is also the sorted list of edge weights of T'.
 
假設最小生成樹有 n 條邊, 存在兩個最小生成樹 T 和 T', 用 w(e) 表示邊的權值.
T 權值遞增排列 w(a1) <= w(a2) <= ... w(an)
T' 權值遞增排列 w(b1) <= w(b2) <= ... w(bn)
假設 i 是兩個列表中, 第一次出現邊不一樣的位置, 既 ai ≠ bi, 先假定 w(ai) >= w(bi).
 
狀況1, 若是 T 中含有邊 bi, 因爲 ai 和 bi 在列表 i 位置以前都是相同的, 若含有 bi 則必定在 i 位置後, 既有 j > i 使得 w(aj) = w(bi). 獲得 w(bi) = w(aj) >= w(ai) >= w(bi), 既 w(bi) = w(aj) = w(ai), 故 i 位置處邊的權值相同.
 
狀況2, 若是 T 不包含邊 bi, 則把 bi 加到 T 中, 會在某處造成一個圈. 因爲 T 是最小生成樹, 圈內任何一條邊的權值都小於等於 w(bi), 另外這個圈中一定存在 aj 不在 T' 中, 得出 w(aj) <= w(bi) 且 j > i. 所以 w(bi) <= w(ai) <= w(aj) <= w(bi), 既 w(bi) = w(aj) = w(ai), 故 i 位置處邊的權值仍相同.
 
 
Exercises 23.1-9
Let T be a minimum spanning tree of a graph G = (V, E), and let V' be a subset of V. Let T' be the subgraph of T induced by V', and let G' be the subgraph of G induced by V'. Show that if T' is connected, then T' is a minimum spanning tree of G'.
 
用 cut (V', V - V') 分割圖 G, 該 cut 必定不影響 T', 且 T' 是 T 的子集, 因此 T' 對於 G' 是安全的. 若是 T' 是連通的, 則 T' 必定是 G' 的最小生成樹.
 
 
Exercises 23.1-10
Given a graph G and a minimum spanning tree T , suppose that we decrease the weight of one of the edges in T . Show that T is still a minimum spanning tree for G. More formally, let T be a minimum spanning tree for G with edge weights given by weight function w. Choose one edge (x, y) ∈ T and a positive number k, and define the weight function w' by

 

 

Show that T is a minimum spanning tree for G with edge weights given by w'.
 
因爲 w(T) - k = w'(T) 且 k 是正數,  假設 X 是任意其餘生成樹, 有 w(T) <= w(X). 若是 X 含有 (x, y), 則 w'(T) <= w'(X), 若是 X 不含有 (x, y), 則 w'(T) <= w'(X) - k, 兩種狀況 w'(T) 均最小. 另外, 減小權值後 T 的其餘屬性無變化, 仍然連通全部頂點, 而且無環. 因此使用 w' 計算權值, T 依然是最小生成樹.   
 
 
Exercises 23.1-11 *
Given a graph G and a minimum spanning tree T , suppose that we decrease the weight of one of the edges not in T . Give an algorithm for finding the minimum spanning tree in the modified graph.
 
假設 (u, v) 不在最小生成樹 T 中, 減少 (u, v) 權值後, 造成新的最小生成樹 T'. 可能的狀況是 T' 包含 (u, v) 或者 T' = T 保持不變. 算法只需尋找 T 中 u -> v 路徑中權值最重邊 x, 若是該邊權值大於 (u, v), 則 T' = T - x + (u, v). 若是 (u, v) 權值大於 x, 則 T' = T. 路徑可用 DFS 算法求得, 從 u 開始 v 結束. 由於 T 是最小生成樹, 因此路徑惟一, 時間 O(V+E).
相關文章
相關標籤/搜索