跳到主要内容

東京大学 情報理工学系研究科 コンピュータ科学専攻 2019年8月実施 専門科目II 問題4

Author

zephyr, 祭音Myyura

Description

Consider a connected undirected graph G=(V,E)G = (V, E) with positive edge weights. A subgraph G=(V,E)G' = (V, E') of GG obtained by removing some of the edges in GG is called a spanning tree of GG, if GG' is a tree. The summation of weights of all the edges in a spanning tree is called the weight of the spanning tree. A minimum spanning tree of GG is a spanning tree of GG whose weight is minimum. You can assume appropriate data representation for graphs and trees in the questions below.

Answer the following questions.

(1) Let ee be the edge (or arbitrary one of the edges if there are multiple such edges) with the maximum weight in some arbitrary cycle CC in GG. Prove that there is a minimum spanning tree of GG that does not contain ee.

(2) Consider an arbitrary vertex subset VV' of VV (VV,VV' \neq V, V' \neq \emptyset) for G=(V,E)G = (V, E). Let ee be the edge (or arbitrary one of the edges if there are multiple such edges) with the minimum weight among the edges (u,v)E(u, v) \in E such that uVu \in V' and vVVv \in V - V'. Prove that there is a minimum spanning tree that contains ee. Note that \emptyset denotes an empty set.

(3) Describe an O(E)O(|E|)-time algorithm that finds an arbitrary path between two nodes u,vVu, v \in V on graph G=(V,E)G = (V, E).

(4) Assume that we are given a graph G=(V,E)G = (V, E) and its minimum spanning tree TT. Let GG' be the graph obtained by adding to GG a new edge e=(u,v)∉Ee = (u, v) \not\in E (u,vV)(u, v \in V) with weight w>0w > 0. Describe an O(V)O(|V|)-time algorithm that finds a minimum spanning tree of GG'.

(5) Prove the correctness of the algorithm described in question (4).


考虑一个具有正边权的连通无向图 G=(V,E)G = (V, E)。如果 GG 的一个子图 G=(V,E)G' = (V, E') 是一个树,则称其为 GG 的生成树。生成树中所有边的权重之和称为生成树的权重。GG 的最小生成树是 GG 的一个生成树,其权重最小。你可以在以下问题中假设图和树的适当数据表示。

回答以下问题。

(1) 设 ee 是在 GG 的某个任意循环 CC 中具有最大权重的边(如果有多条这样的边,则任意选取一条)。证明存在一个不包含 eeGG 的最小生成树。

(2) 对于 G=(V,E)G = (V, E) 的任意顶点子集 VV' (VV,VV' \neq V, V' \neq \emptyset),设 ee 是权重最小的边(如果有多条这样的边,则任意选取一条),该边位于 VV'VVV - V' 的顶点之间,即 (u,v)E(u, v) \in E 使得 uVu \in V'vVVv \in V - V'。证明存在一个包含 ee 的最小生成树。注意,\emptyset 表示空集。

(3) 描述一个 O(E)O(|E|) 时间的算法,用于找到图 G=(V,E)G = (V, E) 上的两个节点 u,vVu, v \in V 之间的任意路径。

(4) 假设我们给定一个图 G=(V,E)G = (V, E) 及其最小生成树 TT。设 GG' 是通过向 GG 中添加一条新边 e=(u,v)∉Ee = (u, v) \not\in E (u,vV)(u, v \in V),且权重 w>0w > 0 得到的图。描述一个 O(V)O(|V|) 时间的算法,以找到 GG' 的一个最小生成树。

(5) 证明问题 (4) 中描述的算法的正确性。

题目描述

给定边权均为正的连通无向图 G=(V,E)G=(V,E)。若删除 GG 的若干边得到的子图 G=(V,E)G'=(V,E') 是一棵树,则称其为 GG 的生成树;生成树的权重是其中全部边权之和,权重最小的生成树称为最小生成树。可自行采用合适的图和树数据结构。回答下列问题。

(1)在 GG 的任意一个环 CC 中,取一条权重最大的边 ee;若并列则任选其一。证明存在一棵不含 ee 的最小生成树。

(2)任取非空真子集 VVV'\subset V,在所有一端位于 VV'、另一端位于 VVV\setminus V' 的边中,取一条权重最小的边 ee;若并列则任选其一。证明存在一棵包含 ee 的最小生成树。

(3)描述一个 O(E)O(|E|) 时间算法,在 GG 中找出任意两点 u,vVu,v\in V 之间的一条路径。

(4)已知 GG 及其一棵最小生成树 TT。向 GG 加入一条原来不存在的正权边 e=(u,v)e=(u,v),得到 GG'。描述一个 O(V)O(|V|) 时间算法,求 GG' 的一棵最小生成树。

(5)证明第(4)问算法的正确性。

Kai

(1)

Let CC be an arbitrary cycle in GG, and let ee be the edge in CC with the maximum weight. We need to prove that there exists a minimum spanning tree (MST) that does not contain ee.

Proof

  • Step 1: Let TT be an MST. If eTe\notin T, the claim already holds.
  • Step 2: If eTe\in T, removing ee splits TT into two components. The path CeC-e connects the two endpoints of ee, so it contains an edge ff crossing these components.
  • Step 3: Then T=Te+fT'=T-e+f is a spanning tree. Since ee has maximum weight on CC, w(f)w(e)w(f)\le w(e), hence w(T)w(T)w(T')\le w(T).
  • Step 4: By minimality of TT, equality holds. Thus TT' is an MST and does not contain ee.

Therefore, there exists a minimum spanning tree that does not contain the edge ee.

(2)

Consider an arbitrary vertex subset VV' of VV (VV,VV' \neq V, V' \neq \emptyset). Let ee be the edge with the minimum weight among the edges (u,v)E(u, v) \in E such that uVu \in V' and vVVv \in V - V'. We need to prove that there is a minimum spanning tree that contains ee.

Proof

  • Step 1: Let TT be an MST. If eTe\in T, the claim already holds.
  • Step 2: Otherwise, adding ee to TT creates a cycle. This cycle crosses the cut (V,VV)(V',V-V') through ee and at least one other edge fTf\in T.
  • Step 3: Since ee is a minimum-weight crossing edge, w(e)w(f)w(e)\le w(f). Thus T=Tf+eT'=T-f+e is a spanning tree with w(T)w(T)w(T')\le w(T), so equality holds and TT' is an MST containing ee.

Thus, there is a minimum spanning tree that contains the edge ee.

(3)

Describe an O(E)O(|E|)-time algorithm that finds an arbitrary path between two nodes u,vVu, v \in V on graph G=(V,E)G = (V, E).

Algorithm

  1. Initialization: Initialize a stack (or queue), mark all vertices as unvisited, and initialize a predecessor array parent.
  2. Depth-First Search (DFS):
    • Push the starting vertex uu onto the stack and mark it as visited.
    • While the stack is not empty:
      • Pop a vertex ww from the stack.
      • If w=vw = v, follow parent pointers from vv to uu and reverse them to return the path.
      • For each adjacent unvisited vertex xx of ww, set parent[x] = w, push xx, and mark it as visited.
  3. Termination: If the search ends without finding vv, return "No Path".

DFS takes O(V+E)=O(E)O(|V|+|E|)=O(|E|) because GG is connected, and path reconstruction takes O(V)O(|V|).

(4)

Assume that we are given a graph G=(V,E)G = (V, E) and its minimum spanning tree TT. Let GG' be the graph obtained by adding to GG a new edge e=(u,v)∉Ee = (u, v) \not\in E (u,vV)(u, v \in V) with weight w>0w > 0. Describe an O(V)O(|V|)-time algorithm that finds a minimum spanning tree of GG'.

Algorithm

  1. Step 1: Add the new edge e=(u,v)e = (u, v) to the MST TT. This will create a cycle in the tree.
  2. Step 2: Find the maximum weight edge ff in this cycle.
  3. Step 3: If f=ef = e, then the original MST TT is still valid.
  4. Step 4: If fef \neq e, remove ff from the cycle. The resulting graph is a tree and is the new MST.

The time complexity is O(V)O(|V|) because finding the cycle in a tree and identifying the maximum weight edge in the cycle can be done in linear time.

(5)

Prove the correctness of the algorithm described in question (4).

Proof

  • Step 1: Adding ee to TT creates the unique cycle CC, and T=T+efT'=T+e-f is a spanning tree. Since ff is a maximum-weight edge of CC, w(e)w(f)w(e)\le w(f) and w(T)w(T)w(T')\le w(T).
  • Step 2: Let SS be any spanning tree of GG'. If eSe\notin S, then SS is a spanning tree of GG, so w(S)w(T)w(T)w(S)\ge w(T)\ge w(T').
  • Step 3: If eSe\in S, removing ee defines a cut. The uu--vv path CeC-e in TT contains an edge gg crossing this cut. Then Se+gS-e+g is a spanning tree of GG, and w(g)w(f)w(g)\le w(f).
  • Step 4: Hence w(T)w(S)w(e)+w(g)w(S)w(e)+w(f)w(T)\le w(S)-w(e)+w(g)\le w(S)-w(e)+w(f), so w(T)=w(T)+w(e)w(f)w(S)w(T')=w(T)+w(e)-w(f)\le w(S). Thus TT' is an MST of GG'.

Knowledge

最小生成树 图论 DFS BFS 贪心算法

解题技巧和信息

  • 最小生成树的关键性质可以通过切割定理和环路定理进行理解。
  • 对于图中的路径查找问题,DFS 和 BFS 都是常用的线性时间算法。
  • 解决最小生成树更新问题时,可以通过引入新边后检查形成的环并删除最大边的方式实现最小生成树的维护。

重点词汇

  • Minimum Spanning Tree (MST) 最小生成树
  • Cycle
  • Cut Property 切割定理
  • Depth-First Search (DFS) 深度优先搜索
  • Breadth-First Search (BFS) 广度优先搜索

参考资料

  1. Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press. Chap. 23: Minimum Spanning Trees.
  2. Sedgewick, R., & Wayne, K. (2011). Algorithms (4th ed.). Addison-Wesley. Sections on Graph Algorithms.