Computer Science Technical Reports Computer Science
10-13-1994 Optimal Parametric Search on Graphs of Bounded Tree-Width David Fernández-Baca Iowa State University, [email protected]
Giora Slutzki Iowa State University, [email protected]
Follow this and additional works at: http://lib.dr.iastate.edu/cs_techreports Part of the Theory and Algorithms Commons
Recommended Citation Fernández-Baca, David and Slutzki, Giora, "Optimal Parametric Search on Graphs of Bounded Tree-Width" (1994). Computer Science Technical Reports. 89. http://lib.dr.iastate.edu/cs_techreports/89
This Article is brought to you for free and open access by the Computer Science at Iowa State University Digital Repository. It has been accepted for inclusion in Computer Science Technical Reports by an authorized administrator of Iowa State University Digital Repository. For more information, please contact [email protected]. Optimal Parametric Search on Graphs of Bounded Tree-Width
Abstract We give linear-time algorithms for a class of parametric search problems on weighted graphs of bounded tree- width. We also discuss the implications of our results to approximate parametric search on planar graphs.
Disciplines Theory and Algorithms
This article is available at Iowa State University Digital Repository: http://lib.dr.iastate.edu/cs_techreports/89
Optimal Parametric Search on Graphs of
Bounded Tree-width
y
David Fernandez-Baca and Giora Slutzki
Department of Computer Science, Iowa State University, Ames, IA 50011
Octob er 13, 1994
Abstract
We give linear-time algorithms for a class of parametric search
problems on weighted graphs of b ounded tree-width. We also discuss
the implications of our results to approximate parametric search on
planar graphs.
1 Intro duction
Parametric search has b een the center of a considerable amount of research
in recent times due to its numerous applications to optimization and com-
putational geometry [CoMe93 , Tol93, CEGS92, MaSc93]. Much of this work
stems from two fundamental pap ers by Megiddo [Meg79, Meg83], where he
intro duced a powerful to ol for parametric search. In the context of opti-
mization problems, the application of Megiddo's technique tends to followa
common pattern. Supp ose we have an algorithm A that allows us to deter-
mine the value of a certain function f for any within a certain range, and
that we wish to lo cate a critical value for f whose nature dep ends on the
A preliminary version of this pap er app ears in the pro ceedings of the 4th Scandinavian
ConferenceonAlgorithm Theory, Aarhus, Denmark, 1994.
y
Supp orted in part by the National Science Foundation under grant No. CCR-8909626
and grant No. CCR-211262. 1
application. Megiddo argued that we can pro ceed by simulating the execu-
tion of A to determine its computation path at . To do so, the op erations
of A are executed symb olically, manipulating functions of instead of num-
b ers. At branching p oints of A commonly asso ciated with comparisons,
decisions ab out the path to follow are made by invoking an oracle, which is
often closely related to algorithm A. Oracle calls are exp ensive; therefore,
they must be used sparingly. Megiddo showed that if these op erations can
be batched i.e., group ed and ordered in such a way as to p ermit many of
them to be resolved by a single oracle call, the total amount of work to
solve the parametric problem can often be made at most a p olylogarithmic
factor slower than that of algorithm A. The p olylogarithmic slowdown in go-
ing from non-parametric to parametric algorithms remains even when using
Cole's clever technique [Cole87].
In this pap er, we show that the ab ove-mentioned slowdown can be com-
pletely avoided for certain parametric optimum subgraph problems. In the
non-parametric versions of these problems, one is givenavertex- and/or edge-
weighted graph and is asked to nd the \b est" subgraph that satis es a sp eci-
ed prop erty. Problems of this kind include maximum cut, minimum-weight
dominating set, minimum-weight vertex cover, and the traveling salesman
problem. All of these problems, and many others, are known to be regular
for graphs of b ounded tree-width, implying that they can be solved in op-
timal linear time on such graphs using well-known dynamic programming
techniques [BLW87, BPT92 ]. In parametric optimum subgraph problems,
weights are assumed to be continuous functions of a parameter . The cost
of the optimum solution is describ ed by a real-valued function Z that
G
sub divides the -axis into a sequence of intervals, where each interval is a
maximal connected set of -values for which a particular subgraph is opti-
mal [FeSl94]. The b oundary p oints between intervals are called breakpoints.
Three typ es of search problems will concern us:
P1 Given a value nd the rst breakp oint such that .
1 1
P2 Find a value such that Z = 0. We assume that such a
G
exists.
P3 Find such that Z = max Z or such that Z =
G G G
min Z .
G
2
Problem P1 arises in sensitivity analysis [Gus83], P2 arises in minimum-
ratio optimization [Meg79], and P3 arises in Lagrangian relaxation [Fis81].
We shall show that, assuming the underlying non-parametric problem is reg-
ular, P3 can be solved in linear time if weights are concave xed-degree
p olynomial functions, and P1 and P2 can be solved in linear time if
weights are linear. These algorithms are optimal, to within a constant fac-
tor, since their run times match those of their non-parametric versions.
Our work has b een motivated by that of Frederickson [Fre90], who showed
that a number of lo cation problems on trees can be solved in optimal lin-
ear time by a novel application of parametric search. We b orrow several of
Frederickson's ideas here, including rep eated graph contraction, accompa-
nied by a rapid narrowing of the search interval, and the use of not one, but
a sequence of increasingly faster oracles. We also intro duce an idea that we
have shown to have applications outside of the context of b ounded tree-width
graphs [FeSl94a]. The basis of this technique is the observation that all our
search problems can be solved quickly if we have constructed Z over some
G
interval I containing . Let A be the standard optimum subgraph algo-
rithm see Section 4 and [ALS91, BLW87, BPT92]. Algorithm A is easily
adapted to evaluate Z for any xed ; moreover, Z can b e constructed
G G
by simulating the b ehavior of A for al l p ossible values of in a pro cess that
is called lifting see Section 4. Our search metho d involves rearranging A's
computation into a sequence of phases, an op eration that relies heavily on a
linear-time algorithm for constructing parse trees satisfying an appropriate
balance condition see Section 2. This rearrangement allows the simulation
of A to be conducted by alternating lifting and \narrowing" steps. During
a lifting step, the algorithm is simulated to determine all the computation
paths it will followover an interval I . This will set the stage for a narrowing
of the searchinterval, and the construction of a faster oracle, which will make
the next phase faster than the current one. At the end of the simulation, we
will have a complete description of Z over an interval I containing ; we
G
end the search by lo oking for in this description.
Our results also lead to O n-time approximation algorithms for several
NP-hard parametric search problems on planar graphs. The pro of of this fact
yields some observations on the structure of functions describing the cost of
approximate solutions to parametric problems on planar graphs. 3
Organization of the pap er. Section 2 presents a linear-time algorithm
to construct balanced parse trees of b ounded tree-width graphs. It also de-
scrib es a strategy for identifying certain sets of no des in a balanced parse
tree. These sets will be used to organize the evaluation of the cost of an
optimum subgraph in the non-parametric setting in a manner to be dis-
cussed in Section 3. A parametric search algorithm based on this evaluation
algorithm is presented in Section 4. Section 5 discusses the application of
this algorithm to approximate parametric search in planar graphs, and gives
some nal comments.
2 Constructing Balanced Parse Trees
Our parametric search algorithm requires the construction of a balanced parse
tree of the input graph. Here we formalize this notion and show how such
a parse tree can be constructed in linear time. We also describ e a linear-
time algorithm to identify certain sets of no des in the tree called levels.
These sets shall b e used to organize the computation of optimum subgraphs,
and the search for . We rst review the closely-related notions of tree
decomp ositions and parse trees.
A tree decomposition of an undirected graph G is a lab eled tree T; X,
where X is the lab eling function for T , such that for all i 2 V T , X i =
S
X = V G; 2 for every u; v 2 X V G, and such that: 1
i i
i2V T
E G, fv; ug X for some i 2 V T ; 3 if j lies on the path of T from i
i
to k , then X \ X X . The width of T; X is max jX j 1. The
i k j i
i2V T
tree-width of a graph G is the minimum over all tree decomp ositions T; X
of G of the width of T; X.
We write to denote the set of all graphs of tree-width at most w .
w
Classes of graphs of b ounded tree-width have b een surveyed by Bo dlaender
[Bo d88] and van Leeuwen [vLe90]. Bo dlaender [Bo d93] has shown that the
problem of determining whether a graph has tree-width at most w and, if
so, constructing a tree decomp osition of width at most w , can be solved in
linear time for every xed w .
A graph G is a k -terminal graph if it is given together with a list termsG=
ht ;:::;t i,1 s k , of distinct vertices of G called terminals. A k -terminal
1 s
composition operator ' of arity r 0 joins r k -terminal graphs G ;:::;G
1 r
to obtain a new k -terminal graph G = 'G ;:::;G by identifying the
1 r 4
terminals of the comp osing graphs in some precisely prescrib ed way. The
terminals of G are obtained from the terminals of the comp osing graphs
[Wim87, BPT92 ]. We shall write U [k; r] to denote the set of all k -terminal
graph comp osition op erators ' of arity at most r , and where, for each ' of
arity zero, jV 'j k . Note that for every xed k and r , jU [k; r]j is b ounded
by a constant.
Let R U[k; r]. Denote by R the subset of R consisting of all op erators
0
of arity0. R is a set of k -terminal graphs whose elements are called primitive
0
graphs. We write R to denote the set of all k -terminal graphs G such
that either G 2 R or G can be expressed as G = 'G ;:::;G for some
0 1 r
op erator ' 2 R and some set of graphs G ;:::;G 2 R . The equality
1 r
G = 'G ;:::;G is called a decomposition of G with respect to R.
1 r
A parse tree T for G 2 R is a lab eled tree constructed as follows. If
G 2 R , T consists of a single no de v with lab el v = G. Otherwise,
0
let G = 'G ;:::;G be decomp osition of G with resp ect to R . Then T
1 r
consists of a ro ot v , with lab el v = ', and subtrees that are parse trees
of G ;:::;G . For any no de v 2 T , we write T to denote the subtree of
1 r v
T ro oted at v . This subtree represents a graph G 2 R , such that 1
v
G = v , if v is a leaf, or 2 G = v G ;:::;G , if the children of v
v v v v
r
1
are v ;:::;v .
1 r
It is well known see, e.g., [Wim87] that graphs of constant-b ounded tree-
width can be expressed as the comp osition of graphs with b ounded number
of terminals according to some nite set of rules. More precisely, there exists
a set of op erators R U [w +1; 2] such that R = . While tree decom-
w
p ositions and parse trees are essentially equivalent concepts, the latter seem
more convenient from a computational p oint of view.
2.1 The decomp osition algorithm
We shall say that a decomp osition G = 'G ;:::;G with resp ect to R
1 r
is -balanced if jV G j jV Gj, for some constant that dep ends only
i
on R. A parse tree T of an n-vertex graph G is said to be -balanced if
for every internal no de v of T with children v ;:::;v , the decomp osition
1 r
G = v G ;:::;G is -balanced. The height of an -balanced parse
v v v
r
1
0
tree T is clearly O log n. It is known that there exists a subset R U[4w +
0
4; 5] such that every G 2 has a O log n-height parse tree over R see
w
[Lag90, FeSl94]; a similar result was indep endently proved by Frederickson 5
[Fre93].
Supp ose wehave a pro cedure Decompose, whose details will b e supplied
shortly, which obtains a 7=8-balanced decomp osition with resp ect to U [5w +
5; 3] of any5w + 5-terminal graph of tree-width w . To obtain a 7/8-balanced
parse tree T of G,we do as follows: If jV Gj 5w +5, G is a primitive graph
whose parse tree consists of a single no de; otherwise, apply Decompose to G
to obtain a 7=8-balanced decomp osition G = 'G ;:::;G , lab el the ro ot of
1 r
T with ', and recurse on the G 's. We will argue that, at the exp ense of a one-
i
time-only linear-time prepro cessing step, Decompose can be implemented
to run in O log n time. Thus, the total work required to construct the
decomp osition, aside from prepro cessing, will b e describ ed by the recurrence
P P
q q
T n T n +b log n, for some constant b, where 1 q 3, n =
i i
i=1 i=1
n and n 7n=8. It can readily b e shown that T n=O n; hence, the total
i
time for building the parse tree will be linear.
2.2 Implementation of Decompose
Decompose is closely patterned after a pro cedure that Lagergren [Lag90]
used to construct tree decomp ositions of graphs. Like Lagergren's metho d
and like a similar algorithm by Reed [Ree92 ], it relies on the familiar notion
of a separator. Let A; B ; S V G. Set S separates A and B if every path
from A to B go es through S . Given a subset Q V G and a real number ,
S V G is said to b e an -Q-separator if there exists a partition A ;A ;S
1 2
of V G such that S separates A and B and jA \ Qj jQj, i = 1; 2. If
i
Q = V G, S will be referred to simply as an -separator.
Pro cedure Decompose requires that the input graph G be a 5w + 5-
terminal graph of tree-width at most w . In what follows, termsG will
denote the sequence of terminal vertices of G,as well as the unordered set
of terminal vertices. In the description of Decompose, we assume that we
are in p ossession of pro cedures that can compute 7/8-separators of size at
most w + 1 and 2/3-Q-separators of size at most w + 1; these pro cedures will
be discussed later. The existence of the desired separators is guaranteed by
results of Rob ertson and Seymour [RoSe86].
DecomposeG
Step 1. Find a 7/8-separator S of G and the asso ciated partition A ;A ;S
1 1 2 1
of V G. For i =1; 2, let G = G[A [ S ] and let termsG consist of
i i 1 i 6
S [ termsG \ A , in any order. Assume w.l.o.g. that jtermsG j
1 i 1
jtermsG j.
2
Step 2. If jtermsG j 5w +5, return the decomp osition G = 'G ;G ,
1 1 2
for the appropriate ' 2U[5w +5; 3].
Step 3. If jtermsG j > 5w +5, nd a 2/3-Q-separator S of G , where
1 2 1
Q = termsG , and the asso ciated partition B ;B ;S ofV G . For
1 1 2 2 1
i =1; 2, let H = G[B [ S ] and let termsH consist of S [ termsG \
i i 2 i 2 1
B , in any order. Return the decomp osition G = 'H ;H ;G , for
i 1 2 2
the appropriate ' 2U[5w +5; 3].
To verify the correctness of Decompose, it is sucient to prove that
in b oth step 2 and step 3, the graphs into which G is decomp osed have
at most 5w +5 terminals. This is trivially true for step 2. Now examine
the decomp osition returned in step 3. For i = 1; 2, jtermsH j jS j +
i 2
2jtermsG j=3. Since termsG jjS j + jtermsG j 6w +6, jtermsH j
1 1 1 i
5w + 5, for i =1; 2. Note also that jtermsG j jtermsGj jtermsG j +
2 1
2jS j;thus, jtermsG j 2w +2.
1 2
The most time-consuming steps of Decompose are the separator com-
putations in Steps 1 and 3. We shall next discuss how to implement these
computations in O log n time, at the exp ense of a one-time-only linear-time
prepro cessing step.
Prepro cessing. Separator computations rely on the maintenance of good
tree decomp ositions for all fragments of the graph, along with some informa-
tion ab out terminal vertices in the form of a data structure that we shall call
a skeleton. A go o d tree decomp osition of a graph G 2 is a decomp osition
w
T; X such that:
C1 T is a ro oted binary tree.
C2 jX j = w + 1 for every i 2 V T .
i
C3 jX \ X j is either w or w + 1 for every i; j 2 E T .
i j
C4 For every internal no de i 2 V T , i has at least one child j such that
X 6= X .
i j 7 X i
X i X X i j4 X X X X j1 j j3 j4 2 X X i j3
X X j
j1 2
Figure 1: Making a tree decomp osition binary.
The prepro cessing phase starts with the construction of a good decom-
p osition for the input graph G. This can be done in linear time as follows.
First, use Bo dlaender's linear-time algorithm [Bo d93] to obtain a tree de-
comp osition of width w of G. Without loss of generality, we can assume
that for any two adjacent no des i and j in this decomp osition, X 6 X
i j
and X 6 X if the given tree decomp osition do es not satisfy this condi-
j i
tion, we can transform it into one that do es by rep eatedly contracting edges
i; j with X X . Pick any no de i with jX j = w +1 as the ro ot. Now
j i i
traverse the tree decomp osition in preorder. When a no de i which will
have jX j = w +1 is visited, consider each child j and do the following.
i
If jX j < w +1, replace X by X [ A, where A is any subset of X X
j j j i j
having cardinality w +1 jX j. After we are done, every no de i of the
j
resulting tree decomp osition will have jX j = w + 1 and for anytwo adjacent
i
no des i and j , jX \ X j w . The next step of the transformation is to
i j
consider each pair of adjacent no des i and j . If jX \ X j i j edge i; j by the path i; i ; i ;i ;:::;i ;j, where k = jX X j. The 1 1 2 k 1 i j corresp onding sets X ;:::;X are de ned as follows. Let Y = X \ X , i i i j 1 k 1 let X X = fa ;:::;a g, and let X X = fb ;:::;b g. Then, for i j 1 k j i 1 k r = 1;:::;k 1, X = Y [fb ;:::;b ;a ;:::;a g. In the nal step, the i 1 r r +1 k r resulting tree decomp osition is made binary by applying the transformation illustrated in Figure 1 to every no de having more than two children. All 8 steps in this pro cedure can be implemented to run in linear time. It is easy to check that the nal result satis es C1{C4. Go o d tree decomp ositions will b e represented using Sleator and Tarjan's dynamic trees with partitioning by size [SlTa83]. Such a representation can be built in O n time [GoTa91]. Several useful op erations can be done in logarithmic time on dynamic trees, among them cutting and linking trees and computing least common ancestors lca's of pairs of no des [SlTa83]. These prop erties will allow us to take a good decomp osition of a graph and extract eciently from it good tree decomp ositions for fragments resulting from separations. A skeleton for the vertices in Q = termsG is a tree T constructed Q as follows. Cho ose any mapping f : Q ! V T such that for all v 2 Q, v 2 X . Let L denote the range of f . A tree T for L is de ned recursively f v L as follows. If L = ;, T is empty. Otherwise, let r be the lca in T of the L no des in L. Let T and T be the subtrees of T ro oted at the children of 1 2 r , and let L = L \ V T , i = 1; 2. Then T has r as its ro ot and as its i i L subtrees it has the trees T and T for L and L , resp ectively. Finally, L L 1 2 1 2 make T = T . See Figure 2. Each vertex i 2 V T will have a weight Q L Q q equal to the number of vertices of Q mapp ed to it by f . Note that, since i jQj = O w , jV T j = O w . A skeleton can be computed using O w lca Q queries on T in O w log n time. Finding vertex separators. We shall show that a 7=8-vertex separator of G, such as the one required in Step 1 of Decompose, can be obtained by lo cating a centroid edge in a good tree decomp osition of G. A centroid edge e in a tree T is an edge such that every subtree in T e has at most 3jV T j=4 vertices | such an edge always exists in a binary tree [CLR90]. We b egin by proving some prop erties of good tree decomp ositions. In what follows, when no confusion can arise, a tree decomp osition of a graph shall sometimes be referred to by mentioning only the underlying tree e.g., we refer to T; X as just T . Given any i 2 V T , we shall write T to denote i the subtree of T ro oted at i and shall write G to denote the subgraph of G i S induced by fX : j 2 V T g. Clearly, T is a tree decomp osition of G . j i i i Lemma 2.1 Let T; X be a good tree decomposition of G 2 . For any w i 2 V T , T is a good tree decomposition of G . i i 9 1 2 3 2 4 5 4 5 6 7 8 9 61112 10 11 12 T TQ Figure 2: A tree decomp osition and its skeleton. No des in the range of f are shaded. Pro of. Follows from the de nition of go o d tree decomp ositions. 2 Lemma 2.2 Let T; X be a good tree decomposition of G 2 . If n = w jV Gj and k = jV T j, then n w k 2n w 1. Pro of. Let d b e the numb er of distinct X 's in T . One can showby an easy j induction on d that d = n w . It now suces to show that d k 2d 1. The rst inequality is trivially true. The second one can b e proved by induc- tion on k . The base case k = 1 is immediate. Supp ose k>1 and let i b e the ro ot of T . If i has only one child j , then X 6= X , by C4. By Lemma 2.1, i j T is a go o d tree decomp osition of G and it must satisfy k 2d 1, where j j j j k = jV T j and d is the number of distinct X 's in T . Since d = d +1 j j j r j j and k = k +1,we have k 2d 1. Now supp ose i has two children j and j 1 j . For r =1; 2, let k = jV T j and n = jV G j. Then, k = k + k +1 2 r j r j 1 2 r r and, by C4, d d + d . The desired result follows since, by induction 1 2 hyp othesis, k 2d 1 for r =1; 2. 2 r r 10 Lemma 2.3 Let T; X be a good tree decomposition of an n-vertex graph 0 00 G. Suppose e =i; j is a centroid edge in T , and let T and T be the two S S 0 0 00 subtrees of T e, with G = G[ fX : l 2 V T g] and G = G[ fX : l 2 l l 00 0 00 V T g]. Then, jV G j; jV G j n=8. Furthermore, S = X \ X separates i j 0 00 V G from V G . Pro of: The fact that S is a separator follows from basic prop erties of tree decomp ositions see, e.g., [RoSe86]. 0 0 0 0 00 00 00 Let k = jV T j, k = jV T j, n = jV G j, k = jV T j, and n = 00 0 jV G j. Assume that i is the parentofj in T and that T contains j . Then, 0 0 by Lemma 2.1, T is a good tree decomp osition of G and, therefore, by 0 0 0 Lemma 2.2, n w k 2n w 1. Using Lemma 2.2 and the fact that 0 e is a centroid edge, we get the following relation for T : 0 0 n w =4 k=4 k 2n w 1: 0 00 It follows that n n=8. The pro of that n n=8 is similar, and relies on 00 00 00 00 the fact that n w k 2n w , which holds b ecause T is a go o d tree 00 decomp osition of G , except for the p ossibility that it might violate C4 at i i.e., X might equal X , where l is the sibling of j . We leave the details i l to the reader. 2 Go o drich and Tamassia have proved that a dynamic tree representation allows one to lo cate a centroid edge in a binary tree in O log n time [GoTa91]. In combination with Lemma 2.3, this yields a O log n algorithm to nd a 7=8-separator in G. This do es not, however, complete the description of the vertex separator pro cedure, since we still need to obtain go o d decomp ositions and skeletons for the fragments. Let us use the notation of Lemma 2.3. As 0 0 argued in the pro of of that lemma, T is a good decomp osition of G ; to 0 extract T we simply cut it from T , which takes O log n time on dynamic 00 trees. On the other hand, T mayormay not be good. If it is, nothing b eyond cutting it from T will b e needed. If it isn't, the only p ossible violation is that 00 no de i has only one child l and X = X . We can convert T into a good i l tree decomp osition by contracting the edge i; l . This can be achieved in O log n time by O 1 cut and link op erations. 0 00 Skeletons for G and G can also b e obtained in logarithmic time. We limit 0 00 ourselves to describing the algorithm for G , as the one for G is analogous. 11 0 0 0 0 Observe that termsG = Q [ N , where Q = Q \ V G and N = X \ i 0 X termsGN consists of the new terminal vertices of G created by the j separation. Recall that the skeleton for G is based on a function f mapping vertices in termsG to vertices of T ; we shall establish a similar mapping 0 0 0 0 0 f : termsG ! V T as follows. Let P be the vertices of Q that are 0 0 0 mapp ed to no des in T by f . For every m 2 P , make f m = f m. By 0 0 de nition of tree decomp ositions, every vertex of Q P must b e present in 0 0 0 X ;thus, we make f m=j for all m 2 Q P . Every m 2 N is contained j 0 0 in X ; thus, for any such m, we make f m=j . After f is established, we j 0 0 compute askeleton for G in O w log n time with O w lca queries on T . Finding set separators. A Q-separator in G is lo cated by nding a cen- troid vertex c in the skeleton T ; i.e., a vertex c whose removal leaves no Q P subtree having total weight exceeding q =2 suchavertex can eas- i i2V T Q ily be shown to exist in any no de-weighted tree. We rely on the following result. Lemma 2.4 Let G 2 , let Q = termsG , and let T beagoodtree decom- w position of G. Then, if T is a skeleton of G and c is a centroid of T , X Q Q c is a 2=3-Q-separator of G. Pro of. Let R , R , R be the comp onents of T c, and let S , S , S be 1 2 3 Q 1 2 3 the comp onents of T c we assume for simplicity that each of T c and Q T c have exactly three comp onents | there may actually b e fewer, but this is easily handled. By the de nition of T , for l =1; 2; 3, there exists some Q 0 0 m such that V R V S , and V R \ V S = ; for m 6= m. W.l.o.g., l m l m assume that V R V S . l l S fX : r 2 V S g X . Then, B ;B ;B ;X For l =1; 2; 3, let B = r l c 1 2 3 c l is a partition of V G such that X separates every pair of distinct B 's. We c l will show that jB \ QjQ=2. Let W b e the weightofR . Then, W equals l l l l the number of vertices v 2 Q such that f v 2 V S , where f is the mapping l asso ciated with T . By the de nition of tree-decomp ositions, if v 2 Q \ X , Q r r 2 V S , but f v 2 V S , m 6= l , then v 2 X . Therefore, jB \ Qj W . l m c l l P Since c is a centroid no de and fq : i 2 V T g = jQj, i Q jB \ QjW jQj=2: l l 12 Assume w.l.o.g. that B is the largest B . Let A = B and A = B [ B . 1 l 1 1 2 2 3 One can easily show that A ;A ;X is a partition of V G such that X 1 2 c c separates A and A and jA \ Qj 2jQj=3. The lemma follows. 2 1 2 l The vertex c of Lemma 2.4 can b e found in O w , as this is the size of T . Q It will be necessary to identify the two graphs resulting from the separation and to construct good tree decomp ositions and skeletons for each. Let us follow the notation used in Lemma 2.4. The two graphs that concern us are given by G = G[A [ X ], l = 1; 2. Clearly, tree decomp ositions for l l c G and G will be given by the subtrees of T induced by V S [fcg and 1 2 1 V S [ V S [fcg. These decomp ositions may or may not be good; if 2 3 they aren't, they can be repaired in O log n time with O 1 cut and link op erations in a manner similar to that for vertex separators. Skeletons for G and G can also be built in logarithmic time. The details are similar to 1 2 those for vertex separators and are therefore omitted. 2.3 Identifying levels in a parse tree Let T be a 7/8-balanced parse tree of an n-vertex graph G 2 and let w r < r < < r be a sequence of numb ers where r = w and r = n. 0 2 k 0 k We shall use these numb ers to identify k + 1 subsets of V T having certain sp ecial prop erties. To do so, we rely on a pro cedure Mark-Tree that takes as inputs the ro ot v of a balanced parse tree T and a number r jV Gj. Mark-Tree is straightforward: If jV G j r , it marks v . Otherwise, v Mark-Tree is applied recursively to each child u of v . Lemma 2.5 Let L be the set of nodes in T markedby Mark-Tree. Then, i jLj =n=r , ii for every u; v 2 L, u 6= v , V T \ V T =;, and iii u v every leaf of T is a leaf of T , for some u 2 L. Moreover, assuming jV G j u u is known for every node u in the tree, Mark-Tree takes O n=r time. Pro of. Prop erties ii and iii follow directly from the description of Mark- Tree. The pro of of prop erty i relies on a straightforward argument based on the fact that T is balanced. We omit the details. The time b ound follows from the fact that Mark-Tree traverses O n=r no des of T and pro cessing each no de takes O 1 time. 2 13 Lk v Lj Tv' Lj -1 L0 Figure 3: Dividing a parse tree into levels. The pro cedure to identify levels is as follows. Declare the ro ot v of T to be a level k no de. Now, for j = k; k 1;:::;2, do the following. For each level j no de u, apply Mark-Treeu; r and declare the newly marked j 1 no des to be level j 1 no des. Finally, declare the leaves of T to be level 0 no des. See Figure 3. For j =0;:::;k, let L denote the set of level j no des. j We shall say that a no de v 2 T lies ab ove level j ,0 j k ,ifv is a prop er ancestor of some level j no de. Lemma 2.5 and the fact that one can compute jV G j for every u 2 V T in O n time imply that identifying L ;:::;L u 0 k takes O n time. The following lemma states prop erties of levels that will b e used later. 14 Lemma 2.6 For 0 j k , jL j = n=r . Moreover, let v be a level j j j 0 node, 0 < j k and let T be the subtree of T containing al l nodes at or v v 0 above level j 1 see Figure 3. Then T has O r =r nodes and height j j 1 v O logr =r . j j 1 Pro of. The b ound on jL j follows from Lemma 2.5. This lemma also im- j plies that T has O r =r level j 1 no des, from which we can conclude v j j 1 0 0 that jV T j = O r =r . The height b ound on T follows from the fact j j 1 v v that T is 7=8-balanced. 2 3 The Non-Parametric Algorithm In the rst part of this section, we summarize the well-known linear-time dynamic programming algorithm for nding the weight of the optimum sub- graph satisfying a regular prop erty in a graph of b ounded tree-width. From the p oint of view of the search for , it will be useful to view this algo- rithm's computation as if it were hard-wired in the form of a circuit. It will also be useful to organize the evaluation of this circuit using levels. The circuit approach and the use of levels are discussed in the last two parts of this section. 3.1 Regular prop erties and dynamic programming We caution the reader that what follows is not a rigorous treatment of regular graph prop erties. Our fo cus is limited to only those characteristics of the metho d that are essential to understanding the parametric algorithm. Full discussions of regularity can be found elsewhere [ALS91, BPT92, BLW87, FeSl94]. Let R b e a set of comp osition op erators; we shall b e primarily interested in sets R such that R = , for some w . A graph-subgraph pair is a pair w G; H where G is a graph and H is a subgraph of G; the cost of G; H is the sum of the weights of the vertices and edges in H . The comp osition op erators of R are extended to graph-subgraph pairs in the natural way: the underlying graphs are comp osed and the subgraphs are unioned mo d- ulo vertex identi cation [BLW87]. A predicate P on graph-subgraph pairs is regular with resp ect to a set R of comp osition op erators if it induces a 15 partition of the set of graph-subgraph pairs G; H with G 2R into a nite number of equivalence classes such that the following prop erties hold. 1. For any class C and anytwo pairs D ;D 2 C , D and D either b oth 1 2 1 2 satisfy or b oth fail to satisfy the predicate P . Classes where every pair satis es P are called accepting. 2. The comp osition op erators on pairs resp ect equivalence classes. That is, the equivalence class containing the comp osition of pairs D ;:::;D 1 l dep ends only on the comp osition op erator and on the equivalence classes containing the pairs. By 2, for each comp osition op erator ' there is a nite set of rules that express the p ossible equivalence classes in which the comp osition of graph- subgraph pairs may fall, dep ending on the classes from which these pairs originate. These rules can be put in tables that are xed for each op erator and each problem. Let G 2 R , let T be a b ounded-degree linear-size parse tree of G, and let v 2 V T . Let C = fC ;:::;C g be the set of equivalence classes with 1 N i resp ect to some regular prop erty P . For i =1;:::;N,we write z to denote v the value of the optimum pair G ;H 2 C . To compute z , the cost of the v i G optimum solution, pro cess the no des of T from the b ottom up, computing i z for every v 2 V T and every class C . If v is a leaf, and hence G is a i v v i primitive graph, then compute all the z 's by exhaustiveenumeration. This v takes constant time, since there are only a constantnumb er of pairs G ;H v in each class. Otherwise, for each equivalence class C ,wehave tables giving i a nite number of ways in which a pair G ;H 2 C can be expressed as v i 0 a combination of pairs of the form G ;H 2 C where u is a child of v . u k k If we know the z 's, we can combine this information in constant time via u i additions and comparisons to obtain z [BLW87, BPT92]. After every no de v in the parse tree has b een pro cessed, we can compute the cost z of the G optimum solution in O 1 time by using n o i z = min f+1g [ fz : C is an accepting class g : 1 G i G Thus, we have a linear-time algorithm to evaluate z . G 16 3.2 A circuit for computing z G A combinational circuit is a directed acyclic graph whose no des are combi- national elements, and where an edge from element w to element w implies 1 2 that the output of w is an input to w ; the size of a circuit is its number 1 2 of elements. Elements of zero fan-in are inputs; elements of zero fan-out are outputs. Combinational elements are computational units that can p erform certain well-de ned op erations, for instance additions and subtractions. The depth of element w is the length of the longest path from an input elementto w ; the depth of a circuit is the maximum depth of an element in the circuit. A combinational circuit D for evaluating z can be built by applying G lo cal transformations to T as follows. To each comp osition op erator ' 2R we asso ciate an O 1-size circuit CT' consisting only of adders and min gates. If ' is a primitive graph, the inputs to CT' corresp ond to the vertex and edge weights of that graph. Its outputs will be the costs of the optimum solutions for each of the N equivalence classes. Otherwise CT' will have with Nk inputs and N outputs, where k is the arity of '. Inputs corresp ond to optimum solutions for the various equivalence classes of the comp osing graphs, and the outputs corresp ond the optimum solutions for the equivalence classes of the resulting graph. The structure of CT' is thus completely determined by the table asso ciated with op erator '. Every no de v of T that is lab eled by ' will be replaced by a copy of CT'. If u ;:::;u are the children of v in T , the inputs to this copyofCT' are the 1 k i z 's which are the outputs of the circuits asso ciated with u ;:::;u and 1 k u j i the outputs are the z 's. The result of applying this lo cal replacement to v the no des of T is a circuit whose inputs are the vertex and edge weights and i whose outputs are the z 's for the ro ot v of T . Equation 1 implies that v i the value of z can b e obtained by connecting the appropriate z 's to a min G v gate. The size of the resulting circuit D will b e O n, since T is a linear-size parse tree of G. More details of the construction can be found elsewhere [FeSl94, page 425]. To determine the output of D , we pro cess its elements in top ological order; thus, when it is no de w 's turn to be pro cessed, all its inputs will b e known, and its output can b e computed in O 1 time. Hence, the circuit-based algorithm runs in linear time. 17 3.3 Using the levels Assume that we have a balanced parse tree T of G, in which, as describ ed in Section 2.3, levels have b een identi ed according to some sequence of numb ers r ;:::;r . We shall use the levels to divide the computation of z 0 k G i into phases, where each phase determines the z 's for all no des between v two consecutive levels. The resulting algorithm will still run in linear time; however, its structure will be more useful in the context of the \lift and narrow" parametric search scheme develop ed in Section 4. We will describ e the algorithm in terms of the combinational circuit D asso ciated with T . By construction, every element w of D is asso ciated with some no de v of T , namely w is one of the elements of the O 1-size circuit CT asso ciated with the no de v . In fact, w will b e asso ciated with two no des of T if it is an input element for the circuit asso ciated with v and an output element for the circuit asso ciated with a child of v . Let v b e a level j no de, 0 1 j k , and, as in Lemma 2.6, let T be the subtree of T containing all v v the no des at or ab ove level j 1. Let D be the sub circuit of D induced v 0 by the elements asso ciated with the internal no des in T , together with the v 0 output elements of the circuits asso ciated with the leaves of T . Obviously, v the size and depth of D are prop ortional to the number of no des and the v 0 heightofT , resp ectively. Thus, by Lemma 2.5, D has O r =r elements v j j 1 v and depth O logr =r . j j 1 i Assuming the z 's are known for all level j 1 no des, we can use these u i functions as inputs to D to determine all the z 's, 1 i N . We simply v v traverse the elements of D in top ological order, pro cessing them in the usual v way; the outputs of the circuit will be the desired values. We shall call this pro cess evaluating D . v A more detailed description of the evaluator algorithm is given b elow. AG 1. Construct a balanced parse tree T and the asso ciated circuit D for G. 2. Identify the levels in T . 3. for each level 0node v 2 T do i 4. Determine all z 's by exhaustive enumeration. v 5. for j =1;:::;k do 6. for each level j no de v do i 7. Compute the z 's by evaluating D . v v 18 n o i 9. return min f+1g [ fz : C is an accepting class g , where v is i v the ro ot of T . As discussed in Section 2, a balanced parse tree for G can be found in linear time. Since the asso ciated circuit D can b e constructed in linear time, line 1 takes O n time. As argued in Section 2.3, line 2 can be done in O n time. Lines 3{4 take O n time, since they involve considering O n primitive i.e., O 1-size graphs. The remaining steps take a total of O n time, as they require examining each element of D exactly once, at a cost of O 1 p er element. Thus, the total time taken by A is O n. 4 Parametric Search Problems We now describ e the linear-time search algorithm. For concreteness and brevity, we shall only discuss problems whose underlying non-parametric versions require nding a minimum-weight subgraph; all of our results are easily transferable to analogous problems involving maximization. Our search pro cedure is based on Megiddo's parametric search metho d [Meg79, Meg83]. This technique relies on simulating a non-parametric algo- rithm for evaluating Z the function describing the cost of the optimum G solution for any xed ; the goal is to determine the computation path followed by the algorithm at the value b eing sought. In our case, the algorithm to be simulated will be pro cedure A of Section 3. Clearly, A can be used to evaluate Z for any given : we simply need to determine G 0 0 the vertex and edge weights at and then run A as usual. 0 Before going into further details, we need to establish some terminology and make some observations. Let d b e a nonnegativeinteger. The term d-th degreepolynomial will b e used to refer to any p olynomial of degree at most d. We shall assume a mo del of computation where evaluating and computing the ro ots of a d-th degree p olynomial are constant-time op erations. A function f : R ! R is a d-th degree piecewise polynomial function d-ppf if it is the lower or upp er envelop e of some nite set of d-th degree p olynomials in . Since the cost of every subgraph is a d-th degree p olynomial in , Z is a G d-ppf [FeSl94]. Furthermore, if weights are concave, Z will be concave. G Let f be a d-ppf and let I =[ ; ]bean interval. We can represent f L R within I by storing its breakp oints in a balanced binary search tree. Together 19 f3 f λ 2 3 f4 f4 λ f λ f f1 1 2 4 5 f5 λ λ L f1 2 f3 λ λλ λ λ λ L 1 2 3 4 R Figure 4: A d-ppf and its ecient representation. with each breakp oint, we store the equation of the segmentoff corresp onding to the interval to its right note that, to do this prop erly, we may have to intro duce an arti cial breakp oint at | see Figure 4. We shall call this L an ecient representation of f within I . This representation will allow us to evaluate f for any 2 I in O log r time, where r is the number of breakp oints of f that fall within I . The simulation of A is done in a sequence of alternating lifting and nar- rowing stages. During a lifting stage, the search algorithm simulates a p ortion of A's computation in such a way as to nd all computation paths followed by the algorithm over an interval I containing . To do this, the search algo- rithm carries out the steps of A, manipulating dth degree concave p olynomial functions of instead of numb ers. Thus, additions of numb ers b ecome ad- ditions of d-ppf 's and nding the minimum of two numb ers translates into taking the lower envelop e of two d-ppf 's [FeSl94, Meg83]. Lifting the compu- tation of A is, in general, time consuming. The purp ose of a narrowing stage is to reduce the size of the interval I under consideration, so as to make the next lifting stage faster. Narrowing will require invoking an oracle B capable of determining whether or not ; this op eration will be referred to as 0 resolving . 0 20 4.1 Oracles and evaluation There is a close relationship between evaluating Z and resolving -values. G We shall argue that, for all problems studied here, resolving a value reduces 0 in O 1 time to O 1 evaluations of Z . G In what follows, I will denote an interval known to contain . All invo cations of the oracle will use such an interval, which will be up dated continually by the search algorithm. Let 2 R b e the value to b e resolved. 0 If 62 I , we can, in O 1 time, determine the p osition of relative to 0 0 by comparing it to the endp oints of I . Supp ose that 2I. When weights 0 are linear, oracles for problems P1{P3 can be obtained by using A to evaluate Z and then doing some additional O 1-time problem-sp eci c G 0 work [FeSl94]. For example, for problem P2 which involves nding the p oint at which Z crosses the -axis, assuming the slop es of all weights are G negative a common scenario in minimum-ratio optimization, we will know that < if Z > 0; otherwise, . 0 G 0 0 Evaluating Z is also an essential comp onent of the oracle for P3 when G weights are concave d-th degree p olynomials. Because Z is concave, we can G conclude that < if there exists >0 such that Z + >Z and 0 G 0 G 0 that > if there exists >0 such that Z >Z . Otherwise, 0 G 0 G 0 we will have = . Thus, three evaluations of Z will b e enough to resolve 0 G : one at itself and two a p oints that are \arbitrarily close" and to the 0 0 left and right of . 0 We are left with the problem of evaluating Z + and Z . We G 0 G 0 do this by runnning A using input weights that are functions of . During the execution of the algorithm, is treated symb olically as an indeterminate number assumed to be smaller than any other number that ever app ears in the computation. Since is xed and the only arithmetic op erations 0 are additions and subtractions, we shall at all times be manipulating dth degree p olynomial functions in . To compare two functions f and g , we examine h=f g to determine if there exists some > 0 such that h > 0 for all 2 0;]. This can be done in O 1 time under our assumption that ro ots can be computed in O 1 time. Thus, each of A's op erations can be carried out in O 1 time without explicit knowledge of and, hence, Z + can b e evaluated within the same time b ound as that G 0 of A. We should note that a di erent approach for implementing the oracle for P3 was prop osed by Toledo [Tol93]. 21 4.2 Building sublinear oracles Supp ose we are given a balanced parse tree T of G in which levels have b een identi ed, as describ ed in Section 2.3. We will show that, given a cer- tain amount of precomputation, one can obtain a sequence of algorithms A ;:::;A for evaluating Z , where, for 0 j k , A runs in time 0 k G j O n=r log r . Given the close relationship between evaluating Z and j j G resolving -values see Section 4.1, this sequence of evaluators yields a se- quence of oracles B ;:::;B , where B has the same asymptotic time b ound 0 k j as A . j Pro cedure A will only b e required to evaluate Z for falling within j G 0 0 a certain interval I containing . For j =0;:::;k, A assumes that for each j level j no de w and each equivalence class i,wehave an ecient representation i i of Z within I as b efore, Z denotes the function describing the cost w w of the optimum solution for the ith equivalence class of G . For brevity, w i any such function Z will b e referred to as a level j function. Algorithm A j w takes advantage of the precomputed level j functions to evaluate Z as G 0 follows. A j 0 i for Step 1. For each level j no de w in the parse tree T of G, nd Z 0 w i each equivalence class i by accessing the ecient representation of Z . w 0 Step 2. Let T denote the subtree of T consisting of all no des lying ab ove level j 0 j . Traverse T in p ostorder. Whenever a no de u is visited, compute j i Z for each equivalence class i. 0 u n o i Step 3. Return min f+1g[fZ :C is an accepting class g , where v 0 i v is the ro ot of T . The correctness of algorithm A can be deduced from the fact that it is j an adaptation of the dynamic programming algorithm of Section 3. Access- i ing the ecient representation of each level j function Z in step 1 takes w time logarithmic in the number of breakp oints of that function. Results from an earlier pap er [FeSl94] imply that this number is p olynomial in r , j where the degree of the p olynomial dep ends only on the regular problem in question see also Lemma 4.1 b elow. Thus, the search time is O log r j 22 per function. Since, by Lemma 2.6, there are O n=r level j functions to j evaluate a constant number per level j no de, the total time sp ent in step 0 1isO n=r log r . By Lemma 2.6, the number of vertices in the tree T of j j j step 2 is O n=r , and the time sp ent on each no de is constant. Thus, step 2 j takes O n=r time. Since step 3 takes O 1 time, A takes O n=r log r j j j j time. Building ecient representations of the level j functions as required by A j can b e time-consuming if the interval I over which they must b e constructed is large. The next lemma gives a condition under which the construction can be done rapidly. Lemma 4.1 Suppose j 2f1;:::;kg and let I be an interval within which the total number of breakpoints of the level j 1 functions is O n=r . Then there j exists a constant , which depends only on the underlying regular problem, such that the total number of breakpoints of the level j functions within I is