Planar Upward Tree Drawings with Optimal Area
Total Page:16
File Type:pdf, Size:1020Kb
International Journal of Computational Geometry Applications c World Scientic Publishing Company PLANAR UPWARD TREE DRAWINGS WITH OPTIMAL AREA ASHIM GARG Dept of Computer Science Brown University Providence RI USA agcsbrownedu MICHAEL T GOODRICH Dept of Computer Science The Johns Hopkins University Baltimore MD USA goodrichcsjhuedu and ROBERTO TAMASSIA Dept of Computer Science Brown University Providence RI USA rtcsbrownedu Received September Revised February Communicated by JD Boissonnat ABSTRACT Ro oted trees are usually drawn planar and upward ie without crossings and with out any parent placed b elow its child In this pap er weinvestigate the area requirement of planar upward drawings of ro oted trees Wegive tight upp er and lower b ounds on the area of various typ es of drawings and provide lineartime algorithms for constructing optimal area drawings Let T b e a b oundeddegree ro oted tree with N no des Our results are summarized as follows Weshow that T admits a planar p olyline upw ardgriddrawing with area O N and with width O N forany presp ecied constant suchthat If T is a binary tree weshow that T admits a planar orthogonalupward grid drawing with area O N log log N Weshow that if T is ordered it admits an O N log N area planar upward grid drawing that preserves the lefttoright ordering of the children of each no de Weshow that all of the ab ove area b ounds are asymptotically optimal in the worst case We present O N time algorithms for constructing each of the ab ovetyp es of drawings of T with asymptotically optimal area We rep ort on the exp erimentation of our algorithm for constructing planar p oly line upward grid drawings p erformed on trees with up to million no des wing Keywords Graph drawing orthogonal drawing straightline drawing planar dra upward drawing tree area grid Intro duction and Overview The research area of graph drawing establishes a connection b etween computa tional geometry and graph theory The general setting is that we are given a graph G and we wish to pro duce a geometric representation of G that visualizes Gs imp ortant prop erties For example wemay wish to display all the symmetries in G or if G contains a Hamiltonian cycle wemay wish to draw G as a regular p olygon with chords The interest in this area has b een growing signicantly of late see eg the Pro ceedings of Graph Drawing and the annotated bibliography on graph drawing algorithms maintained by Di Battista Eades Tamassia and Tol lis which mentions more than pap ers Imp ortant domains of application for graph drawing algorithms include software engineering pro ject management visual languages and VLSI layout Perhaps the most studied graph drawing problem is that of pro ducing a planar drawing of a planar graph eg see the classic work of Tutte on planar convex drawings and the recent results on planar straightline drawings But there is a variety of other interesting graph drawing problems that are also b eing investigated of late such as representing G by means of visibilitybetween geometric gures in the plane eg and ORourkes computational geometry column or dynamically maintaining a drawing under a sequence of insertions and deletions of vertices and edges as studied byCohenet al The Problem An imp ortant criterion for a drawing of a graph is that it takes up as little area as p ossible This is motivated by the nite resolution of all of our current technologies for rendering a drawing and also by circuitarea optimization criteria in VLSI layout In the following we assume the existence of a resolution rule that implies a nite minimum area for the drawing of any graph A typical resolution rule is to require grid drawings where the vertices and b ends of the edges haveinteger co ordinates Indeed this consideration recently motivated the reexamination of straightline drawings of planar directed graphs b ecause they require exp onentiallylarge area whereas several researchers have recently shown that planar graph drawings require only quadratic area and that suchdrawings Moreover some very nice recentwork by can b e pro duced in linear time Kant shows that a numb er of other aesthetic criteria suchasconvex faces can b e satised for a planar drawing while still keeping the area quadratic In this pap er we study areaecientdrawings of ro oted trees The goal of this researchistodrawanN no de tree T in as little area as p ossible while still maintaining certain aesthetic qualities of the drawing The aesthetic qualities we are particularly interested in are that the drawing b e planar and upward ie that every edge of T be a vertically monotone chain from the child to the parent so that the parent u of a no de v has y co ordinate greater than or equal to the one of v This is the natural way in which ro oted trees are usually drawn to display their hierarchic structure eg see any undergraduate text in data structures The diculty is that most of the known techniques for constructing planar upward drawings of trees require N area in the worst case Previous Work If we relax the upward requirement however then as indep endently shown by Leiserson and Valiant one can construct an O N area planar orthogonal grid drawing of an N no de tree T where the no des are placed at integer grid p oints and the edges follow paths of the grid However Brent and Kung show that if the leaves of an N no de complete binary tree are constrained to b e on the convex hull of the drawing then the drawing needs N log N area Thus a natural question is whether O N area is still achievable for planar upward drawings Crescenzi Di Battista and Pip erno haverecently provided a negative answer to this question for the case of strictly upward grid drawings where the no des haveinteger co ordinates and the parent of a no de has y co ordinate strictly greater than the ones of its children Namely they exhibit a family of binary trees that require N log N area in any strictly upward planar grid drawing This lower b ound is tight within a constant factor Shiloach and Crescenzi Di Battista and Pip erno give lineartime algorithms that construct a strictly upward planar straightline grid drawing of an N no de ro oted tree with O N log N area O N height and O log N width Their result do esnt settle the question for the standard notion of upward draw ing however which allows a child no de to b e on the same horizontal line as its parent as long as it is not ab ove its parent In addition it should b e noted that pro ducing the exact minimization of the area of the drawing of a tree is NPhard under several drawing conventions Nevertheless Crescenzi Di Battista and Pip erno give O N area planar straightline upward grid dra wings of AVL trees They do not however give a general construction for other typ es of trees An hvdrawing of a binary tree has the following prop erties i no des have integer co ordinates iianedgebetween a no de v and its parent u is drawn either as a horizontal segment with u to the left of v orasavertical segment with u ab ove v iii the enclosing rectangles of the drawings of the subtrees ro oted at the children of a no de are disjoint Hence hvdrawings are a sp ecial case of upward planar straight p line drawings Eades Lin and Lin show how to construct in O N N log N time a minimumarea hvdrawing of an N no de binary tree However they do not provide sp ecic b ounds on the area requirementofhvdrawings Related results on the area requirement of visibility representations of trees are given in Our Results In this pap er we show that for any ro oted b oundeddegree tree T with N no des one can construct a planar upward grid drawing of T with O N area in O N time and that suchdrawing can have width O N for any presp ecied constant such that The latter feature provides great exibility to applications that need to t the drawing in a prescrib ed region of the plane We also extend our approach to trees of arbitrary maximum degree d at a small additional cost when d exceeds N for any Our drawings do not preserve the lefttoright ordering of the children in T however But this should not b e surprising for we showthat if one requires a planar upward tree drawing to preserve the lefttoright ordering then the drawing requires at least N log N area in the worst case and we show that this is tight to within a constant factor Our O N area drawing is for the polyline grid mo del where the no des of T are mapp ed to integer grid p oints and the edges of T are mapp ed to p olygonal chains with b ends at grid p oints These p olygonal chains need not follow along grid edges however If one desires suchadrawing then in Section weshow that one can con struct a planar upward orthogonal grid drawing of an N no de binary tree T with O N log log N area in O N time This log log N factor in the area may at rst seem unnatural but wesho wthatitisnotforwegivean N no de binary tree that requires N log log N areaforanyupward orthogonal grid drawing Thus we show that there is an intermediate case b etween the N area achievable for non upward planar orthogonal grid tree drawings and the N log N areaachievable for strictlyupward planar grid drawings or for upward planar grid drawings that preserve the lefttoright order It is also interesting to observethattheupward requirement p enalizes the area less than the requirement of placing the leaves on the same horizontal line for whichtheN log N area b ound also applies We summarize the previous and current b ounds on planar grid tree drawings in Table Drawing Tree