算法导论 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).
相关文章
相关标签/搜索