東京大学 情報理工学系研究科 コンピュータ科学専攻 2019年8月実施 専門科目II 問題4
Author
zephyr, 祭音Myyura
Description
Consider a connected undirected graph with positive edge weights. A subgraph of obtained by removing some of the edges in is called a spanning tree of , if 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 is a spanning tree of whose weight is minimum. You can assume appropriate data representation for graphs and trees in the questions below.
Answer the following questions.
(1) Let be the edge (or arbitrary one of the edges if there are multiple such edges) with the maximum weight in some arbitrary cycle in . Prove that there is a minimum spanning tree of that does not contain .
(2) Consider an arbitrary vertex subset of () for . Let be the edge (or arbitrary one of the edges if there are multiple such edges) with the minimum weight among the edges such that and . Prove that there is a minimum spanning tree that contains . Note that denotes an empty set.
(3) Describe an -time algorithm that finds an arbitrary path between two nodes on graph .
(4) Assume that we are given a graph and its minimum spanning tree . Let be the graph obtained by adding to a new edge with weight . Describe an -time algorithm that finds a minimum spanning tree of .
(5) Prove the correctness of the algorithm described in question (4).
考虑一个具有正边权的连通无向图 。如果 的一个子图 是一个树,则称其为 的生成树。生成树中所有边的权重之和称为生成树的权重。 的最小生成树是 的一个生成树,其权重最小。你可以在以下问题中假设图和树的适当数据表示。
回答以下问题。
(1) 设 是在 的某个任意循环 中具有最大权重的边(如果有多条这样的边,则任意选取一条)。证明存在一个不包含 的 的最小生成树。
(2) 对于 的任意顶点子集 (),设 是权重最小的边(如果有多条这样的边,则任意选取一条),该边位于 和 的顶点之间,即 使得 且 。证明存在一个包含 的最小生成树。注意, 表示空集。
(3) 描述一个 时间的算法,用于找到图 上的两个节点 之间的任意路径。
(4) 假设我们给定一个图 及其最小生成树 。设 是通过向 中添加一条新边 ,且权重 得到的图。描述一个 时间的算法,以找到 的一个最小生成树。
(5) 证明问题 (4) 中描述的算法的正确性。
题目描述
给定边权均为正的连通无向图 。若删除 的若干边得到的子图 是一棵树,则称其为 的生成树;生成树的权重是其中全部边权之和,权重最小的生成树称为最小生成树。可自行采用合适的图和树数据结构。回答下列问题。
(1)在 的任意一个环 中,取一条权重最大的边 ;若并列则任选其一。证明存在一棵不含 的最小生成树。
(2)任取非空真子集 ,在所有一端位于 、另一端位于 的边中,取一条权重最小的边 ;若并列则任选其一。证明存在一棵包含 的最小生成树。
(3)描述一个 时间算法,在 中找出任意两点 之间的一条路径。
(4)已知 及其一棵最小生成树 。向 加入一条原来不存在的正权边 ,得到 。描述一个 时间算法,求 的一棵最小生成树。
(5)证明第(4)问算法的正确性。
Kai
(1)
Let be an arbitrary cycle in , and let be the edge in with the maximum weight. We need to prove that there exists a minimum spanning tree (MST) that does not contain .
Proof
- Step 1: Let be an MST. If , the claim already holds.
- Step 2: If , removing splits into two components. The path connects the two endpoints of , so it contains an edge crossing these components.
- Step 3: Then is a spanning tree. Since has maximum weight on , , hence .
- Step 4: By minimality of , equality holds. Thus is an MST and does not contain .
Therefore, there exists a minimum spanning tree that does not contain the edge .
(2)
Consider an arbitrary vertex subset of (). Let be the edge with the minimum weight among the edges such that and . We need to prove that there is a minimum spanning tree that contains .
Proof
- Step 1: Let be an MST. If , the claim already holds.
- Step 2: Otherwise, adding to creates a cycle. This cycle crosses the cut through and at least one other edge .
- Step 3: Since is a minimum-weight crossing edge, . Thus is a spanning tree with , so equality holds and is an MST containing .
Thus, there is a minimum spanning tree that contains the edge .
(3)
Describe an -time algorithm that finds an arbitrary path between two nodes on graph .
Algorithm
- Initialization: Initialize a stack (or queue), mark all vertices as unvisited, and initialize a predecessor array
parent. - Depth-First Search (DFS):
- Push the starting vertex onto the stack and mark it as visited.
- While the stack is not empty:
- Pop a vertex from the stack.
- If , follow
parentpointers from to and reverse them to return the path. - For each adjacent unvisited vertex of , set
parent[x] = w, push , and mark it as visited.
- Termination: If the search ends without finding , return "No Path".
DFS takes because is connected, and path reconstruction takes .
(4)
Assume that we are given a graph and its minimum spanning tree . Let be the graph obtained by adding to a new edge with weight . Describe an -time algorithm that finds a minimum spanning tree of .
Algorithm
- Step 1: Add the new edge to the MST . This will create a cycle in the tree.
- Step 2: Find the maximum weight edge in this cycle.
- Step 3: If , then the original MST is still valid.
- Step 4: If , remove from the cycle. The resulting graph is a tree and is the new MST.
The time complexity is 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 to creates the unique cycle , and is a spanning tree. Since is a maximum-weight edge of , and .
- Step 2: Let be any spanning tree of . If , then is a spanning tree of , so .
- Step 3: If , removing defines a cut. The -- path in contains an edge crossing this cut. Then is a spanning tree of , and .
- Step 4: Hence , so . Thus is an MST of .
Knowledge
最小生成树 图论 DFS BFS 贪心算法
解题技巧和信息
- 最小生成树的关键性质可以通过切割定理和环路定理进行理解。
- 对于图中的路径查找问题,DFS 和 BFS 都是常用的线性时间算法。
- 解决最小生成树更新问题时,可以通过引入新边后检查形成的环并删除最大边的方式实现最小生成树的维护。
重点词汇
- Minimum Spanning Tree (MST) 最小生成树
- Cycle 环
- Cut Property 切割定理
- Depth-First Search (DFS) 深度优先搜索
- Breadth-First Search (BFS) 广度优先搜索
参考资料
- Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press. Chap. 23: Minimum Spanning Trees.
- Sedgewick, R., & Wayne, K. (2011). Algorithms (4th ed.). Addison-Wesley. Sections on Graph Algorithms.