Optimal Algorithms for the Vertex Updating

0 downloads 0 Views 247KB Size Report
The vertex updating problem for a minimum span- ning tree (MST) is de ned as follows: Given a graph. G = (V; EG) and its MST T, update T when a new vertex z ...
Optimal Algorithms for the Vertex Updating Problem of a Minimum Spanning Tree Donald B. Johnson

Panagiotis Metaxasy

Dartmouth Collegez

Abstract The vertex updating problem for a minimum spanning tree (MST) is de ned as follows: Given a graph G = (V; EG) and its MST T , update T when a new vertex z is introduced along with weighted edges that connect z with the vertices of G. We present a set of rules that, together with a valid tree-contraction schedule, are used to produce simple optimal parallel algorithms that run in O(lgn) parallel time using n= lgn EREW PRAMs where n = jV j. These rules can also be used to derive simple linear-time sequential algorithms for the same problem. The previously best known parallel result was a rather complicated algorithm that used n processors of the more powerful CREW PRAM model. Furthermore, we show how our solution can be used to solve the multiple vertex updating problem: Update a given MST when k new vertices are introduced simultaneously. This problem is solved in O(lg k  lgn) parallel kn EREW PRAM processors. time using lg k lg n

1 Introduction De nition. The vertex updating problem for a minimum spanning tree (MST) is de ned as follows: We are given a weighted graph G = (V; EG ), along with a MST T = (V; E). The graph is augmented by a new vertex z and n weighted edges connecting z to every vertex in V . We want to compute a new MST T 0 = (V [fz g; E 0). In this paper we present an optimal yet simple solution for the EREW PRAM model. Our solution works in O(lg n) parallel time using n= lgn processors, where n = jV j. In a later section, we show how this solution can be used to solve the multiple vertex updating problem (an existing MST T is updated simultaneously by k new vertices having weighted edges to T). The virtue of  email address: [email protected] y email address: [email protected] z Bradley Hall, Departmentof Mathematicsand Computer Sci-

ence, Hanover, NH 03755

an algorithm in the EREW model is that no arbitration of concurrent access requests need be provided in the machine on which it runs. Such arbitration is necessary in the more powerful CREW and CRCW models employed in all previous work on these problems. models. We introduce a set of rules that make use of a few simple observations on MSTs as well as of the fact that it is preferable to break the cycles introduced by the new edges (because there is only a polynomial number of them) than to compute the tree from scratch. These rules are de ned to apply locally on the nodes of the existing MST, so we get parallel algorithms (using tree-contraction) as well as sequential ones (using, for example, depth- rst-search). History. The vertex updating problem of a minimum spanning tree was rst addressed by Spira and Pan in [16], where an O(n) sequential algorithm was presented. Another solution using depth- rst-search and having the same time complexity was later given by Chin and Houck in [2], while Pawagi and Ramakrishnan [14] gave a parallel solution to the problem. Their algorithm, which runs in O(lg n) time 1 using n2 CREW PRAMs, precomputes all maximum weight edges on paths between any two nodes in the tree, and then breaks the cycles simultaneously in constant time. Varman and Doshi [19] presented an ecient solution that works in the same parallel time, but uses n CREW PRAM processors. Even though their idea is rather simple, the implementation details make the algorithm rather complex. More recently, Jung and Mehlhorn [9] have given an optimal solution for the more powerful CRCW PRAM model by reduction to an expression evaluation problem. They use an optimal tree contraction algorithm as a subroutine, as do we. However, their approach to breaking cycles is di erent from ours and appears to require concurrent writing if the running time of O(log n) is to be preserved. In our case, we are able to restrict consideration of cycles to those with no more than four vertices and, as we will show, they can 1

We denote log2 by lg . n

n

be treated without concurrent writing. Simulating the [9] algorithm without concurrent writing slows down its performance by a factor of lg n. As indicated above, the model of parallel computation we will use throughout this paper is the EREW PRAM (exclusive-read-exclusive-write parallel random access machine) [10]. Representation. Upon introducing ?  the new vertex z along with n weighted2 edges, n2 cycles are created. If we break these cycles by deleting the maximum weight edge (MaxWE) that appears in each cycle, the resulting tree will be the new MST. It is easy to see that at most n of these 2n ? 1 weighted edges will be included into the new MST. No non-tree edge of the old graph can be included because all of them are already MaxWE on some existing cycle in the original graph, so we need not consider any such edge.

In light of this discussion we may take the input to be a tree T with n ? 1 weighted edges (corresponding to the given MST) and n weighted nodes (corresponding to weights of the newly introduced edges to z). We will call this object a weighted tree (Figure 1). Note that a path between any two weighted nodes in T corresponds to a cycle in the graph augmented with z. Such a graph is shown in Figure 1b and is implied in Figure 1c. Thus we call this object the implicit graph. In the discussion that follows, reference to the weight of a node will mean reference to the corresponding edge in the implicit graph, unless noted otherwise. The paper is organized as follows: Section 2 has an outline of the solution and describes the rules and the invariants used in the problem's binarized version. Section 3 presents the main theorem and some of the algorithms that can be derived using the rules. It also contains the binarization technique and the handling on the memory access con icts that may occur. Finally, Section 4 shows how the vertex updating algorithms can be used to solve the multiple vertex updating problem in parallel.

2 Breaking the Cycles Outline of the Algorithm. As we have said, we are given the input in the form of a weighted rooted tree. We assume that each vertex has a pointer to a circular linked list of its children, and the linked lists are stored in an array. This representation of the input is not crucial, since it can be derived in O(lg n) time using n= lgn processors from any reasonable representation (see [5] for a discussion on the representation). We should mention at the outset that in the course of our description we treat every case where read or write con icts might be expected to occur and we show in each case how these con icts are avoided. The basic idea is that when only a constant number of vertices are involved in a computation, avoiding con icts is always possible with a constant dilation in running time and is in fact straightforward to implement. The algorithm consists of a number of phases. During each phase, nodes of degree 1 (i.e. leaves) and nodes of degree 2 (internal nodes having one child) of the weighted tree are processed. Each tree-node is processed once in the entire course of the algorithm. The order in which the nodes are processed in parallel is dictated by a tree-contraction schedule. Processing a node means examining the edges composing small cycles (cycles of length 3 or 4) that the node is part of, and breaking these cycles by removing the MaxWE that appears in them, e ectively computing the MST of the subgraph induced by the examined edges. This is done by a set of rules which also update neighboring nodes, so that the size of the unprocessed part of the tree decreases without losing any information about the MaxWEs of larger cycles.

A sequential algorithm needs only to apply the appropriate rule while visiting the nodes of the tree. Thus a depth- rst-search visit of the nodes suces. When working in parallel though, the rules can apply to many nodes at once, provided that no confusion arises from the updating of neighboring nodes. A valid tree2 If, in an instance of the problem, is not connected to some contraction schedule suces to assure that neighboring vertex , we can assume an edge ( ) having maximum weight. nodes are not processed at the same time (like the ones z

x

z; x

presented in Section 3). When all edges have been examined (i.e. after processing all the nodes), the MST of the implicit graph has been computed. The rules assume a binary tree as input, so some preprocessing is needed to transform the weighted tree to a binary weighted tree. This can be achieved in O(lg n) using n= lg n EREW PRAM processors, and is needed only for ordering the processing of a node's children. Of course, only the parallel algorithms need this transformation. This transformation is performed by the procedure binarize, which we brie y describe here. For details we refer to Section 3.1. Each node v = u0 with k > 2 children is augmented with k ? 2 fake nodes ui (Figure 2) to form a right path. Each of the children vj of node v is attached as a left child of uj?1, while uk?2 has a right child as well. The edges connecting the ui 's have weights ?1 which makes them unremovable by the algorithm. The fake nodes do not have weights. They are introduced only to x the order of processing of v's children. At the end of the algorithm the right path is always included in the MST of the binarized problem, giving a unique obvious solution to the general problem. The binary weighted tree has the same number of cycles, but may have height much larger than the input tree and may contain twice as many nodes. This fact, though, does not a ect the running time of the algorithm, which is logarithmic in the number of tree nodes. Invariants and Rules. The rules are divided into two categories: Rules that are applied to nodes of degree 1 (pruning rules), and rules that are applied to nodes of degree 2 (shortcutting rules). Each node is examined once for rule application. Then, its incident edges are identi ed as being either (unconditionally) included into the new MST, excluded from it, or conditionally included in it. A conditionally included edge is one which will be included in the MST unless it is the MaxWE of another cycle which has not been yet considered. In the gures that accompany this paper, a conditionally included edge is marked with an asterisk (*). It is useful to observe that the edge with minimum weight incident to some node will always be included into the MST. Actually, many sequential and parallel algorithms are based on this observation (i.e. [15, 16, 3]). Edge inclusion makes use of this observation. Another useful observation is that whenever some edge is found to correspond to the MaxWE of some cycle it can be removed from the tree without a ecting the computation of the remaining graph. (Kruskal's MST algorithm makes use of this fact.) Edge exclusion is based on this observation.

Let w : V [ E ! R give the weights of the nodes and the edges. In the beginning of the algorithm the weight of a node v, if it exists, is the weight of the edge connecting v to z. Some nodes (fake or not) may not have an assigned weight. For the purposes of the algorithm a weight of +1 is assumed on each of them. To resolve ties, we adopt the convention that the currently processed node has weight larger than its equally weighted neighbor. Let us de ne the provisional graph to be the graph induced by the edges examined since the beginning of the algorithm. We will see in the next subsection that whenever a leaf v is processed, three edges are examined and whenever an internal node is processed ve edges are examined. Each application of a rule on some node preserves the following three invariants:

Invariant 1 The minimum spanning tree of the provisional graph has been computed.

This will be true, because we will consider and break all cycles of the provisional graph by removing the MaxWE appearing in them. Furthermore, the rules will assure that the non-excluded edges of the provisional graph will constitute a MST. So, it will be the MST of the provisional graph because (i) connectivity is preserved, (ii) no cycles remain and (iii) the cycles have been broken by removing their MaxWE.

Invariant 2 The weight w[v], if it is de ned, of some

unprocessed node v corresponds to the max weight edge on the unique path from z to v either via edge (z; v) or through edges contained in the provisional graph.

As we said, application of a rule on some node v will examine and break all the small cycles that v is on, by removing their MaxWE. Some larger cycle sharing the MaxWE with a broken small cycle will also be broken. The next invariant describes how other larger cycles containing v are a ected.

Invariant 3 Let c be a larger cycle containing node v and let e be its MaxWE. After the application of a rule on v, either e has been deleted or there remains another cycle in which e is the MaxWE. Initially, since there are no processed nodes and the provisional graph is empty, the invariants hold. We now show how these invariants can be preserved under tree-contraction operations.

2.1 Pruning Rules Consider a cycle involving leaf v, p(v) and z. Let w[(v; p(v))] = a, w[v] = b and w[p(v)] = c (Figure 3).

The cycle of length 3 they form can be broken in such a way that the invariants are preserved by removing one of the three edges involved. We consider the following cases: a = maxfa; b; cg: Edge (v; p(v)) must be excluded from the new MST. When it is removed, the tree is broken into two subtrees connected in the implicit graph via z. Moreover, the edge that corresponds to b has to be included into the MST, since this is the only way that v can be connected with the graph.

and some precaution must be taken to avoid simultaneous reading or writing on p(v) by the two processors. Moreover a cycle of length 4 (namely z; v; p(v); u; z) must be broken by excluding its MaxWE. Also w[p(v)] must be updated to either maxfa; bg or maxfd; eg, depending on which child was connected to the excluded edge. In particular, if maxfa; bg > maxfd; eg then maxfa; bg is excluded and w[p(v)]gets maxfd; eg. Else if maxfd; eg > maxfa; bg then maxfd; eg is excluded and w[p(v)]gets maxfa; bg.

b = maxfa; b; cg: Node v can be included in the MST only via (v; p(v)). Therefore, this edge is included, while edge (z; v) is excluded from the MST. c = maxfa; b; cg: In this case the best way to include p(v) is not via (z; p(v)) so this edge is excluded. It could be best to include p(v) via v, but if so, we do not know it yet. However, in this case, the MaxWE that connects p(v) with the provisional tree will have weight maxfa; bg. The edge corresponding to minfa; bg has to be included in the MST. In the gure, this is indicated by relabeling v with minfa; bg. The edge corresponding to maxfa; bg is conditionally included. We update w[p(v)]gets maxfa; bg to preserve Invariant 2. The e ect of the update is the following: If w[p(v)] is found to be the MaxWE of some other cycle later on, the edge corresponding to maxfa; bg will not be included in the MST. Otherwise, if upon termination of the algorithm no rule has excluded w[p(v)], it will be included.

Some special care must be taken in the case that v's sibling, say u, is also a leaf (Figure 4) and is processed at the same time. Let w[u] = e and w[(u; p(v))] = d. If c = maxfa; b; c; d; eg then (z; p(v)) must be excluded

2.2 Shortcutting Rules Now we consider a situation where v has only one child, say u. There are two possible small cycles involving v: z; v; u; z and z; v; p(v); z. We will describe how to break these cycles in such a way that the invariants are preserved. Let w[v] = a, w[(v; u)] = b, w[u] = c, w[(v; p(v))] = d and w[p(v)] = e (Figure 5).

a = maxfa; b; cg or a = maxfa; d; eg: The best way to include v in the MST is either via (v; p(v)) or via (v; u). Thus, the edge with weight minfb; dg must be included in the MST. The other, equal to maxfb; dg will be conditionally included, i.e. it will be included if and only if it is not the MaxWE in another cycle involving z; u; p(v) and possibly other nodes. Therefore we can preserve the MaxWErelated information about these cycles by introducing a new shortcutting edge (u; p(v)) corresponding to the edge with weight maxfb; dg.

b = maxfa; b; cg or d = maxfa; d; eg: In the rst case edge (v; u) must be excluded from the new MST, while in the second case edge (v; p(v)) must be excluded. In either case v becomes a leaf3 and it then can be pruned using the rules for pruning. c = maxfa; b; cg and e = maxfa; d; eg: Then, both (z; u) and (z; p(v)) must be excluded from the MST and the edge corresponding to minfa; b; dg must be included. We have to update p(v) and u so that they re ect this fact preserving the invariants. (In Figure 6 the case is presented with the further assumption that b > d for a simpli ed picture.) Observe that there may exist (i) cycles involving edges (z; v), (v; p(v)) and edges in the upper part of the tree, (ii) cycles involving (z; v), (v; u) and edges in the lower part of the tree, and nally (iii) cycles going through z; u; v; p(v); z that do not involve (z; v). The update should preserve information about these cycles as dictated by Invariant 3. We update w[p(v)]gets maxfa; dg to account for cycles of the rst type and w[u]gets maxfa; bg to account for cycles of the second type, corresponding to conditionally included edges. Finally, we introduce a conditionally included shortcutting edge (p(v); u) with weight maxfb; dg to account for cycles of the third type.

ond type. So, updating w[p(v)]getsd and w[u] b is enough. Otherwise, if a 6= minfa; b; dg, and say b > d, then updating of u is not needed, because information about cycles of all three types is preserved. (Figure 7) This observation can lead to a simpler implementation of the algorithm. Recall that a weightless node is treated as if it was holding the maximum value.

The fact that shortcutting may update both parent and child nodes creates a possibility of a write con ict. This is easily xed, since at most three processors may try to access the same memory cell simultaneously. Section 3.2 has more on this. The above discussion veri es that application of the rules preserve the invariants, proving the following Lemma:

Lemma 1 Application of a pruning or a shortcutting

rule on some node v of the weighted graph preserves the invariants.

Correctness Lemma. We have described a set of rules that de ne a prune operation which removes the leaves of a tree, and a shortcut operation which removes nodes of degree two from the tree. Note that individual prunings and shortcuttings take O(1) time to be performed. A valid tree-contraction schedule is one which schedules the nodes of the binary tree for pruning and shortcutting in such a way that (i) when a node is operated upon it has degree one or two, and (ii) neighboring nodes are not operated upon simultaneously. Lemma 2 When the rules are applied on the nodes of

It is worth noting that in the last shortcutting rule not all three weight-updates are needed for the correctness of the algorithm. One of them can be omitted as redundant (Figure 6a,b): If a = minfa; b; dg, then we don't need the shortcutting edge (p(v); u) because some MaxWE occurring in cycles of the third type will also be MaxWE in some other cycle of the rst or the sec-

a binary weighted tree at times given by any valid treecontraction scheduling, they correctly produce the updated minimum spanning tree.

Proof. As we said, a valid contraction schedule de nes processing times on nodes having degree 1 or 2. So, only the prune and shortcut operations are needed, and they are provided by the rules. Moreover any node may be accessed simultaneously by at most three pro3 Of course in the second case we use the term \leaf" loosely: Node is the parent of but nevertheless it then can be pruned cessors. This con ict can be resolved easily. Therefore as a leaf because it has degree one. the shortcutting and pruning operations can be done v

u

without confusion, and their application, according to Lemma 1, preserves the invariants. Thus, at the end of the schedule the MST of the provisional graph, and therefore the updated MST of the implicit graph, has been computed. 2

3 The Algorithms

We will brie y describe here the simplest of these schedules (called Shunting) which was proposed independently by [1] and [11]. The algorithm is composed of a number of phases, each containing the following steps: (Figure 8) 1. Number the leaves of the tree from left-to-right. Here, the input is supposed to be a regular binary tree, i.e. a binary tree in which every internal node has exactly two children. The numbering can be done using the eulerian tour technique [18] within the desired bounds. 2. Prune the odd-numbered leaves that are the left children of their parent. Then, shortcut their parent. This is the shunt operation. 3. Shunt the odd-numbered leaves that are the right children of their parent. 4. Shift out the last bit of the remaining leaves and repeat steps 2 to 4 until the whole tree has been contracted.

We say that a sequential algorithm for some problem of size n is optimal if it runs in time that matches a lower bound for the problem to within a constant factor. Note that the vertex updating problem has a lower bound of

(n) sequential time. Let t(n) denote the parallel running time for some parallel algorithm, and p(n) denote the number of processors employed by the algorithm. Then, w(n) = t(n)p(n) denotes the work performed by the algorithm. A parallel algorithm for some problem is said to be optimal [10] if it has polylogarithmic parallel running time and the work w(n) performed by the algorithm is Lemma 3 ([1]) The previous algorithm computes a O(T(n)), where T(n) is the running time of the best valid contraction schedule which has length O(lg n). sequential algorithm for the same problem. If we had a processor assigned to each node, we could Theorem 1 There are optimal parallel and sequential contract tree using n processors in the desired time. algorithms that solve the MST vertex updating problem But the the time at which processing occurs can be combased on the rules presented above. The parallel algo- puted beforehand each leaf and placed in an array rithms run on a binary weighted tree in O(n=p) time of length dn=2e + for 1. the array, it takes time using p  n= lgn EREW PRAM processors and the se- O(n=p) using p  n=Having lg n processors conquential algorithms run in O(n). Furthermore, the run- traction. Optimality is achieved for p =ton=dolgthe n. (The ning time of O(log n) achieved when p = n= logn is the shunting scheduling is shown in Figure 9.) best possible. The accelerated centroid decomposition (ACD) technique was proposed by [5] and also provides an optimal valid scheduling. Using their technique another optimal algorithm for the vertex updating problem is acquired. Since in either scheduling at most three processors may attempt to operate on the same data item at a certain time and the identity of these processors is known in advance, we can schedule the operations in such a way that no read or write con icts occur. This observation along with Lemma 2 completes the proof for the parallel case. b. the optimal sequential algorithms. The rules we presented do not depend on the particular orProof. a. the optimal parallel algorithms. der in which the nodes of the tree are removed. So, There are, actually, several valid tree contraction sched- di erent removal sequences of the nodes yield di erent ules that produce optimal behavior in our algorithm. algorithms and, in particular, we can derive sequential First, [12] proposed such a schedule which was con- algorithms from the parallel ones. In particular, the structed on the y by an optimal randomized algorithm. Shunting and the ACD numberings give two such algoThe problem and its applications drew the attention of rithms. Their running times di er only by a constant. researchers, and soon several optimal deterministic al- In the next paragraphs we present two more sequential gorithms were presented [1, 11, 5, 8, 7]. algorithms.

Use depth- rst-search to visit the nodes of the tree. Every time a node of degree 1 or 2 is encountered, process it using pruning or shortcutting rule, respectively. Each node will be visited at most twice (on the way down the tree and on the way up the tree), so its running time is O(n). Another algorithm simpler to implement is the following: Visit the nodes of the weighted tree in postorder. A node is processed after all its children have been processed, so only the pruning rules are needed. Since each node is processed at most once, we have an O(n) sequential algorithm. The work optimality of our algorithm has been established above. We now state an argument which shows that any running time must be (logn). Consider a tree all of whose nodes are on a path of length n ? 1, and therefore having only two leaf-nodes. If we add two new weighted edges connecting z to each of the two leaves, the updating MST problem is equivalent to the problem of computing the maximum of n + 1 weights on the cycle created, for which problem [6] have proven a lower bound of (log n). 2

binarization should be extended to handle nodes v with only one child in the input tree. For each of them a second child v0 is introduced, for which w[v0 ] = 1 and w[(v; v0 )] = ?1.

Theorem 2 There are logarithmic-time optimal parallel algorithms solving the MST vertex updating problem on a rooted tree.

Proof: The binarized graph has exactly the same number of cycles as the given graph, and at the end of the algorithm the edges composing the right path are always included into the new MST. Therefore, the solution of the binarized problem shows a corresponding unique and unambiguous solution to the general problem. 2

3.2 Memory Access Con icts. As we said, the fact that shortcutting may update both parent and child nodes creates a possibility of a write con ict. Consider the following situation: Let nodes x; v; y satisfy p(y) = v and p(v) = x, and assume that nodes x and y are to be processed simultaneously (Figure 10a). Moreover, let's assume that shortcutting node x calls for updating child node v with w[v] a, and shortcutting node y calls for updating parent node v with w[v] b.

3.1 Binarization We now discuss how a general tree can be transformed into a binary tree using the procedure binarize: Each node v having k children v1;    ; vk is represented by a right path (Figure 2) composed of v = u0 and k ? 2 fake nodes u1 ;    ; uk?2, so that node uj is the right child of uj?1 and the parent of uj +1. Node vi , i = 1;    ; k ? 1 becomes the left child of node ui?1 and vk the right child of uk?2. We assign weights of ?1 to the edges of the right path so they can not be excluded by the rules. The fake nodes have no assigned weight (which is treated as maximum value weight by the algorithm) because they are only introduced to x the processing order of v's children. Of course, the real nodes v and the vi 's keep their weights. Recall that the shunting scheduling accepts as input a regular binary tree. When using this technique, the

Recall that, according to Invariant 2, the weight of a node represents the MaxWE on the path from this node to z via processed neighbors. The write con ict actually represents a cycle involving nodes z; x; v; y, and possibly x's parent and/or y's child. Since two processors may try to write on the same memory cell, the con ict can be avoided and the cycle behind it should be broken by removing the edge maxfa; bg while updating w[v] minfa; bg. This is the only kind of access con ict that can be created by the shunting schedule we describe in the next section. There are other schedules though, which create a slightly more complicated con ict when updating a node with three values (Figure 10b), say a; b, and c. Again, this can be resolved by breaking the MaxWEs of the three cycles behind the con ict. Therefore, in this case the algorithm should update w[v] minfa; b; cg and should exclude the edges that correspond to the other two values.

4 On the Multiple Vertex Updates Problem We de ne the problem of multiple vertex updates of a MST as follows: Let G = (VG ; EG) be a weighted graph on n vertices and m weighted edges and T = (VG ; ET ) be its MST. Suppose G is augmented with k = jVk j new vertices that are connected to VG 's vertices by kn = jEk j new weighted edges, but they are not connected among themselves. We are asked to compute the new MST T 0 . The problem of multiple vertex updates was considered by Pawagi [13] and a parallel algorithm was presented running in O(lgn lg k) time using nk CREW PRAM processors. We will show how our solution for the (single) vertex update problem can be used to achieve a better solution for the multiple updates problem on a weaker model of parallel computation. Note that this is optimal for graphs having O(kn) edges.

Theorem 3 The multiple updates MST problem can be solved in parallel in time O(lg n lgk) using nk= lg n lgk EREW PRAM processors. Proof. The algorithm follows in general the one presented in [13] but in certain parts uses di erent implementation techniques to achieve the tighter time and processor bounds. The algorithm consists essentially of three parts. 1. Make k copies of T and solve k update MST problems in parallel. 2. Combine the MSTs of the k solutions into a new graph Gz . This graph may contain cycles. Transform it to an equivalent bipartite graph Gb . 3. Solve the bipartite MST problem on the graph Gb . We will show that each of these parts can be implemented within the desired bounds. 1. Solving k Updating Problems. Making k copies of T requires O (kn) operations and it can be done in constant time if kn processors are available. Therefore, it can be done in O(lg n lg k) time using kn=(lg n lg k) processors following Brent's technique [10]. According to Theorem 1, a single updating of a MST can be done in O(n=p) time when p processors are available. Here we have k problems to solve, each of size n. Allocating n= lg n lg k processors per problem, it takes O (lg n lg k ) time to solve each one in parallel. 2. Creating the Bipartite Graph. Next, we have to combine the k solutions found in the rst part, into a new graph Gz which in turn is transformed to an equivalent bipartite graph Gb . By equivalent here, we mean that there is a cycle in Gb if and only if there is a cycle in Gz . Graph Gz will never be explicitly created; it is only de ned for the

sake of description.

If some edge (v; w) 2 ET did not appear in all k solutions, it was the MaxWE of some cycle and thus must be excluded. So, Gz = (V [fz1 ;  ; zk g; Ez ) is composed of edges (v; w) 2 ET that appear in all k solutions, along with edges of the form (zi ; v) 2 Ek , 8i 2 f1;  ; kg. It is easy to see that the formation of Gz can be done within the desired bounds, because there are at most n ? 1 such edges per solution to examine. We can view Gz as a collection of subtrees Cj of the old MST that are held together by the zi 's (Figure 11). Every cycle in Gz can be viewed as starting at some zi , then entering subtree Cj at a node ve and visiting some of its nodes, then exiting through a node ve0 and visiting zl , etc, until returning back to zi (Figure 12). The nodes ve that are adjacent to some zi are called e-nodes. The new graph Gb = (Vb ; fz1 ;  zk g; Eb ) has a set of vertices Vb which contains one vertex v for each e-node ve of Gz . Consider a path from zi to some e-node ve and let x be the MaxWE on this path. Then edge (zi ; v) 2 Eb corresponds to this path and has cost equal to x's cost. The algorithm needs therefore to compute all MaxWE on all paths from zi to e-nodes ve.

This is done as follows. First, all e-nodes ve are recognized. Then we root each of the Ti 's at zi . Both of these operations can be done within the desired bounds. Now we have to compute the MaxWEs on the paths between zi 's and e-nodes by solving k instances of the following problem: Given a (regular binary rooted) tree with n nodes having weights associated with its edges, nd the MaxWE for each path from a node to the root in O(n=p) time using p  n= lg n EREW PRAM processors. Each solution is a simple application of the tree-

contraction problem. We allocate n= lg n lg k processors per tree and compute the problem in time O(lg n lg k). 3. The Bipartite MST Problem. For the third part of the algorithm we need the following de nition of the bipartite MST problem: Let G = (Vk ; Vn ; E ) be a weighted bipartite graph, where jVk j = k and jVn j = n, k  n. We want to compute its MST. The following Lemma concludes the description of the algorithm along with the proof of Theorem 3.

Lemma 4 The bipartite MST problem can be solved using

kn=(lg n lg k ) EREW PRAM processors in O (lg n lg k ) parallel time.

Proof. The algorithm that we use is a well-known algorithm whose main idea is attributed to Boruvka [17] and was described in its parallel form in [3]. The analysis however and the time-processors bounds for the bipartite-MST problem are new. First, let us give some de nitions. A pseudotree is a directed graph in which each vertex has outdegree one. A pseudotree has at most one simple cycle. A pseudoforest is a graph whose components are pseudotrees. The algorithm consists of a number of stages. In each stage, each vertex v selects the minimum weight edge (v; w) incident to it. This creates a pseudoforest of vertices connected via the selected edges. In this case the cycle of each pseudotree involves only two vertices, so it can be easily transformed into a tree. Next, each tree is contracted to a star using pointerdoubling and vertices in the same component are identi ed with the root of the star. The crucial observation here is that after the rst stage there will be no more than k vertices in the resulting graph and the problem can be solved in O(lg2 k) time using 2 2 k = lg k processors. So, we only have to show that the rst stage can be performed within the desired bounds. As we said, the rst stage consists of nding the minima of O(n) sets of vertices, each with cardinality O(k) and then to reduce the O(k) resulting pseudotrees of height O(n) to stars. For the rst part Brent's technique applies. For the second part we use the optimal list-ranking technique of [4]. 2

Acknowledgement. The authors would like to thank Professors Sam Bent and Jim Driscoll for their helpful comments on the presentation of the paper.

References [1] K. Abrahamson, N. Dadoun, D. Kirkpatrick, and T. Przytycka. A simple parallel tree contraction algorithm. J. Algor., 10:287{302, 1989. [2] F. Chin and D. Houck. Algorithms for updating minimal spanning trees. JCSS, 16(12):333{344, 1978.

[3] F. Chin, J. Lam, and I.-N. Chen. Ecient parallel algorithms for some graph problems. CACM, 25(9):659{ 665, September 1982. [4] R. Cole and U. Vishkin. Approximate and exact parallel scheduling with applications to list, tree and graph problems. In Proc. 27 FOCS, pages 478{491, 1986. [5] R. Cole and U. Vishkin. The accelerated centroid decomposition technique for optimal parallel tree evaluation in logarithmic time. Algor., 3:329{346, 1988. [6] S. Cook, C. Dwork, and R. Reischuk. Upper and lower time bounds for parallel random access machines without simultaneous writes. SIAM J. Comp., 15(1):87{97, February 1986. [7] H. Gazit, G. L. Miller, and S. H. Teng. Optimal tree contraction in the EREW model. In Concurrent Computations: Algorithms, Architecture, and Technology, New York, 1988. Tewksbury and Dickinson and Schwartz (editors), Plenum Press. [8] A. Gibbons and W. Rytter. An optimal parallel algorithm for dynamic expression evaluation and its applications. In Proc. of Symp. Found. Soft. Tech. Th. CS, volume 6, pages 453{469. Springer Verlag, 1986. [9] H. Jung and K. Mehlhorn. Parallel algorithms for computing maximal independent sets in trees and for updating minimum spanning trees. IPL, 27(5):227{236, April, 28 1988. [10] R. Karp and V. Ramachandran. Parallel algorithms for shared-memory machines. Handbook Th. CS, 1:869{ 941, 1990. [11] S. R. Kosaraju and A. L. Delcher. Optimal parallel evaluation of tree-structured computations by raking. AWOC, pages 101{110, 1988. [12] G. L. Miller and J. H. Reif. Parallel tree contraction and its application. In 26 FOCS, pages 478{488, 1985. [13] S. Pawagi. A parallel algorithm for multiple updates of minimum spanning trees. In ICPP, volume III, pages 9{15, 1989. [14] S. Pawagi and I. Ramakrishnan. An O(log n) algorithm for parallel update of minimum spanning trees. IPL, 22(5):223{229, April, 28 1986. [15] R. Prim. Shortest connection networks and some generalizations. Tech. J., Bell Labs, 36:1389{1401, 1957. [16] P. Spira and A. Pan. On nding and updating spanning trees and shortest paths. SIAM J. Comp., 4(3):375{ 380, September 1975. [17] R. Tarjan. Data Structures and Network algorithms. Society for Industrial and Applied Mathematics, Philadelphia, Pennsylvania 19103, 1983. [18] R. Tarjan and U. Vishkin. An ecient parallel biconnectivity algorithm. SIAM J. Comp., 14(4):862{874, 1985. [19] P. Varman and K. Doshi. A parallel vertex insertion algorithm for minimum spanning trees. In 13th ICALP, volume 226, pages 424{433, 1986.

fwto 1 fwto 2 fwto 3 fwto 4 fwto 5 fwto 6 fwto 7 fwto 8 fwto 9 fwto 10 fwto 11 fwto 12

Suggest Documents