Upgrading Vertices In Trees, SeriesParallel Digraphs And General
SeriesParallel Digraphs To Bound Path Length+
Doowon Paik Sartaj Sahni
University of Minnesota University of Florida
Abstract
We consider trees, seriesparallel digraphs, and general seriesparallel digraphs that have vertex
weights and delays. The length/delay of a path is the sum of the delays on the path. We show
that minimal weight vertex subsets X such that the length of the longest path is bounded by a
given value 6 when all vertices in X are upgraded to have delay 0 can be found in pseudo polyno
mial time. In case all delays are unit or all weights are unit, our algorithms have a quadratic com
plexity. For the case of trees with unit weights and unit delays, we develop a linear time algo
rithm.
Keywords And Phrases
Vertex upgrading, bounding path length, trees, seriesparallel digraphs, general seriesparallel
digraphs
+ Research supported, in part, by the National Science Foundation under grant MIP 8617374.
2
1. Introduction
Directed acyclic graphs (dags) can be used to model circuits. Each vertex of the dag has a delay
associated with. The delay of any signal path is the sum of the delays of the vertices on the path.
The delay of a circuit is the length of the longest path in the dag. In an effort to reduce circuit
delay, we may attempt to upgrade some of the dag vertices. Upgrading a vertex reduces its delay
but comes at some cost. In this paper we consider an extreme form of upgrade that results in the
vertex delay being negligible (i.e., zero) relative to the delay before upgrading. For each vertex v
of the dag G = (V, E) we use d(v) to denote its delay before upgrade and w(v) to denote the cost of
the upgrade.
Let d(G) be the length of the longest path in G. Let GX be the graph that results when the
vertices in X are upgraded. Let d(GX) be the length of the longest path in G[X. The dag vertex
upgrade problem (DVUP) is that of finding a minimal weight vertex set X such that d(G )) < ,
where 6 is an input parameter (Figure 1).
(5,3) (0,3)
(2,2)_ .Q (2,2)O
u1 05 1 05
(3,4) (3,4)
2 4 2 4
(1,3) (3,2) (1,3) (0,2)
(a) G with 6 = 6 (b)X = {3, 4} is the minimal solution
d(GC) = 6
Figure 1: DVUP example (the first(second) coordinate is the delay(weight) of the vertex).
Throughout this paper, we assume that the weights, delays, and 6 are nonnegative integers.
In [PAIK91], we showed that:
(1) DVUP is NPhard for directed chains.
(2) DVUP can be solved in O(n3logn) time for unit weight unit delay dags (n is the number of
vertices in the dag).
(3) DVUP is NPhard for dags with unit weight but non unit delays when 6 2 2 and is solvable
in O(n2) time when 6 = 1.
In addition, we proposed a backtracking algorithm and several heuristics for general dags.
The related problems of vertex splitting and vertex deletion to bound path lengths were studied
by Paik, Reddy, and Sahni in [PAIK90ab].
In this paper we consider the DVUP for trees, seriesparallel dags (SPDAGs) and general
seriesparallel dags (GSPDAGs). The results we obtain are:
(1) An O(n) time algorithm for unit weight unit delay trees (Section 2).
(2) Pseudo polynomial time algorithms for trees, SPDAGs and GSPDAGs with general weights
and delays (Sections 2, 3, 4). These algorithms have complexity O(n2) when either 6 = O(n),
all weights are unit, or all delays are unit (note that if all delays are unit, then d(G) < n and
so 8 < n for the problem to be nontrivial).
2. Trees
2.1. Trees With Unit Weight And Unit Delay
When the dag is a rooted tree T such that w(v) = d(v) = 1 for every vertex, the minimum weight
vertex subset X such that d(T[X) 6 can be found in O(n) time by computing the height, h, of
each vertex as defined by:
( 1 v is a leaf
h(v) = 1+ max {h(u)  u is a child of v}, otherwise
X is selected to be the set:
X= {v I h(v) > 6}
The vertex heights can be computed in O(n) time by a simple postorder traversal of the tree T
[HORO90]. The correctness of the procedure outlined above is established in Theorem 1. Note
that when all vertices have unit weight, the weight of a set, Y, of vertices is simply its cardinality
\Y\.
Theorem 1: For any tree T let h(v) be the height of vertex v. The set
X= {v I h(v) > 6}
is a minimum cardinality vertex set such that d(TX[) < 6.
Proof: The fact that d(T[X) 6 is easily seen. The minimality ofX is by induction on the
number, n, of vertices in T. For the induction base, we see that when n = 0, JX = 0 and the
theorem is true. Assume the theorem is true for all trees with < m vertices where m is an arbitrary
natural number. We shall see that the theorem is true when n =m + 1. Consider any tree with n =
m + 1 vertices. Let X be the set of all vertices with height > 8. If AIX = 0, then X is clearly a
minimal set with d(T[Y) < 6. Assume AX > 0. In this case the root, r, of T has h(r) > 6 and so is
in X. First, we show that there is a minimal vertex set W that contains r and for which d(TIW) <
6. Let Z be a minimal vertex set for which d(TIZ) I 6. If r Z, then let r, u1, u2, ..., h(r) be a
longest root to leaf path in T. Since h(r) > 6, at least one of the u,'s is in Z. Let u, be any one of
the u,'s in Z. Let W = Z + {r} {u,}. Clearly,  W = Z. Since all root to leaf paths that include
u, also include r, the length of these paths in TIW is the same as in TIZ. The length of the remain
ing paths in TIW is no more than in TIZ. So, W is a minimal cardinality vertex set such that
d(TIW) < 6 and furthermore W contains the root r.
Let A(v), A e {X, W}, denote the subset of A that consists only of vertices in the subtree,
T(v), rooted at v. Since d(T(v)X[(v)) 6, d(T(v)IW(v)) 6, and I T(v)l m for each v that is a child
of r, it follows from the induction hypothesis that X(v) = I W(v) for each v that is a child of r.
Hence, A = 1 +  IX(v)l= I W. D
v is a child of r
2.2. General Trees
Since a chain is a special case of a tree and since DVUP for chains with arbitrary weights and
delays is known to be NPhard [PAIK91], we do not expect to find a polynomial time algorithm
for general trees. In this section we develop a pseudo polynomial time algorithm (i.e., one whose
complexity is polynomial in the number of vertices and the actual values of the vertex delays and
weights). We modify the definition of height used in the preceding section to account for the ver
tex delays. We use H to denote this modified height.
( d(v) v is a leaf
(v) d(v) + max {H(u)  u is a child of v}, otherwise
For each vertex v, let L(v) be a set of pairs (1, c) such that there is a subset X c T(v) such
that d(T(v)[Y) = 1 and I w(u) = c. Let (l/, cl) and (12, c2) be two different pairs such that 1i <
u X
12 and cl, c2. In this case, pair (li, cl) dominates (12, c2). Let S(v) be the subset of L(v) that results
from the deletion of all dominated pairs. Let S(r) be this set of dominating pairs for the root r of
T. Let (1', c') e S(r) be the pair with least cost c'. It is easy to see that the least weight vertex set
W such that d(TIW) < 6 has weight c'. We shall describe how to compute S(r). Using the back
trace strategy of [HOR078, cf chapter on dynamic programming] we can compute the W that
results in d(TIW) 6 and Y w(u) = c' in less time than needed to compute S(r) (however, S(r)
u W
and some of the other S's computed while computing S(r) are needed for this).
For a leaf vertex v, S(v) is given by:
{ (0, w(v)) } d(v)> 6
S(v) ( 0, w(v) ), (d(v), 0) d(v) <6
For a non leaf vertex v, S(v) may be computed from the S(u)'s of its children ul, ... uk
First, we compute U(v) as the set of nondominated pairs of the form (1, c) where 1 = max { /, 12,
k,
k } and c = C c, for some set of pairs (l,, c,) e S(u,), 1 < i < k_. Let V(v) and Y(v) be as
S=1
below:
(v)= { (1, c+w(v)) (1, c) e u(v)}
Y(v) = { (l+d(v), c)  l+d(v) < 6 and (1, c) e U(v) }
Now, S(v) is the set of nondominated pairs in V(v) u Y(v). Since S(v) contains only nondom
inated pairs, all pairs in S(v) have different / and c values. So, IS(v)l min { 6, o } where ( =
n
I w(u). Using the technique of [HOR078], S(v) can be computed from the S(u)'s of its children
u=1
in time O(min{6,mc*k,). To compute S(r) we need to compute S(v) for all vertices v. The time
needed for this is O(min{6,m} *k,) = O(miin{6,(o}*n)
Note that for unit delay trees, 6 < n and for unit weight trees (o = n. So in both of these
cases the procedure described above has complexity O(n2).
3. SeriesParallel Dags
A seriesparallel digraph, SPDAG, may be defined recursively as:
1. A directed chain is an SPDAG.
2. Let s, and t, respectively, be the source and sink vertices of one SPDAG G, and let s2 and t2
be these vertices for the SPDAG G2. The parallel combination of G, and G2, G1/G2, is
obtained by identifying vertex s, with s2 and vertex tj, with t2 (Figure 2(c)). G/1G2 is an
SPDAG. We restrict G, and G2 so that at most one of the edges < s,t>, < s,t> is present.
Otherwise, G//G2 contains two copies of the same edge.
3. The series combination of G, and G2, GIG2, is obtained by identifying vertex t1 with s2 (Fig
ure 2(d)). GIG2 is an SPDAG.
The strategy we employ for SPDAGs is a generalization of that used in Section 2.2 for trees
with general delays and weights. Let s and t, respectively, be the source and sink vertices of the
SPDAG G. Let D(l,Y,G) be a minimum weight vertex set that contains the vertices in Y, Y c {s,
t}, and such that d(GID(1,Y,G)) 1 and let f(G) be as below:
f(G)= {(l,c,Y)  0 l 6, c = w(u)}.
ueD(I,Y,G)
Let (1 ,cl ,Yi) and (12 ,c2 ,Y) be two different triples in f(G). (i ,cl ,Yi) dominates (2 ,c2 ,Y2)
iff /, < 12, c, c2 and Yi = Y2. Let F(G) be the set of triples obtained by deleting all dominated tri
ples off(G). If (l',c',Y') is the least weight triple (i.e., the one with least c) in F(G) then the least
weight W such that d(Gii ) < 8 has weight c'. We shall show how to compute F(G) and hence
(l',c',Y'). The actual W may be obtained using a backtrace step as described in [HOR078].
S1 t 2 G, t
0< G, >o~ C< G o G
(a) G, (b) G2 (c) G1/G2
s' G2l t2
(d) GG2
Figure 2: Seriesparallel digraph.
3.1. G Is A Chain
Consider the case when G has only two vertices s and t. F(G) is constructed using the code:
F(G) := { (0, w (s)+w(t), {s, t}) }
if d(s) < 6 then F(G) := F(G) u { (d(s), w(t), {t}) }
if d(t) < 6 then F(G) := F(G) u { (d(t), w(s), {s}) }
if d(s)+d(t) < 6 then F(G) := F(G) u { (d(s)+d(t), 0, 0) }
When G is a chain with more than two vertices, it may be regarded as the series composition of
two smaller chains G, and G2. In this case F(G) may be constructed from F(GI) and F(G2) using
the algorithm to construct F(G1G2) described in the next section.
3.2. G is of the form G1G2
The following lemma enables us to construct F(G G2) from F(GI) and F(G2).
Lemma 1: If(l, c, Y) e F(G1G2), then there is an (i ,cl ,Y1) e F(Gi) and an (2 ,c2 ,2) e F(G2) such
that
(a) D(llY ,1 ,) = D(I,Y,GIG2) rn V(G1)
(b) D(12,Y2 ,G) = D(l,Y,GIG2) n V(G2)
(c) D(I,Y,GG2) =D( ,Y1 ,G) u D(12 ,Y2 ,G2)
(d) c = I W(U), c1 = I W(U), C2 = C W(U)
u e D(1,Y,GIG2) u e D(1,YT,GI) u e D(1,YT,G2)
Proof: Let A = D(l,Y,GIG2) rn V(Gi) and B = D(l,Y,GIG2) n V(G2). Since V(GiG2) = V(Gi) u
V(G2), D(1,Y,G G2) = A uB. Let s, and t,, respectively, denote the source and sink vertices for G,, i
e { 1, 2}. s and t are the corresponding vertices for GiG2. We see that s = sl, t = t2, and t1 = s2.
Case 1 : [ t D(1,Y,GG2) ]
Let 11 = d(GiIA), Y1 =A r {sj}, and c, = w(u). We shall show that (li ,c ,Y1) e F(Gi). Sup
u A
pose it is not. Then it must be dominated by a triple (l'j ,c' ,Y1) that is in F(GI). Let C =
D(l'I,Y1,G,). It follows that c', = w(u) and that (l',+d(G2IB)d(s2), c'+ I w(u), Y) dominates
ueC ueB
(li+d(G2IB)d(s2), ci+ I w(u), Y) (l, c, Y). So, (1, c, Y) V F(GIG2). This contradicts the
ueB
assumption on (1, c, Y). Hence, (1i ,c ,Yj) e F(G1). Similarly, (/2 ,c2 ,Y2) F(G2). (a) (d) are an
immediate consequence as D(l1 ,Y, ,Gl) = A and D( ,Y2 ,G2) = B.
Case 2 : [ tj E D(l,Y,G1G2)
This is similar to case 1 D
Lemma 1 suggests the following approach to obtain F(GIG2) from F(GI) and F(G2):
Stepi: Construct a set Z of triples such that F(GIG2) c Z. This is obtained by combining
together all pairs of triples (1i ,cl ,Y) e F(Gi) and (/ ,c2 ,Y) E F(G2).
Step2: Eliminate from Z all triples that are dominated by at least one other triple of Z.
The triples (/i ,cl ,Y1) and (12 ,c2 ,Y) are compatible iff( tj e Yi and s2 e Y2) or ( tj v Yi and
s2 Y2 ). Only compatible triples may be combined. Assume that we are dealing with two com
patible triples. We first obtain the triple (1, c, Y) as below:
if t1 E Y1
then (1, c, Y) := (11+12, CI+c2w(tl), Y1uY2{t1})
else (1, c, Y) := (l,+12d(tl), c1+c2, Y1uY2{t })
Next, (1, c, Y) is added to Z provided I 6.
3.3. G = G1/G2
When G = G1/G2 we use Lemma 2 which is the analogue of Lemma 1.
Lemma 2: If (, Y) e F(G1/G2), then there is an (1i ,cj ,Y1) e F(Gi) and an (2 ,c2 ,2) e F(G2)
such that
(a) D( ,Y1 ,Gi) = D(I,Y,GiG2) n V(Gi)
(b) D(12,Y2,G2) = D(l,Y,GIG2) rn (G2)
(c) D(l,Y,GG2) = D(l ,Y, ,G1) U D(12 ,Y2 ,G2)
(d) c = I W(u), C1 = I w(u), c2 = w(u).
u e D(I,Y,GIG2) u e D(1,YI,GI) u e D(12,Y2,G2)
Proof: Similar to that of Lemma 1. D
To obtain F(G//G2) from F(G1) and F(G2) we use the two step approach used to compute
F(G1G2). For step 1, we compute the triple (1, c, Y) obtained by combining (1l ,c1 ,Yl) E F(G1) and
(12 ,c2 ,Y2) E F(G2). The triples are compatible iff Yi = Y2. Again, only compatible triples may be
combined. For compatible triples, (1, c, Y) is obtained as below:
S:= max {11, 12}
1 := C + C2 + W(c)
u E Yl
Y:= Y
Next, (1, c, Y) is added to Z.
3.4. Complexity
The seriesparallel decomposition of an SPDAG can be determined in O(n) time [VALD79]. By
keeping each F(G,) as four separate lists of triples, one for each of the four possible values for the
third coordinate of the triples, F(GIG2) and F(G//G2) can be obtained in O( F(G1) + F(G2) ) time
from F(GI) and F(G2). Since F(GI) (F(G2)) contains only non dominated triples, it can contain at
most four triples for each distinct value of the first coordinate and at most four for each distinct
value of the second coordinate (these four must differ in their third coordinate). Hence, IF(GI)
4*min { 6 + 1, 1 w(u) } and F(G2) < 4*min { 6 + 1, w(u) }. So, we can obtain F(G)
u e V(GI) u e V(G2)
for any SPDAG in time O(n*min {6, i w(u)} ). For SPDAGs with unit delay or unit weight,
u e V(G)
this is O(n2).
4. General Series Parallel Dags
General series parallel dags (GSPDAGs) were introduced in [LAWL78, MONM77, SIDN76]. A
linear time algorithm to determine whether or not a given dag is a GSPDAG was developed in
[VALD79]. This paper also contains a linear time algorithm to obtain a seriesparallel decompo
sition of a GSPDAG. The definitions and terminology used in this section are derived from
[VALD79].
A transitive dag is a dag G = (V, E) such that < ij> e E whenever there is a path from i to
j. The transitive closure, G+ = (V, E+) of the dag G = (V, E) is the transitive dag with E c E+ and
IEl is minimum. An edge < ij> of the dag G is redundant iff there is an i to j path in G that
does not include . A dag is minimal iff it contains no redundant edges. The transitive
reduction, G = (V, E) of the dag G = (V, E) is the minimal dag that has the same transitive clo
sure as G and such that E c E.
The class of minimal series parallel dags (MSPDAGs) is defined recursively as below:
1. If l0 = 1 and IE = 0, then G is an MSPDAG
2. If G, = (V1, E1) and G2 = (V2, E2) are MSPDAGs, then their parallel composition Gi//G2 = (V
u V2, El u E2) (Figure 3 (a)) is an MSPDAG.
3. If G, and G2 are as above, then their series composition GIG2 = (V 2 u V2, E u E2 u E3)
where E3 = {< ij> I i V, dout(i) = 0, j e V2, d n(j) = 0 }, dout(i) and d'n(j) are, respec
tively, the out and in degrees of vertex i (Figure 3(b)) is an MSPDAG.
Finally, a GSPDAG is a dag whose transitive reduction is an MSPDAG. The dag of Figure 4 is a
GSPDAG as its transitive reduction is the MSPDAG of Figure 3(b). It is interesting to note that
every dag which is a tree is an MSPDAG. However the only dag trees that are SPDAGs are
chains.
G, G2
(a) G1//G2
Figure 3: Parallel and series combination of G1 and G2.
Figure 4: An example GSPDAG.
The following lemma shows that the DVUP solutions for a GSPDAG G and for its transi
tive reduction MSPDAG G are the same.
Lemma 3: Let G = (V, E) be a GSPDAG and let G = (V, E) be its transitive reduction (hence
G is an MSPDAG). LetX be a subset of V. Then, d(G K) < 6 iffd(GC ) < 6.
Proof: If d(G X) < 6 then d(GCX) 6 as E c E. If d(G[X) > then there is a path P = vv2 ... Vq
in G such that its delay in GKX is A = I d(v,) and A > 6. From the v, to vq path P of G we
1 < < n,v,EX
can construct a vi to v, path Q in G by replacing each edge < v,,v+,,> V E by a path from v, to
v,,, in G. Since G is the transitive reduction of G, such a path exists. When all edges < v,,v,+1>
(b) G1G2
SE have been so replaced, we obtain the desired path Q. Clearly, the delay of Q is 2 A. Hence,
if d(G[Y) > 6 then d(GY) > 6. This completes the proof. D
As a consequence of Lemma 3 the DVUP for GSPDAGs can be solved using the steps:
Stepi: Compute G, the transitive reduction of the GSPDAG G.
Step2: Let X be the minimum weight vertex subset such that d(G~X) < 6.
Step3: OutputX.
Since the transitive reduction of a GSPDAG G can be obtained in time linear in the number
of vertices and edges in G [VALD79], we need be concerned only with step 2. Our strategy for
this is similar to that used in Section 3 for SPDAGs. However, since the source and sink vertices
of G, and G2 remain distinct following a series or parallel combination, we can deal with tuples
(1, c) rather than with triples (1, c, Y). Corresponding to D(1 ,Y ,G) of SPDAGs, we define D(1 ,G)
for an MSPDAG G to be a minimum weight vertex set for which d(GX[) 1. We use the series
parallel decomposition of G and begin with the non dominated tuple sets F(G) for each of the
vertices in G. Then using the series and parallel combinations that result in G we obtain F(G).
4.1. G Is A Single Vertex
If G is the single vertex v, then F(G) = { (0, w(v)) } when d(v) > 6 and { (0, w(v)), (d(v), 0) }
when d(v) < 6.
4.2. G Is Of The Form GiG2
The following lemma is the analogue of Lemma 1.
Lemma 4: If(l, c) e F(G1G2), then there is an (1i ,c) e F(Gi) and an (12 ,C2) e F(G2) such that
(a) D(l1 ,G1) =D(1,G1G2) r V(G,)
(b) D(12 ,G2) = D(1,G1G2) n V(G2)
(c) D(1,G1G2) =D(1 ,G) U D(12,G2)
(d) c = I W(u), c1 = I W(u), c2 = W(u).
u e D(I,Y,GIG2) u e D(I1,YI,GI) u e D(12,Y2,G2)
Proof: Similar to that of Lemma 1. D
For the case of MSPDAGs, all pairs (li ,cl) e F(GI) and (12 ,c2) E F(G2) are compatible pairs
for combination. The pair (1 ,c) that results from combining these two pairs is (1+12 ,c1+c2). This
is added to Z (see step 1 of the procedure for G1G2 in Section 3.2) provided 1+1/2 6.
4.3. G = G//G2
The analogue of Lemma 2 that applies to MSPDAGs is given below.
Lemma 5: If(l, c) e F(G1/G2), then there is an (1i ,c) e F(G1) and an (2 ,c2) e F(G2) such that
(a) D(1 ,G,) =D(l,G1G2) r V(G,)
(b) D(12 ,G2) = D(1,G1G2) n V(G2)
(c) D(1,G1G2) =D(1 ,G) u D(12 ,G2)
(d) c = W(U), C1 = I W(u), C2 = W(M).
u e D(1,Y,GIG2) u e D(1,Y,,GI) u e D(12,Y2,G2)
Proof: Similar to that of Lemma 1. D
Once again, all pairs (l1 ,cl) e F(G1) and (2 ,c2) E F(G2) are compatible pairs for combina
tion. The result of combining these two pairs is the pair (1 ,c) = (max {l1,12, c1+c2 ).
4.4. Complexity
While the algorithm for MSPDAGs is simpler than that for SPDAGs, its asymptotic complexity
is the same. Note that for trees with unit weight and/or unit delay the complexity is O(n2) which
is asymptotically the same as the algorithm of Section 2.2 for unit weight or unit delay trees but
inferior to the algorithm of Section 2.1 for unit weight and unit delay trees.
5. Conclusions
We have obtained pseudo polynomial time algorithms for DVUP for trees, seriesparallel dags,
and general seriesparallel dags. These algorithms have quadratic complexity when all vertices
either have unit delay or unit weight. For 6 = O(n), the complexity is O(nS). For the case of trees
with unit weights and unit delays we have developed a linear time algorithm.
6. References
[HOR078] E. Horowitz, and S. Sahni, "Fundamentals of Computer Algorithms", Computer
Science Press, Maryland, 1978.
[LAWL78] E. L. Lawler, "Sequencing Jobs To Minimize Total Weighted Completion Time
subject to precedence constraints", Annals ofDiscrete Math. 2, 1978, 7590.
[MONM77] C. L. Monma and J. B. Sidney, "A General Algorithm For Optimal Job Sequenc
ing With SeriesParallel Constraints", Technical Report No. 347, School of Opera
tions Research and Industrial Engineering, Cornell University, Ithaca, N.Y., July
1977.
[PAIK90] D. Paik, S. Reddy, and S. Sahni, "Vertex Splitting In Dags And Applications To
Partial Scan Designs And Lossy Circuits", University of Florida, Technical
Report, 9034,1990.
[PAIK91a] D. Paik, S. Reddy, and S. Sahni, "Deleting Verticies To Bound Path Lengths",
University of Florida, Technical Report, 914, 1990.
[PAIK91b] D. Paik, and S. Sahni, "Upgrading Circuit Modules To Improve Performance",
University of Florida, Technical Report, 1991.
[SIDN76] J. B. Sidney, "The Two Machine Flow Line Problem With SeriesParallel Pre
cedence Relations", Working paper 7619, Faculty of Management Science,
University of Ottawa, November 1976.
[VALD79] J. Valders, R. E. Tarjan, and E. L. Lawler, "The recognition of Series Parallel
digraphs", SIAMJ Comput., 11 (1982), pp. 298313.
