generalized edge-rankings of trees · fig. 1. two optimal 2-rankings of a tree t. is a labeling of...

15
Generalized Edge-Rankings of Trees (Extended Abstract) Xiao Zhou 1, Md. Abul Kashem 2 and Takao Nishizeki ~ 1 Education Center for Information Processing 2 Graduate School of Information Sciences Tohoku University, Sendai 980-77, Japan. Email: [email protected], [email protected] [email protected] Abstract. In this paper we newly define a generalized edge-ranking of a graph G as follows: for a positive integer c, a c-edge-ranking of G is a labeling (ranking) of the edges of G with integers suck that, for any label i, deletion of all edges with labels > i leaves connected components, each having at most c edges with label i. The problem of finding an op- timal c-edge-ranking of G, that is, a c-edge-ranking using the minimum number of ranks, has applications in scheduling the manufacture of com- plex multi-part products; it is equivalent to finding a c-edge-separator tree of G having the minimum height. We present an algorithm to find an optimal c-edge-ranking of a given tree T for any positive integer c in time O(n ~ log A), where n is the number of vertices in T and A is the maximum vertex-degree of T. Our algorithm is faster than the best algorithm known for the case c = 1. Key words: Algorithm, Edge-ranking, Separator tree, Tree. 1 Introduction An edge-ranking of a graph G is a labeling of edges of G with positive integers such that every path between two edges with the same label i contains an edge with label j > i [8, 5]. Clearly an edge-labeling is an edge-ranking if and only if, for any label i, deletion of all edges with labels > i leaves connected components, each having at most one edge with label i. The edge-ranking problem is to find an edge-ranking of a given graph G using the minimum number of ranks (labels). The problem seems to be NP-complete in general [3]. However, polynomial-time algorithms have been reported for trees. Iyer etal. [8] have given an O(n log n) time approximation algorithm for finding an edge-ranking of trees T using at most twice the minimum number of ranks, where n is the number of vertices in T. P. de la Torre etal. [3] have given an exact algorithm to solve the edge-ranking problem for trees in time O(n a log n) by means of a two-layered greedy method. Although Deogun and Peng [5] have claimed an exact O(n a) time algorithm, several flaws in [5] are pointed out in [4]. In this paper we newly define a generalization of an ordinary edge-ranking. For a positive integer e, a c-edge-ranking (or a c-ranking for short) of a graph G

Upload: others

Post on 26-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

Generalized Edge-Rankings of Trees (Extended Abstract)

Xiao Zhou 1, Md. Abul Kashem 2 and Takao Nishizeki ~

1 Education Center for Information Processing 2 Graduate School of Information Sciences Tohoku University, Sendai 980-77, Japan.

Email: [email protected], [email protected] [email protected]

Abs t rac t . In this paper we newly define a generalized edge-ranking of a graph G as follows: for a positive integer c, a c-edge-ranking of G is a labeling (ranking) of the edges of G with integers suck that, for any label i, deletion of all edges with labels > i leaves connected components, each having at most c edges with label i. The problem of finding an op- timal c-edge-ranking of G, that is, a c-edge-ranking using the minimum number of ranks, has applications in scheduling the manufacture of com- plex multi-part products; it is equivalent to finding a c-edge-separator tree of G having the minimum height. We present an algorithm to find an optimal c-edge-ranking of a given tree T for any positive integer c in time O(n ~ log A), where n is the number of vertices in T and A is the maximum vertex-degree of T. Our algorithm is faster than the best algorithm known for the case c = 1.

Key words: Algorithm, Edge-ranking, Separator tree, Tree.

1 Introduction

An edge-ranking of a graph G is a labeling of edges of G with positive integers such that every path between two edges with the same label i contains an edge with label j > i [8, 5]. Clearly an edge-labeling is an edge-ranking if and only if, for any label i, deletion of all edges with labels > i leaves connected components, each having at most one edge with label i. The edge-ranking problem is to find an edge-ranking of a given graph G using the minimum number of ranks (labels). The problem seems to be NP-complete in general [3]. However, polynomial- t ime algorithms have been reported for trees. Iyer etal. [8] have given an O(n log n) t ime approximation algorithm for finding an edge-ranking of trees T using at most twice the minimum number of ranks, where n is the number of vertices in T. P. de la Torre etal. [3] have given an exact algorithm to solve the edge-ranking problem for trees in t ime O(n a log n) by means of a two-layered greedy method. Although Deogun and Peng [5] have claimed an exact O(n a) t ime algorithm, several flaws in [5] are pointed out in [4].

In this paper we newly define a generalization of an ordinary edge-ranking. For a positive integer e, a c-edge-ranking (or a c-ranking for short) of a graph G

Page 2: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

391

2 3 2 3

3 2 3 2

(a) Supercritical 2-ranking r (b) Subcritical 2-ranking 1]

Fig. 1. Two optimal 2-rankings of a tree T.

is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with labels > i leaves connected components, each having at most c edges with label i. Clearly an ordinary edge-ranking is a 1-edge-ranking. The integer label of an edge is called the rank of the edge. A c-ranking of G using the minimum number of ranks is called an optimal c-ranking of G. The c-ranking problem is to find an optimal c-ranking of a given graph G. Fig. 1 depicts two optimal 2-rankings 9 and q of a tree T using four ranks, where the ranks are drawn next to the edges and the 2-rankings ~ and q are different only for the label of the rightmost edge incident to the root. Connected components obtained from T by deleting all edges with labels > i for the 2-ranking ~ of Fig. l(a) are drawn in ovals in Fig. 2.

The problem of finding an optimal c-ranking of a graph G has applications in scheduling the parallel assembly of a complex multi-part product from its components, where the vertices of G correspond to the parts and the edges correspond to assembly operations [5, 7, 8]. Let us consider a robot with c + 1 hands which can connect at most c + 1 connected components at a time. If we have as many robots as we need, then the problem of minimizing the number of steps required for the parallel assembly of a product using the robots is equivalent to finding an optimal c-ranking of the graph G. Fig. 2 shows that one can assemble in parallel a product of Fig. l(a) in four steps using seven robots of three hands. Note that, among ten connected components in Step 1, there are seven connected components each of which is not an isolated vertex. In each step robots simultaneously connect at most three connected components of the previous step.

The c-edge-ranking problem for a graph G is also equivalent to finding a c-edge-separator tree of G having the minimum height. Consider the process of starting with a connected graph G and partitioning it recursively by deleting at most c edges from each of the remaining connected components until the graph has no edge. The tree representing the recursive decomposition is called a c- edge-separator tree of G. Thus a c-edge-separator tree corresponds to a parallel computation scheme based on the process above, and an optimal c-ranking of G provides a parallel computation scheme having the minimum computation time

Page 3: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

392

[9]. Fig. 2 illustrates a 2-edge-separator tree of the tree T depicted in Fig. l(a).

Step 4

~4

Step 3

Step 2 (

Step 1

:3

:2

Fig. 2. A 2-edge-separator tree of the tree T in Fig. l(a).

The vertex-ranking problem [6] and the c-vertex-ranking problem [12] for a graph G are defined similarly. A c-vertex-ranking of a graph G is a labeling of the vertices of G with positive integers such that, for any label i, deletion of all vertices with labels > i leaves connected components, each having at most c vertices with label i. The vertex-ranking problem, that is, 1-vertex-ranking problem, is NP-complete in general [2, 10]. However, Iyer et al. presented an O(n log n) time algorithm to solve the vertex-ranking problem for trees [6]. Then Sehgffer obtained a linear-time algorithm by refining their algorithm and its analysis [11]. On the other hand, Zhou et al. gave a linear-time algorithm to solve the c-vertex-ranking problem for trees [12]. Very recently Bodlaender et aI. have given a polynomial-time algorithm to solve the vertex-ranking problem for graphs with bounded treewidth [2].

In this paper we give an algorithm to solve the c-edge-ranking problem on

Page 4: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

393

trees. The algorithm does not use a complicated greedy method, and finds an optimal c-ranking of a given tree T by means of "bottom-up tree computation" on T as the previous ranking algorithms [3, 6]: an optimal c-ranking of a subtree rooted at an internal vertex of T is updated from those of the subtrees rooted at its children. It is the first polynomial-time algorithm for the generalized edge- ranking problem, and takes time O(n 2 log A) for any positive integer c, where A is the maximum vertex-degree of T. It should be noted that c is not always bounded. Thus our algorithm is faster than the best algorithm of complexity O(n alogn) known for the ordinary edge-ranking problem [3]. Our algorithm uses several new techniques as well as ones employed in [3, 6] for the ordinary ranking problems, and uses data-structures which can be constructed from lists of "visible edges" by radix sorting. The early conference versions [13, 14] of the paper claimed the bound O(nlogn) for the ordinary edge-ranking problem on trees, but there were flaws in the algorithms. This paper corrects the flaws and extends the algorithms for the c-ranking problem.

2 P r e l i m i n a r i e s

In this section we define some terms and present easy observations. Let G = (V, E) denote a graph with vertex set V and edge set E. We often

denote by V(G) and E(G) the vertex set and the edge set of G, respectively. An edge joining vertices u and v is denoted by (u,v). We denote by n the number of vertices in a tree T = (V, E) and by ,4 the maximum vertex-degree of T. One may assume that n >__ 3 and hence A >_ 2. T is a "free tree," but we regard T as a "rooted tree" for convenience sake: an arbitrary vertex of T is designated as the root of T. The maximal subtree of T rooted at a vertex w E V is denoted by T(w). Let e = (v, w) be an edge in T such that w is a child of v. Then the tree obtained from T(w) by adding e is denoted by T(e). We denote by T - T(e) the tree obtained from T by deleting all edges and all vertices of T(e) except v. We will use notions as: root, internal vertex, child and leaf in their usual meaning.

Let ~o be an edge-labeling of a tree T with positive integers. The label (rank) of an edge e C E is represented by ~(e). An edge e of T is visible from vertex w under ~o if e is contained in T(w) and every edge in the path from w to e has a rank _< ~(c). An edge visible from the root of T is often called a visible edge for short. In Fig. 1 all visible edges are drawn in thick lines. For a subtree T ' of T, we denote by <piT' a restriction of ~ to E(T ' ) : let ~' = ~IT', then ~'(e) = 9~(e) for e r E(T ' ) .

One can easily observe that the following lemma holds as in the case of the ordinary edge-ranking [3].

L e m m a 1. An edge-labeling ~ of a tree T is a e-ranking of T if and only if

(a) ~lT(w) is a c-ranking of T(w) for every child w of the root of T; and (b) no more than c edges of the same rank are visible from the root under

~fl . []

This lemma immediately implies:

Page 5: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

394

Coro l l a ry 2. An edge-labeling ~ of a tree T is a c-ranking if and only if no more than c edges of the same rank are visible from each vertex o f T under ~.

Since it is not so simple to find an optimal c-ranking, we focus on specific types of optimal c-rankings. Before formally defining them, we need to define some terms.

One may assume without loss of generality that a c-ranking ~, of tree T uses consecutive positive integers starting from 1 as the ranks. Thus the largest rank is equal to the number of ranks used by ~. Iyer et al. introduced an idea of a "critical list" to solve the ordinary vertex-ranking problem [6]. We define the list L(~) of a c-ranking ~ of tree T to be a list containing the ranks of all edges visible from the root, that is,

L(p) = {~(e) l e ~ E is visible from the root}.

The ranks in the list L(!o) are sorted in non-increasing order. The list L(~) may contain same ranks with repetition < c. For an integer 1 we denote by eount(L(~), l) the number of l's contained in L(~), that is, the number of visible edges with rank I. By Lemma 1 count(L(to), l) <_ c for each rank I. The 2-ranking ~o in Fig. l(a) has the list L(~,) = {4,3, 2, 1, 1}, and hence eount(L(~), 4) = eount(L(~,o), 3) = count( L(~), 2) = 1 and count(L(~o), 1) = 2. On the other hand, the 2-ranking rl in Fig. l(b) has the list L(V) = {4, 3, 3, 1].

For a list L and an integer i, we define a sublist [i _< L] of L as follows:

[i < L] = {l E L l i <_ l}.

Similarly we define sublists [i < L], [L < i] and [L < i] of g for the integer i. For lists L and L' we use L C L' and L U L' in their usual meaning in which we regard L, L' and L U L ~ as multi-sets.

We define the lexicographical order -< on sequences (lists) of positive integers as follows: let A = {al,a2, "'" ,ap} and B = {bl,b2, "" ,bq} be two sequences (lists) of positive integers, then A -< B if there exists an integer i such that

(a) a j = b j for a l l l < j < i , and (b) either ai < bi or p < i < q.

We write A ~ B if either A = B or A --< B. We are now ready to define notions of optimality. A critical e-ranking ~ of

tree T is defined to be a c-ranking with the lexicographically smallest list L(~,). Every critical c-ranking r is optimM, because all edges of the largest rank are visible and hence the topmost rank in L(~) is equal to the number of ranks used by p. The optimal e-ranking ~ depicted in Fig. l(a) is indeed critical, but the optimal c-ranking r; in Fig. l(b) is not critical since L(~) -K L(rl). P. de la Torte et aI. used the concept of "supercritical ranking" to solve the ordinary edge-ranking problem [3]. We adapt the same notion for c-rankings. We define a c-ranking ~ of tree T to be supercritical if the restriction ~olT(v ) is critical for every vertex v of T. Thus a supercritical c-ranking is critical and hence optimal. The c-ranking ~ depicted in Fig. l(a) is indeed supercritical. A c-ranking ~ of

Page 6: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

395

tree T is subcritical if ~lT(v) is critical for every vertex v of T except the root. Thus a c-ranking ~ of T is subcritical if and only if piT(v) is supercritical for every child v of the root of T. Furthermore a c-ranking ~ of T is supercritical if and only if ~ is subcritical and critical. Although a supercritieal c-ranking is subcritical, a subcritical c-ranking is not always critical and is not always optimal. For example, the optimal c-ranking r] in Fig. l(b) is subcritical, but is not critical.

The definitions above immediately imply that every tree has a critical c- ranking, but do not immediately imply that every tree has a supercritical c- ranking. However, we will show in Section 3 that every tree does in fact have a supercritical c-ranking. Since any supercritieal c-ranking is optimal, it suffices to give an algorithm for finding a supereritieal c-ranking of T as we do in Section 3.

3 O p t i m a l e - r a n k i n g

The main result of this paper is the following theorem.

T h e o r e m 3 . For any positive integer c an optimal c-ranking of a tree T can be found in time O(n 2 log 2 A), where n is the number of vertices in T and A is the maximum vertex-degree of T.

In the remaining of this section we give an algorithm to find a supercritical c-ranking of a tree T in time O(n 2 log A). Our algorithm uses the technique of "bottom-up tree computation." That is, it repeats the following operation for each internal vertex v of a tree T from leaves to the root: constructs a sup ercritical c-ranking ~ of subtree T(v) from those ~1, ~2," �9 ", ~d of the subtrees T(wl) , T ( w 2 ) , . . . , T(wa) rooted at the children wl, w2 , . . . , wd of v. For such a strategy to succeed, it is favorable that a supercritical c-ranking ~ of T(v) could be extended from ~1, ~ 2 , " ", ~d, that is, p could be obtained from ~1, ~2," "", ~ by appropriately labeling the edges ei = (v, wi), 1 < i < d, without changing the labeling of the subtrees. We indeed prove that this actually holds as in the case of ordinary edge-rankings [3], and give an algorithm to find a supercritical c-ranking qo of T(v) from ~i, 1 < i < d.

For notational convenience we may assume that v is the root of tree T and hence T(v) = T. Let E(v) = {ei = (v, wi) [ 1 < i < d}, and let Li = L(~i). We first have the following lemma.

L e m m a 4 . Every tree T has a supercritical c-ranking ~. Furthermore for any supercriticat c-rankings ~i of T(wi), 1 < i < d, T has a supercritical c-ranking

which is an extension of (pi , that is, ~[T(wi) = Y)i for every i, 1 < i < d. []

Lemma 4 implies the existence of a supercritical c-ranking ~, but the proof (omitted in this extended abstract) does not yield a polynomial-time algorithm to decide the d ranks of the edges ei C E(v).

In the remaining of this section we present a sequence of lemmas and corol- laries which help us to decide the d ranks in time O(dn log(d + 1)). Repeating

Page 7: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

396

the same operation for all internal vertices v of T from bottom to top, we can find a supercritical c-ranking of T in time

O ( ~ d ( v ) n l o g ( d ( v ) + l ) ) =O(n21og~),

where d(v) is the number of children of v in T. Note that ~ , e v d(v) = n - 1. We decide the d ranks of the edges el, 1 < i < d, in non-increasing order as in

the case of the ordinary edge-ranking [3]. For a c-ranking ~ of tree T, let my be the maximum rank of edges in E(v), that is, m~, = max{~(ci) Iei e E(v)}. Let n v be the number of edges in E(v) labeled by m~,. We then have the following lemma.

L e m m a 5 . Let ~ and ~ be two subcriticaI c-rankings of tree T. I f (m~,n~) -< then < L( , ) []

The following corollary is an immediate consequence of Lemma .5.

C o r o l l a r y 6. The following (a) and (b) hold:

(a) if p is a supereritieal c-ranking of tree T and ~ is a subcritical c-ranking of T, then (m~,,n~) ~ (mo,nv); and

(b) every supercritical c-ranking ~ o f t has the same pair (m~,n~).

We thus denote by ,$s~p the same value my for all supercritical c-rankings of T, and call fls~p the super rank of tree T. Then Corollary 6 immediately

implies the following.

C o r o l l a r y 7. The super rank flsup of tree T is equal to the minimum integer fl for which T has a subcritieal c-ranking p of m~o = ft. []

We will later give an algorithm SUPER-RANK to find the super rank flsui~ of tree T using Corollary 7.

14 13 12 11 13 3 ~3~ 8 [3 t 6 ~ 4 3 2 1

qS T2ol o 11j_

2&l o I 3,1,

Fig. 3. Illustration of three lists for the case c = 5.

Let fl be a positive integer. Let j , 1 < j < d, be an index such that sublist [Lj < fl] is the lexicographieally largest among all [L~ < 8], 1 _< i < d, that

Page 8: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

397

is, if ej was labeled by/3 then the sublist of ranks in Lj hidden by/3 would be lexicographieally largest. Note that the larger [Lj < fl] is, the smaller is the list of the c-ranking extended from pl, p 2 , ' " , ~d by labeling ej with p. The index j depends on/3. For example, Fig. 3 illustrates a case in which d = 3 and c = 5, and if/3 = r = 7 then j = 1, and if/3 =/32 = 9 then j = 2. In Fig. 3 a number in the array corresponding to list Li represents count(Li, 7) for its column number 7. Then the following lemma holds.

L e m m a 8 . Let j be the index defined for/3 as above, and assume that tree T has a subcritical c-ranking 77 of rn~ = /3. Then T has a subcritical c-ranking such that ~(ej) = m~ =/3 and L(~) ~ L(~). []

The following corollary is an immediate consequence of Lemma 8.

C o r o l l a r y 9. Let j be the index defined for/3 = flsup, that is, let [Lj < flsup] be the lexicographically largest one among all sublists [Li </3s~p], 1 < i < d. Then tree T has a supercritical c-ranking ~ such that ~(ej) =/3sup. []

Thus, once/3sup is decided, one can easily decide an edge ej to be labeled by /3~up. Furthermore we have the following lemma.

L e m m a l 0 . Let j be the index defined for/3 =/3~up, and let T' = T - T(ej) . Then any supercritical c-ranking ~ of T ~ can be extended to a supercritical c- ranking ~ of T as follows:

{ /3sup if e = ej ; ~(e) = ~j(e) if ~ ~ E(T(w~)); and

~'(e) if e C E(T') . []

Using Corollary 9 and Lemma 10 one can easily verify that the following algorithm UPDATE correctly decides the ranks of el, e2, -- �9 ed if algorithm SUPER-RANK, given later, could correctly find the super rank of trees. An algorithm similar to UPDATE is used to find an ordinary edge-ranking in [3].

P r o c e d u r e UPDATE(v); beg in

1 T' :=T@); 2 for d := d(v) d o w n t o 1 do { decide the d(v) ranks in non-increasing

order, where d(v) is the number of children of v in T } beg in

3 let wii, wi2, "" ", wid be the children of v in T'; 4 find the super rank flsup of tree T ~ by the algorithm SUPER-RANK;

{ SUPER-RANK will be given later ) 5 find an index ii, 1 <_ j <_ d, such that [Lij < fl~up] is the

lexicographically largest one among the d lists [Lik < fl~up], 1 _< k _< d; 6 label edge % = (v, wij) with flsup; { of. Corollary 9 ) 7 T' := T ' - T ' ( e i j ) ; { cf. Lemma 10 }

Page 9: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

398

e n d end;

Clearly line 1 can be done in time O(1). Lines a-7 are e x e c u t e d d = d(v) times. One execution of lines 3 and 5-7 can be done in time O(n). Therefore if one execution of line 4, i.e., SUPER-RANK, takes time O(n log(d+ 1)), then the algorithm UPDATE runs in time O(dnlog(d + 1)) as we claim. Thus it suffices to give the algorithm SUPER-RANK for finding fl~up of a tree in time O(n log(d + I)).

By Corollary 7, in order to find /3sup we need to check the existence of a subcritical c-ranking !~ with rn~ = fl for some integers /9. A necessary and sufficient condition for the existence will be given in Lemma 12 below, which is a key lemma in the paper to make the algorithm faster and simpler than the best algorithm known for the ordinary edge-ranking. For a c-ranking ~ of T~ let ce = count(L(p), m~), then c~ _< c. Before presenting Lemma 12 we prove the following lemma.

L e m m a 11. Assume that ~a is a subcriticaI c-ranking of tree T and that/3 is an integer such that fl >_ m~ and count(Udi=iLi,~) < c - 1 . Then T has a subcritical c-ranking ~* such that

(i) m~. -= fl; and (ii) if fl > m~ then c~. = 1 + count(Ud=lLi,fl).

Proof. Let ~(ek) = m~ for some k, 1 < k _< d. We then modify ~ to ~* by labeling e~ with fl; all the other labels remain the same. Clearly ~* is a subcritical c-ranking of T and m~,. = ft. If ,8 > m~, then n~* = 1 and c~. = 1 + count(Ud:iL{, ;3). r~

The necessary and sufficient condition in Lernma 12 is recursive. That is, the existence of a subcritical c-ranking ~, of a tree T is reduced to the existence of a sub critical c-ranking c / o f a smaller tree T t satisfying an additional condition: c~, _< c" for some c", 1 < c" _< c. We are now ready to present Lemma 12.

L e m m a 12. Let 1 < c' < c, and let j be the index defined for/3 as before. Tree T has a suberitical c-ranking ~ such that ~(ej) = rn~ = /~ and c~ < c ~ if and only if the following three conditions hold:

cou (us < c ' - 1; (b) count(Ud=iLi,#) < c for all ranks 2/E [fl < Zj]; and (c) if d > 2, then tree T' = T - T(ej) has a subcr~tical c-ranking ~J such that

(i) if cou t(uJ= L ,9) < c ' - 2, then = and <_ c" here c" = c' -- nj -- 1 and nj : count(Lj,fl); and

(ii) if count(U~=iLi,/3 ) = d - 1, then there is an integer~3', 1 <_/3' < f l - 1, such that count(Ud=lLi, 9 I) < c -- 1, and furthermore m W -= fl' for the

iCj largest/9' among all such integers.

Page 10: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

399

Proof. ====:~: Let ~ be a subcri t icai c-ranking o f T such tha t 9 ( e j ) = m y = fl and c~ < c'. Since one or more edges in E ( v ) including ej are labeled with fl, we have 1 + coun t (ud=lL{ , /~ ) < c~ < c', and hence (a) holds true. Since any integer 7 > fl satisfies c > c o u n t ( n ( ~ ) , ~ / ) = c o u n t ( u d = l n i , 7 ) , (b) holds true. Thus it suffices to prove (c) and one may assume tha t d > 2. Let { ' = ~ I T ' , then p ' is a subcr i t ical c-ranking of T ' and my, < m y = ft. Since count (ud=~n{ , /~) < c' -- 1, there are the following two cases. Case (i): c o u n t ( U ~ : l L i , f l ) < c' - 2.

I f m ~ , = t3 , t h e n c ~ , + n i + l = c~ < c ~ and hence c~, < c ~ - n j - l = c ~ as required. Thus one m a y assume tha t fl > m~,,. Clearly count(ud=~ Li , fl) < c - 1.

~#j Apply ing L e m m a 11 to T ~, one can know tha t T ~ has a subcri t ical c-ranking ~* such t h a t m~* = fl and c~. <<_ c ' , because

c~. = ~ + ~ o ~ t ( u ~ = ~ L ~ , ~ ) = 1 + c o ~ ( u ~ = ~ L ~ , ~ ) - ~ < 1 + c' - ~ - ~ = ~".

Case (ii): c o u n t ( u d = ~ L i , Z ) = c' -- 1. In this case, no edge in E ( v ) - { e j } is labeled with fl by ~ ' , and hence 1 _<

my, < f l - 1 . Since l +count (ud=~ ni , m y , ) < c f , < c, we have count(ud=~ Li , m y , ) i#j i~j

< c - 1. Thus we have fl ' >_ my, since r is the largest integer such t ha t 1 _ < /~' < f l - 1 and coun t (ud=~Li , r < c - 1. Therefore, apply ing L e m m a 11 to T ' ,

one can know tha t T ~ has a subcri t ical c-ranking ~* with m y . = r ~ : Suppose tha t (a), (b) and (c) hold. Ex tend the subcri t ical c-ranking f '

of T ~ to an edge-label ing ~ of T as follows:

/3 i f e = ej; ~(~) = ~ ( e ) if~ c E(T(wj)); and

~ ' (e ) otherwise.

Then {(ej) = m y = /3 and

L ( ~ ) = L ( ~ ' ) U {f l} U [/3 < Lj] . (1)

We now cla im tha t every 7 > ] satisfies

eo~t (L(~) , 3`) < c. (2)

I f ei ther 1 < 3 ̀ < fl or 3' > ~3 and 3 ̀ ~ n j , then by (1) and (c) we have c o u n t ( L ( ~ ) , 7 ) = c o u n t ( L ( ~ ' ) , ~ : ) < c. On the other hand, if 3 ̀ e [/3 < Lj] , then by (1), (b) and my, < fl we have c o u n t ( L ( ~ ) , 3 ` ) = c o u n t ( U d = l L { , 7 ) < c. Thus it suffices to prove c o u n t ( L ( { ) , / 3 ) < c. If either d = 1 or d >_ 2 and m~o, < /3 , then by (a) we have

c f = c o u n t ( L ( f ) , fl) = c o u n t ( U ~ : l L i , fl) + 1 < c' < c.

If d > 2 and my, = fl, then by (c) ~ ' should satisfy (i) and hence c~,, < c" and consequent ly

c~, = count(n(9~) , /3) = c~,, + nj + 1 <_ c" + n j + 1 = c' <_ c.

Page 11: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

400

Thus we have verified (2) and % _< c'. By (2) and Lemma 1 ~ is a c-ranking of T, and is subcritical, rn

Let B = {7 ] 1 _<_ 7 _< n - 1 and count(U~=sLi,7) <_ c- 1}. Then T necessarily has a subcritical c-ranking ~ such that m~ = /3 for some integer /3 E B; for example, label el, e2 , . ' . , ed by the smallest d positive integers larger than all labels used for ~01, ~ 2 , " ' , ~d, then the resulting subcritical c-ranking g) of T satisfies rn~ E B. Note that the labeling of the n - 1 edges of T with 1, 2, �9 �9 �9 n - 1 is a trivial c-ranking of T. Thus B is a set of integers eligible for flsup. Prom Lemma 12 one can easily derive the following recursive algorithm CHECK to decide whether T has a subcriticM c-ranking qo of m~ = /3 and % <_ c' for a given integer/3 E B by checking the conditions (a), (b) and (e) in Lemma 12.

P r o c e d u r e CHECK(T, fl, c'); beg in

8 i f count(Ud=lLi,/3) > c ~ - 1 t h e n r e t u r n false { the condition (a) does not hold} else beg in {the condition (a) holds}

9 let wl ,w2, - - . ,wd be the children of v in TI {d > 1} 10 let j , 1 _< j _< d, be an index for which [Lj < p] is the lexicographically

largest among all ILk < fl], 1 < k < d; 11 i f co'ant(cldi=l Li, 7) :> c for a rank 7 E [fi < Lj]

t h e n r e t u r n false {the condition (b) does not hold} else {the condition (b) holds}

12 i f the root v of T has exactly one child {obviously (c) holds} t h e n r e t u r n true else beg in {d > 2}

13 T' := T - T(e j ) ; 14 if count(Od=lLi,/3) < c'-- 2 t h e n beg in 15 nj := count(Lj , /3); 16 c" : = c ' - - n j _ 1;

CHECK(T',/3, c ' ) {recursively check the condition (c)} e n d else {coun t (Uda Li,/3) = c' -- 1}

17 if there is no integer/3', 1 < fl' < / 3 - 1 , s.t. count(Ud=lLi,/3') < c - 1 ~#j

t h e n r e t u r n false {the condition (c) does not hold} else beg in

18 let fl', 1 <__ fl' _< fl - 1, be the largest one among all integers such that count(Od~=l Li,/3') <_ c - 1;

i#j CHECK(T', fl', c) {recursively check the condition (c)}

e n d e n d

e n d end;

Page 12: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

401

By Corollary 7 and Lemma 12, /3sup is the smallest integer fl satisfying the conditions (a), (b) and (c) for c' = c. Therefore we have the following algorithm SUPER-RANK to find/3sup of tree T.

P r o c e d u r e SUPER-RANK(T); b e g i n

19 B := {~1 1 <_ 7 < n - 1 and count(Ud=tnl,7) < c - 1}; 20 choose the smallest integer/3 E B satisfying the conditions (a), (b) and (c)

by executing CHECK(T,/3, c) for all/3 E B; 21 /?sup := fl

end ;

We will prove the following lemma later.

L e m m a 1 3 . The algorithm CHECK takes O(n) time.

By Lemma 13 the straightforward implementation of SUPER-RANK takes O(n 2) t ime since IBI < n - 1. P. de la Torre et al. used a binary search to decide /3~up [3]. We also use a binary search, but the range of our search is bounded by d. Thus we can improve the time-complexity O(n 2) to O(n log(d+ 1)) as follows.

If count(Ud=lL~, 7) _~ c for all ranks 7 C Ud=IL~, let a = 0. Otherwise, let be the largest rank 7 such that count(U~=lLi,7 ) k c + 1. Then /?sup _> a + 1. Let /31 < /72 < " " < /?d be the smallest d integers such that /?i >_ a + 1 and count(ud=lLi,/3i) _~ c - 1. For the example in Fig. 3 ~ = 5,/?~ = 7,/32 = 9 and /33 = 10. Then the following Lemma 14 holds.

L e m m a 14. Tree T has a subcritical c-ranking ~ such that my <_ rid, and T has no subcritical c-ranking ~ such that mv </31.

Proof. Let f /? i i f e = e i , l < i < d ; a n d

~(e) \ if e e 1 < i < d

Then the definition of/71,/?2," "',/3d implies that there are no more than c edges of the same rank visible from v under ~. Therefore, by Lemma 1, p is a c-ranking of T. Clearly ~ is subcriticat and m~ =/3~.

Let 77 be any subcritical c-ranking of T. Since ~ is a c-ranking, my > o~ and m~ satisfies count(Ud=lLi, m,) < c - 1. Therefore, by the definition of/31, we have /31 ~ rn~. []

Corollary 7, Lemmas 11, 12 and 14 immediately imply the following lemma.

L e m m a 1 5 . The following (a) and (b) hold:

(a) /3sup c {/3,, & , . . . , &}; and (b) let i be an integer such that 1 < i < d, then fl~p C {fll,/?~,... ,/3i} if and

only if T has a subcritical c-ranking ~ of m~ =/3i. []

Page 13: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

402

Replace line 19 of Procedure SUPER-RANK with the following:

B : = . . . , `3d}.

Then, using the binary search technique, one can find the smallest integer 2 at line 20 by calling CHECK at most [log(d+ 1)] times. Clearly line 19 can be done in t ime O(n), and line 21 can be done in t ime O(1). Therefore the algori thm SUPER-RANK can be done in time O(n log(d + 1)) if Lemma 13 is correct.

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

Order- 315 0 010 TotalCount PointerToList

Fig. 4. Illustration of data-structure Order for the example of Fig. 3.

In the remaining of this section we prove Lemma 13. We use an array Order to support the operations at lines 10, 17 and 18. The array Order consists of records, each of which contains two items of data: TotaICoun~ and PointerToList.

d L~. For The array Order is of length m, where m is the largest integer in Ui= 1 each integer I, 1 < 1 < m, the i tem TotalCount of record Order[t] is the sum of all count(L~, l), 1 < i < d. The i tem PointerToList of record Order[l] points to a list s of records containing two fields: one of the fields stores the names of lists L~ such that count(Li, l) > 1 and the other stores count(L~,l), 1 < i < d. Furthermore we assume that list s links the names of the lists Li in lexicographicalIy non-increasing order of [Li < l]. This is one of the key ideas behind the speed-up of our algorithm. We also use d lists Same[i]; 1 < i < d; Same[i] links all the same names L~'s appearing in the lists El, 1 < t < m. The data-structure Order is illustrated in Fig. 4 for the example of Fig. 3. Lists Same[i] are not drawn in Fig. 4 for simplicity. One can construct the data- structure Order by radix-sorting a set of d lists, {(t, count(L~,l)) [ m >_ I > i and count(Li,l) > 1}, 1 < i < d, in lexicographically non-increasing order. Since T has n - 1 edges, the d lists contain at most n - 1 elements in total. Furthermore 0 < count(L~,l) < c. Therefore the radix sorting can be done in t ime O(c. m + n) [1]. Clearly an optimal c-ranking of tree T uses at most

Page 14: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

403

[(n - 1)/el ranks, and hence m <_ F(n - 1)/c]. Thus Order can be constructed in t ime O(e . m + n) = O(n).

We are now ready to prove Lemma 13. P r o o f o f L e m m a 13

Clearly lines 8, 9 and 12 can be executed total in t ime O(n) during one execution of CHECK(T, fl, d).

We now verify that one execution of lines 11 and 13-16 can be done in t ime O(]F,(T(ej))[). Scanning Order[l] for all ranks l E [/3 < Lj], one can execute line 11 in t ime O(]E(T(ej))I) since Lj contains at most IE(T(ej))I ranks. Traversing list Same[j], one can easily update the data-structure Order for a new tree T t at line 13 in t ime O(IE(T(e~))I). Lines 14-16 can be easily done in O(1) time. Thus we have verified that one execution of lines 11 and 13-16 can be done in t ime O(IE(Z(ej))l ), Since

0 ( ~ IE(T(ej)),] =O(,E(T)I)=O(n), \l<j<d /

lines 11 and 13 16 can be executed total in t ime O(n). We next claim that lines 10, 17 and 18 can be done total in t ime O(n). Scan

array Order[I] fl'om t = / 3 - 1 in decreasing order of l until l = lk such that TotaICount of Order[lk] is > 1. Then the top element of list /21k is Lj. Thus the index j in line 10 can be easily found. One can search fl' in lines 17 and 18 by scanning array Order[l] from l = /3 - 1 in decreasing order of 1 until l = / 3 / s u c h tha t TotalCount of Order[~3 I] is < c - 1. (Note that the data-structure Order in lines 17 and 18 has been updated for the new tree T / at line 13.) If there is such an integer/3~, then one can similarly find the index j~ for/3~ by scanning Order[l] from l = m i n{ / 3 ' - 1, Ik}. Thus one can execute lines 10, 17 and 18 total in t ime O(n) since we scan Order at most twice.

Thus we have shown that the algorithm CHECK can be done total in O(n) time. []

4 ConcLusion

We newly define a generalized edge-ranking of a graph, called a c-ranking, and give an algorithm for finding an optimal c-ranking of a given tree T in t ime O(n 2 log A) for any positive integer e, where n is the number of vertices in T and A is the max imum vertex-degree of T. This is the first polynomial- t ime algo- r i thm for the generalized edge-ranking problem. Our algorithm is faster than the best algorithm of complexity O(n 3 log n) known for the ordinary edge-ranking problem [3], and is simple in a sense that it does not use a two-layered greedy method.

We may replace the positive integer c by a function f : N ~ N to define a more generalized edge-ranking of a graph as follows: an f-ranking of a graph G is a labeling of the edges of G with integers such that , for any label i, deletion of all edges with labels > i leaves connected components, each having at most

Page 15: Generalized edge-rankings of trees · Fig. 1. Two optimal 2-rankings of a tree T. is a labeling of the edges of G with integers such that, for any label i, deletion of all edges with

404

f(i) edges with label i. By some trivial modifications of our algorithm for the c-ranking of a tree, we can find an optimal f - ranking of a given tree in the same time complexity of O(n 2 log A).

Our work raises several interesting open problems:

1. Is there a faster sequential algorithm for trees ? 2. Wh~t is the complexity of tile c-ranking problem for general graphs ? 3. Wha t is the complexity of parallel algorithms for c-rankings of trees or

general graphs ?

A c k n o w l e d g e m e n t . We would like to thank Professor A. Nakayama for his careful reading and valuable comments on an early version of the paper.

References

1. A. V. Aho, J. E. Hopcroft, and J. D. Ullman, The Design and Analysis of Com- puter Algorithms, Addison-Wesley, Reading, MA, 1974.

2. H. Bodlaender, J. S. Deogun, K. Jansen, T. Kloks, D. Kratsch, H. Miiller, and Zs. Tuza, Rankings of graphs, Proc. of the International Workshop on Graph- Theoretic Concepts in Computer Science, Lecture Notes in Computer Science, Springer Verlag, 903 (1994), pp. 292-304.

3. P. de la Torte, R. Greenlaw, and A. A. SchS.ffer, Optimal edge ranking of trees in polynomial time, Algorithm@a, 13 (1995), pp. 592-618.

4. P. de la Torre, R. Greenlaw, and A. A. Schs A note on Deogun and Peng's edge ranking algorithm, Technical Report 93-13, Dept. of Computer Science, Univ. of New Hampshire, Durham, New Hampshire 03824, USA, 1993.

5. J. S. Deogun and Y. Peng, Edge ranking of trees, Congressus Numerantium, 79 (1990), pp. 19-28.

6. A. V. Iyer, H. D. Ratliff, and G. Vijayan, Optimal .node ranking of trees, Infor- mation Processing Letters, 28 (1988), pp. 225-229.

7. A. V. Iyer, tI. D. Rattiff, and G. Vijayan~ Parallel assembly of modular products - an analysis, Technical Report PDRC, Technical Report 88-06, Georgia Institute of Technology, 1988.

8. A. V. Iyer, H. D. Ratliff, and G. Vijayan~ On an edge-ranking problem of trees and graphs, Discrete Applied Mathematics, 30 (1991), pp. 43-52.

9. N. Megiddo, Applying parallel computation algorithms in the design of serial algorithms, Journal of the ACM, 30 (1983), pp. 852-865.

10. A. Pothen, 'The complexity of optimal elimination trees, Technical Report CS-88- 13, Pennsylvania State University, USA, 1988.

11. A. A. Schiffer, Optimal node ranking of trees in linear time, Information Process- ing Letters, 33 (1989/90), pp. 91-96.

12. X. Zhou, It. NagM, and T. Nishizeki, Generalized vertex-rankings of trees, Infor- mation Processing Letters, 56 (1995), pp. 321-328.

13. X. Zhou and T. Nishizeki, An efficient algorithm for edge-ranking trees, Pron. of the 2nd. European Syrup. on Algorithms, Lecture Notes in Computer Science, Springer-Verlag, 855 (1994), pp. 118-129.

14. X. Zhou and T. Nishizeki, Finding optimal edge-rankings of trees, Proc. of the 6th Annual ACM-SIAM Syrup. on Discrete Algorithms, 1995, pp. 122-131.