跳到主要内容

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

Author

祭音Myyura (co-authored with GPT 5.6 SOL)

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 的生成树;生成树的权重是其中全部边权之和,权重最小的生成树称为最小生成树。可自行采用合适的图和树数据结构。回答下列问题。

(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)

取任意最小生成树 TT。若 eTe\notin T 即得结论。否则删除 eeTT 分成两部分,路径 CeC-e 必含跨越这两部分的边 ff。由于 w(f)w(e)w(f)\le w(e)Te+fT-e+f 是权重不大于 TT 的生成树,因此也是最小生成树,且不含 ee

(2)

取最小生成树 TT。若 eTe\in T 即得结论。否则 T+eT+e 产生唯一环,该环除 ee 外还含另一条跨越割 (V,VV)(V',V\setminus V') 的边 ff。由 w(e)w(f)w(e)\le w(f)Tf+eT-f+e 也是最小生成树,且包含 ee

(3)

用邻接表存图,从 uu 做 DFS 或 BFS;首次访问顶点时记录其前驱。到达 vv 后沿前驱回溯即可恢复路径。时间为 O(V+E)O(|V|+|E|);连通且至少两个顶点时 EV1|E|\ge |V|-1,故为 O(E)O(|E|)。若 u=vu=v,直接返回该顶点。

(4)

TT 上搜索唯一的 uuvv 路径 PP。取 P{e}P\cup\{e\} 中最大权边 ff,输出

T=T+ef.T'=T+e-f.

f=ef=e,输出原树即可。搜索仅遍历含 V1|V|-1 条边的树,找最大边和修改均为 O(V)O(|V|)

(5)

TT' 显然是生成树。任取 GG' 的生成树 SS

  • eSe\notin S,则 SSGG 的生成树,故 w(S)w(T)w(T)w(S)\ge w(T)\ge w(T')
  • eSe\in S,删除 ee 得到一个割。PP 上必有跨割边 gg,且 w(g)w(f)w(g)\le w(f)。于是 Se+gS-e+gGG 的生成树,故
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).

因此 w(T)=w(T)+w(e)w(f)w(S)w(T')=w(T)+w(e)-w(f)\le w(S)。对所有 SS 均成立,故 TT'GG' 的最小生成树;证明同样覆盖并列边权。