Minimum Diameter Spanning Tree
Before learning about Minimum Diameter Spanning Tree, it is recommended to first read the content on Tree Diameter.
Definition
Among all spanning trees of an undirected graph, the one with the smallest diameter is called the Minimum Diameter Spanning Tree.
Absolute Center of a Graph
To find the minimum diameter spanning tree, we first need to locate the absolute center of the graph. The absolute center can lie on an edge or at a vertex, and it minimizes the maximum shortest distance to all vertices.
From the definition of the absolute center, we know that there are at least two vertices farthest from the absolute center.
Let \(d(i,j)\) be the shortest path length between vertices \(i\) and \(j\), computed via an all-pairs shortest path algorithm.
Let \(\textit{rk}(i,j)\) denote the \(j\)-th closest vertex to vertex \(i\) among all other vertices.
The absolute center may lie on an edge. For each edge \(w=(u,v)\), suppose the absolute center \(c\) lies on this edge. Let the distance from \(c\) to \(u\) be \(x\) (where \(x \leq w\)), then the distance to \(v\) is \(w - x\).
For any vertex \(i\) in the graph, the distance from the absolute center \(c\) to \(i\) is \(d(c,i)=\min(d(u,i) + x, d(v,i) + (w - x))\).
Consider a vertex \(i\); its positional relationship with the absolute center is illustrated below.
As the absolute center \(c\) moves along the edge, a function of distance versus \(c\)'s position is generated. Clearly, the function \(d(c,i)\) is a piecewise linear function composed of two segments with the same slope.
For any vertex in the graph, the function of the farthest distance from the absolute center is written as \(f = \max\{ d(c,i)\},i \in[1,n]\), and its graph is as follows.
The lowest point among the intersections of these piecewise linear functions corresponds to the position of the absolute center.
The absolute center may also lie at a vertex. In that case, update using the farthest vertex from the candidate vertex: \(\textit{ans}\leftarrow \min(\textit{ans},d(i,\textit{rk}(i,n))\times 2)\).
Procedure
-
Use an all-pairs shortest path algorithm (Floyd, Johnson, etc.) to compute the \(d\) array.
-
Compute \(\textit{rk}(i,j)\) and sort it in ascending order.
-
The absolute center may lie at a vertex. Update using the farthest vertex from each candidate vertex: iterate over all vertices and update the minimum with \(\textit{ans}\leftarrow \min(\textit{ans},d(i,\textit{rk}(i,n)) \times 2)\).
-
The absolute center may lie on an edge. Enumerate all edges. For an edge \(w(u,v)\), start updating from the vertex farthest from \(u\). When \(d(v,\textit{rk}(u,i)) > \max_{j=i+1}^n d(v,\textit{rk}(u,j))\) occurs, update with \(\textit{ans}\leftarrow \min(\textit{ans}, d(u,\textit{rk}(u,i))+\max_{j=i+1}^n d(v,\textit{rk}(u,j))+w(u,v))\), because this situation changes the absolute center.
Implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
Example Problems
Minimum Diameter Spanning Tree
From the definition of the absolute center, it is easy to see that the absolute center is the midpoint of the diameter of the minimum diameter spanning tree.
To find the minimum diameter spanning tree, first locate the absolute center of the graph. Starting from the absolute center, generate a shortest path tree; this yields the minimum diameter spanning tree.
Implementation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
Example Problems
timus 1569. Networking the "Iset"
SPOJ PT07C - The GbAaY Kingdom
References
Play with Trees Solutions The GbAaY Kingdom
本页面最近更新:,更新历史
发现错误?想一起完善? 在 GitHub 上编辑此页!
本页面贡献者:OI-wiki
本页面的全部内容在 CC BY-SA 4.0 和 SATA 协议之条款下提供,附加条款亦可能应用