HI liBlili mm mill ■31 Km mm am w m ma I m LIBRARY OF THE UNIVERSITY OF ILLINOIS AT URBANA-CHAMPAIGN 510.84 ho. 69 1 -696 ?■ cop. 2. The person charging this material is re- sponsible for its return to the library from which it was withdrawn on or before the Latest Date stamped below. Theft, mutilation, and underlining of books are reasons for disciplinary action and may result in dismissal from the University. UNIVERSITY OF ILLINOIS LIBRARY AT URBANA-CHAMPAIGN j| ft ■ . L161 — O-1096 Digitized by the Internet Archive in 2013 http://archive.org/details/oeloglogvalgorit691yaoa oof? 9, UIUCDCS-R-7 1 +-691 An 0(|E|fogfog|v|) Algorithm for Finding Minimum Spanning Trees by Andrew Chi -chin Yao December 197^ THE LIBRARY OF THE FEB 20 1975 UNIVERSITY OF ILLINOIS M URBANA-CHAMPAIGN flO.lf T/U no (,11 -arc ty> UIUCDCS-R-74-691 An 0( l?"l ^og^og |Vl ) Algorithm for Finding Minimum Spanning Trees Andrew Chi-chih Yao Department of Computer Science University of Illinois Urbana, Illinois 618OI December 197^ * Research is partially supported by NSF GJ-U1538 -1- Key words: minimum spanning tree, linear median finding algorithm Introduction Given a connected, undirected graph G = (V, E) and a function c which assigns a cost c(e) to every edge e e E, it is desired to find a spanning tree T for G such that Z c(e) is minimal. In this note we describe an algorithm which finds a minimum spanning tree (MST) in 0( |E| fogiog|v|) time. Previously the best MST algorithms known have running time 0(|E|iog|V|) for sparse graphs £1}, an ^ more recently Tarjan (2 J has an algorithm that requires ( | E | JIog\V~\ ) time. Our algorithm is a modification of an algorithm by Sollin (3 J . His method works by successively enlarging components of the MST. In the first stage the minimum-cost edge incident upon each node of G is found. These edges are part of the MST sought. The groups of vertices that are connected by these edges are then identified. By shrinking each such group of vertices to a single node, we obtain a new graph with at most |V|/2 nodes. This process is repeated for a number of times, at each stage for a new graph, until finally a single contracted node remains. Clearly each stage of this procedure involves 0(|E|) operations, and iog|V| stages are necessary in the worst case. Thus this algorithm requires a total of 0(|E|£og|vl) operations. In our algorithm, we first partition the set of edges incident with each node v into k levels E , E , ... , E so that v v 7 v c(e)^c(e') if e e E , e'e E ' and i|V| £og|V| . If |E|< |V| £og|V|, the algorithm needs a slight modification as will be discussed later. The algorithm uses three sets T, VS, and ES. T is used to collect edges of the final spanning tree. The set VS contains the vertex sets corresponding to the connected components of the spanning tree found so far. And ES contains, for each vertex set W in VS, an edge set E(W). Initially we have VS = {{v} | v e V J- and ES = {{all the edges incident upon v}| v e vj . The algorithm also uses an integer parameter k, a level function 1 : V-»[l, 2, ..., k, k+l| , and a function low : V — » real numbers. -3- Frocedure MST; begin T*-f; VS*-f; ES*-^; for each vertex v e V do begin add the singleton set {v} to VS; add the set E({v}) = {all the edges incident with v}" to ES; A. divide E({v}) into k levels of equal size according to cost, i.e. oi>- ,(D ,-(2) Jk) v ' 2(e) t set f(v)*-l; '', W- ',..., E^ 'with the property that .6 E^ J ^ = E^v} 1 V V V /.n / v J-l V and c(e)£c(e') if e e E v ; , e' e E VJ; , and i<: j : v v end ; while JVS|>1 do- begin B. take a vertex set W from VS; for each vertex v e W do begin lowlv)*- 00 ; while low(v) = o© and £(v)^k do : each begin begin for each edge e = (v.v') in E do — - — ' v — C. if v'e W then delete e from e^ v ^ — v D. else low(v)«- minjlow(v), c(e)\ ; end : if low(v) = oo then £(v) «- i(v) +1; end end - - F. find the edge e = (v r v') in E(w) whose cost is equal to min{low(v) | v e WV ; H. in VS, replace W and the vertex set W containing v' by W u W I. in ES, replace E(w) and E(W) by E(W) u E(W'); add e to T; end : output T; end MST ■4- Remarks (1) In the above procedure, the set VS is implemented with a circular queue Step B corresponds to removing W from the front of the queue; step H corresponds to deleting W and adding the new W to the tail of the queue. A full cycle of the queue, in which every vertex set of VS is merged with some others, corresponds to one "stage" of the algorithm as discussed before (2) Step A is done by applying the median- finding algorithm ik] repeatedly, and takes 0(|E|£og k) time. (3) Step C is executed at most 2|E| times, since each edge (v,v') of G can be thrown out at most twice--once as (v,v'), once as (v',v). ('0 Steps D and F amount to approximately E({v»l £og|V| Z veV min operations .