转载: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).