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 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 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

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 Typ e Previous Bounds Our Bounds

Upward general O N log N

StraightLine

Upward AVL N

StraightLine

StrictlyUpward general N log N

StraightLine

Upward degree O n N x

Polyline

Upward Ordered degree O N log N x

Polyline

LeavesonHull binary N log N

Orthogonal

NonUpward degree O N

Orthogonal

Table Arearequirementsforvarious typ es of planar grid drawings of a

ro oted tree with N no des

Preliminaries

In this section we give denitions that will b e used throughout the pap er

A drawing of a graph G maps eachvertex of G to a distinct p oint of the plane

and eachedgeu v ofG to a simple Jordan curve with endp oints u and v Wesay

thatisastraightline drawing see Fig a if each edge is a straightline seg

mentisapolyline drawing see Fig b if each edge is a p olygonal chain and

we call bends the intermediate vertices of the chain that are not vertices of Gis

an orthogonal drawing see Fig c if each edge is a chain of alternating horizontal

and vertical segments A grid drawing is such that the vertices and b ends along

the edges haveinteger co ordinates Planar drawings where edges do not intersect

are esp ecially imp ortant b ecause they improve the readability of the drawing and

in the context of VLSI layouts they simplify the design pro cess Anupward

drawing of a directed graph is such that everyedgeisacurve monotonically nonde

creasing in the vertical direction when trav ersed along the direction of the edge

(a) (b)

(c)

Fig Example of planar upward drawings of the same binary tree a

straightline b p olyline c orthogonal

The area of a drawing is the area of the smallest rectangle R with sides parallel

to the axes covering the drawing The width and height of are the width and height

of R resp ectivelyWe 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 When a resolution rule is given it is meaningful to consider the

problem of nding drawings with minimum area

An orderedtree is a ro oted tree with a presp ecied lefttoright order of the

children of each no de Let T b e an ordered tree We assume that eachedgeofT is

directed from the child to the parent The ordering of the children of a no de v will

b e referred to as their lefttoright order Hence the rst and last children of v will

b e referred to as the leftmost child and rightmost child of v resp ectivelyThedegree

ofanodeofT is the numberofitschildren Tree T is said to b e leftheavy see

Fig a if for every no de v of T the children of v are ordered by nonincreasing

size of their subtrees A leftmost path of T is a maximal path consisting of no des

that are leftmost children except the last no de

A binary tree is dened as a ro oted tree such that each no de has at most two

children Examples of planar upward drawings of a binary tree are given in Fig

Polyline Drawings

In this section weinvestigate p olyline drawings First we describ e a layering

technique that will b e used to construct the drawings

UpwardLayerings

We dene the inorder visit of a ro oted ordered T as follows

i recursively visit the rst subtree of T

ii visit the ro ot of T

iii recursively visit the other subtrees of T in lefttoright order

An upward layering of T is a mapping of the no des of T to nonnegativeintegers

that satises the following prop erties see Fig a

0 3 1 3 4 2 2 5 5 4 7 3 6 2 7 75 5 3 7

(a) (b)

Fig a Example of upward layering of a leftheavy tree b Drawing

asso ciated with

i If w is the leftmost child of v then v w

ii If w is a child of v but not the leftmost child then v w

iii If u is the ro ot of T thenu

Wesay that a no de v is assigned to layer i if v iAnedgeu v issaidto

traverse layer i if v i u The height of upward layering is dened as

max v The width of a layer i is the number of nodes assigned to layer i plus

v T

the numb er of edges that traverse layer iThewidth of is the maximum width

of a layer

The following theorem shows that an upward layering can b e extended to a

planar p olyline upward grid drawing where the no des are placed along horizontal

lines asso ciated with the layers see Fig b

Theorem Given an upward layering with height H and width W of an N node

orderedtree T a planar polyline upwardgriddrawing of T with height W and width

H can beconstructedinO H W time

Pro of First we insert dummy no des along the edges that traverse layers

Namelyifedgeu v traverses layers i through j we insert j i dummynodes



along u v and assign them to la yers i through j resp ectively Let T b e the



resulting tree For eachnodev of T weset y v v and xv equal to the



numb er of no des of layer v preceding v in the inorder visit The edges of T

are then drawn as straightline segments Clearly this yields a straightline upward



grid drawing of T with height H and width W suchthatevery edge either joins

no des of consecutivelayers or joins a leftmost child to its parent on the same level

We claim that the drawing is also planar Toprove the claim we observe a a

horizontal edge u v onlayer i cannot b e crossed b ecause all the no des b etween

u and v in the inorder sequence are assigned to layers b elow i b if there were a

     

crossing b etween edges v w and v w where w precedes w in layer i and

   

v precedes v in layer i then wewould have that w precedes w in the inorder

 

sequence but v follows v in the inorder sequence a contradiction Finallywe

obtain a planar p olyline upward grid drawing of T by replacing the dummynodes



of T with b ends The height and width are not aected The ab ove construction

can b e easily carried out in time O H W

Therefore it is sucient for us to describ e how to construct an upward layering

of a tree

Drawing Algorithm

In this section we describ e an algorithm for constructing an upward layering

of an N no de ro oted tree We show that if the tree has b ounded degree an up ward

layering with width O N and height O N can b e constructed for any constant

such that

So let T b e a leftheavy ordered ro oted tree with N no des we will showhow

to remove this leftheavy restriction later The following algorithm constructs an

upward layering of T with width O N d log N and height O N The

algorithm incrementally assembles an ordered sequence of no des of T and marks

some no des of T such that the following invariants are maintained

i If u precedes v in then u v and

ii a no de is marked if and only if it is the rst no de of its layer contained in

The assembly of is p erformed by rep etitiv e insertions of leftmost paths Atthe

end of the computation the sequence contains all the no des of T so that and

the marking of the no des uniquely identify the upward layering Note that in the

sequence a child precedes its parent while in the layering achild is assigned

toalayer numb er greater than or equal to the one of its parent The algorithm

consists of three steps

i Preprocessing Initialize as the leftmost path containing the ro ot of T

ii Main Loop

for k log N do

execute round k

a Select the no des v of T suchthat

v is a child of a no de of

v is not already in and

k

the subtree ro oted at v has size at least N

b Sort the selected no des according to the order of their parents in

k

c Partition the sorted sequence of selected no des into blo cks of no des

with the last blo ck p ossibly having fewer no des

d For eachblockv v let u b e the parentofv Mark u and

m

successively insert into the leftmost paths of v v right b efore

m

u

endfor

iii Postprocessing Scan sequence and mark a no de if it has N unmarked

predecessors

Layering is nally constructed by assigning no de v to layer i if there are i

marked no des following v in

The algorithm is illustrated in Fig An example of the layering pro duced

for a dierent tree is shown in Fig

Theorem Let beaconstant such that Given an N node leftheavy

rootedorderedtree T with maximum degree d an upward layering of T with height

H O N and width O NH d log N can b econstructedinO N time

Pro of Every no de is eventually inserted into Namely after round k all the

k

no des in the leftmost path of a subtree of size N are inserted into Hence

every no de is assigned to a layer All the children of a no de v precede v in Also

if u isachild of v but is not the leftmost child of v then u v b ecause either

v is marked or there is a marked no de b etween u and v in Hence is an upward

layering

Wesayanedgeu w of T is across a marked no de v if u precedes v andv

precedes w in After round k the numb er of edges across a no de is increased by

k

at most d Hence at the end of the main lo op the numb er of edges across

ed no de is at most amark

log N

X

k

d

k p r y z x u w v s q t

Block 1 (a) Block 2 Λ xyzswt u v pq r

round k=4

xyz u v

Block 1 Λ Block 2

(b)

Fig Illustration of the execution of round of the upward layering algorithm

of Theorem Here N andk a Tree b Twoblocks

of size at most are created in Step c and no des x and v are marked in

Step d

P

m

i m

Since a aa a weget

i

log N

X

k

N d log N d

k

The p ostpro cessing step do es not increase the numb er of edges across a marked

no de After the p ostpro cessing step at most N no des are assigned to a layer

Also the numb er of edges that traverse a layer is less than or equal to the number

of edges across the marked no de of that layer We conclude that the width of is

at most

N N d log N

k k

Since there are at most subtrees of size at least N thenumb er of blo cks

k k k

created in step c in round k is at most d e Hence after

k

round k the number of marked no des is increased byatmost Hence

the total numberofnodesmarked in the main lo op is at most

log N

X

k

N log N

k

The p ostpro cessing step marks at most N no des The heightof is equal to

the numb er of marked no des so that it is at most

N N log N

Toachieve linear time complexitywe set up a data structure that allows us to

eciently p erform Steps ab Wesay that a no de is active for round k if it is in

k

and has a child not in whose subtree has size at least N A no de is called

active if it is activeforany round k We maintain log N lists such that b efore

round k the k th list contains the no des active for round k Within each list the

active no des are in the same relative order as in An active no de can app ear in

more than one list and has p ointers to its representatives in the lists

The no des selected in round k are children of the no des in list k so that they can

b e accessed and sorted in Steps ab in O time p er no de Every no de v that

has more than one child and gets inserted into at round k b ecomes a new active

no de and its representatives are inserted into the appropriate lists The insertion

in each such list is carried out in a manner similar to insertion in This can b e

done in O time p er representative in Step d Also whenever a no de b ecomes

inactive for round k we remo ve its representativefromthek th list Again this can

b e done in O time p er representative Therefore the total time for maintaining

the lists is prop ortional to the maximum total size of the lists The k th list can

k  

haveatmost no des Since a no de in list k is also in list k for k kwehave

that the maximum total size of the lists is

log N

X

k

log N k N log N

k

The remaining computations can b e p erformed in O N time and we conclude

that the time complexity of the algorithm is O N

Theorem Given a rootedtree T with N nodes and maximum degree danda

constant such that a planar polyline upward grid drawing of T with

height H O N and width O NH d log N can beconstructedinO N

time

Pro of First p ermute the children of a no de so that they are ordered by

nonincreasing size The tree so obtained is leftheavy so that the result follows

from Theorems

Theorem implies the existence of optimal area planar upward p olyline grid

drawings for trees of maximum degree O N for any constant suchthat

Corollary Givenaboundeddegreerootedtree T with N nodes and a constant

such that a planar polyline upwardgriddrawing of T with area O N

height H O N and width O NH can beconstructedinO N time

Corollary Let and beconstants such that Given a rooted

tree T with N nodes and maximum degree O N a planar polyline upwardgrid

drawing of T with are a O N height H O N and width O NH can be

constructedinO N time

The algorithm describ ed in this section has b een implemented for binary trees

The drawing pro duced for a complete binary tree with no des and is

shown in Fig

Fig Drawing of the complete binary tree with no des pro duced bythe

implementation of the algorithm of Corollary with

Order Preserving Drawings

The drawings obtained with the ab ove algorithm do not preserve the lefttoright

order of the children This is justied however by the area lower b ound given in

Theorem Our pro of of theorem is based up on the following lemma

Lemma Any planar upwardpolyline grid drawing of the complete binary tree

with N nodes has log N width and log N height

Pro of Let us denote by H N and W N the minimum height and width resp ec

tivelyofanupward p olyline grid drawing of an N no de complete binary tree T

In anyupward p olyline grid drawing of T a no de its children and its grand

children can not all b e placed at the same height Hence we get the recurrence

H N H N H H Therefore H N log N

The width of anyupward p olyline grid drawing of T is at least one plus the min

imum of the widths of the drawings of the subtrees of T in the drawing Therefore

W N W N with W Hence W N log N

Theorem The N node ordered binary tree B requires N log N areainany

N

planar upwardpolyline grid drawing that preserves the order of the children

Pro of Let B b e an ordered binary tree comprising see Fig a

N

achain with N no des alternating b etween left and rightc hildren

N leaves attached to each nodeofthechain alternating as left and right

children and

a complete subtree with N no des attached to the b ottommost no de of the

chain

In any planar upward p olyline grid drawing of B b ecause of the order of the

N

children each pair of consecutive edges of the chain contributes at least one unit

to the height of the drawing see Fig b so that the chain requires N height

By Lemma the complete subtree requires log N width

chain with N/3 nodes

(b)

complete binary tree with N/3 nodes

(a)

Fig Orderpreserving drawings a Tree for the lower b ound of Theorem

b Each pair of consecutive edges of the chain increases the heightby at least

one unit

The lower b ound of Theorem is tightand canbeachieved with the following

simple recursive algorithm

i Let T T T b e the subtrees of a b ounded degree tree T whose ro ot is

m

v see Fig a where m is ve Let the ro ot of the subtree T b e denoted

i

by v Recursively construct the drawings of each T Vertically stacktheir

i i

drawings see Fig b such that the subtree at the b ottom has the maximum

size among the subtrees other subtrees can b e placed in any order eg in

Fig b they are in the order T T T T from top to b ottom Place the

ro ot v ab ove the drawing of the topmost subtree

ii Nowforevery T drawedgev v as a p olyline that uses one vertical track

i i

grid column either on the left or on the rightofeach T drawn ab ove T

j i

dep ending up on whether T is to the left or rightofT in T and corresp ond

j i

ingly switches from left to right or viceversa eg in Fig T is to the left

of T and is to the right of the subtrees T T and T Hence in Fig b

edge v vrstusesavertical track on the left of the drawing of T and them

switches to a vertical track on the rightofthedrawing of T T and T

This completes the construction of the drawing of the tree T

Fig e shows the drawing constructed by this algorithm for the ordered tree

of Fig d

Theorem Given a boundeddegreeorderedtree T with N nodes a planar polyline

upward grid drawing of T with width O log N height N and area O N log N

that preserves the order of the children can beconstructedinO N time

Pro of Let T T T b e the subtrees of T and v b e the ro ot of T Let the ro ot

m

of the subtree T b e denoted by v

i i

m is a constant only a constantnumb er say cofvertical tracks are Since

needed to route all the edges of the typ e v v Let T b e the subtree that is drawn

i k

b ottommost and hence has the maximum size among the subtrees Therefore if we

denote by W T the width of the drawing of T wehave

W T maxfW T maxfW T g cg

k i

ik

Let w idthN b e the maximum width of the drawing constructed by the al

gorithm of any tree with N no des Nowweshow inductively that widthN

log N for some constant c This is trivially true for N since w idth

No w supp ose this is true for any tree with less than N no des If N is the size

of a tree T then the size of T as dened ab ove is at most N and since there

k

can b e at most two subtrees of sizes b oth at least N size of any subtree T

i

of T for i k is at most N Therefore from equation and our inductive

hyp othesis w idthN maxf log N log N cgFor cwe

have w idthN log N

It is easy to proveby a simple inductive argument that the height of the drawing

Thus the area of the drawing is O N log N of T is N

The algorithm can b e trivially implemented in linear time

Orthogonal Drawings

In this section we consider planar orthogonal upward grid drawings of binary

trees and provide a tightN log log N b ound on the area v

3 5 2 4 7

T1 T2 T3 T4 T5 (a) v

T5

T3

T2

T1

T4

(b)

(c) (d)

Fig Example of construction of orderpreserving drawings Here m

a Tree T with subtrees T T T Thenumb er inside the triangle

 

representing subtree T indicates the number of nodes of T b Drawing of

i i

T where the rectangles represent the drawings of the T s c An ordered tree

i

T d Drawing of T constructed by the algorithm of Theorem

Drawing Algorithm

First we present a simple straightline drawing algorithm that will b e later

used as a subroutine The algorithm is a variation of the ones by Shiloach and by

Crescenzi Di Battista and Pip erno Wesay that a no de in a drawing is obstructed

if the vertical line through v intersects the drawing b elow v

Lemma Let T be a binary tree with N nodes A planar straightline orthogonal

upward grid drawing of T with width at most N and height at most log N such that

every node of degree or is not obstructed can beconstructedinO N time



Pro of The algorithm rst transforms tree T into a leftheavy binary tree T

Then for every no de v it sets y v equal to the minus of the number of nodes on

 

the path in T from v to the ro ot that are rightchildren Then traversing T in

the p ost order sequence for every no de v it sets xv equal to the xco ordinate of

its rightchild if it has one otherwise sets xv to one plus the xco ordinate of the

last no de visited b efore it Finally it draws each edge as a straightline b etween its

endp oints The drawing is clearly a straightline upward drawing

Twonodesv and w are assigned same xco ordinates by the algorithm if and only

if there is a sequence of no des u v u u u w or u w u u u

m m



v such that u is the rightchild of u in T Since no no de of T with degree or

i i



has a rightchild in T eachnodeofT with degree or is assigned a unique

xco ordinate and hence is not obstructed

For every edge e u v ofT either y u y v which happ ens when u

 

is the left child of v in T or xu x v when u is the rightchild of v in T

Hence the drawing constructed is orthogonal

Nowweshow that the drawing is planar Supp ose for contradiction there are

edges e u v ande u v that cross Assume without loss of generality



that v precedes u in the p ost order traversal of T Ife do es not b elong to a

subtree ro oted at u then b ecause of the p ost order assignmentof xco ordinates

wehave that xu xv xu xv Hence e and e can not cross

then a contradiction If e b elongs to a subtree ro oted at the left child of u

xu xv xu xv andife b elongs to a subtree ro oted at the right

child of u then y u y v yu y v and in either case e and e can

not cross again a contradiction Hence the drawing constructed is planar

The drawing has width at most N and has height at most log N b ecause any



path in T from a leaf to the ro ot consists of at most log N no des that are right

children of their resp ective parents

The algorithm can b e easily implemented in linear time

An example of a drawing constructed by the algorithm of Lemma is shown in

Fig a

Now we recall some denitions on separators of binary trees Let T b e a binary

tree with N no des A partial tr ee of T is a tree which is a subgraph of T Note

the dierence b etween partial tree and subtree the subtree of T ro oted at no de v

is the partial tree of T containing all the descendants of v is the entire tree ro oted

atachild of the ro ot of T Aseparator of a binary tree T is an edge of T whose

removal divides T into two partial trees each with at least N nodesandatmost

N no des eg see Chazelle A recursive decomp osition of T by separators

denes a binary tree S called separator tree where eachleafofS corresp onds to a

no de of T andeachinternal no de of S corresp onds to a partial tree T of T and

to the separator s u v ofT with the left child of b eing asso ciated to the

partial tree of T ro oted at u and the rightchild asso ciated with the rest of T

Tree S has N nodesheight at most log N and can b e constructed in O N

time eg see Guibas et al

The algorithm for constructing a planar orthogonal upward grid drawing of an

N no de binary tree T is outlined b elow see Fig

i Construct the separator tree S of T

ii Remove from S the no des asso ciated with partial trees with less than log N



no des and let S b e the resulting truncated separator tree which has O N log N

no des and O logN log N O log N height See Fig bc



iii For eachleaf of S construct a drawing of the asso ciated partial tree T

(a)

(b)

(e)

(c) (d)

Fig Illustration of the algorithm of Theorem a Example of a drawing

pro duced by the algorithm of Lemma b A binary tree T and the separators

that join blo cks drawn with thick lines Here N log N one blo ck



has size and the remaining blo cks have size The blo ck size B is obtained

for T by using the constraintlog N  B  log N c Truncated separator

 

tree S of the tree T of part b The no des of S corresp ond to the separators

of T d Stacking of the drawings of the blo cks of T and routing of the

separators The rectangles represent the drawings of the blo cks e Drawing

of T constructed by the algorithm of Theorem

called a block using the algorithm of Lemma See Fig a Since T has

log N nodesitsdrawing has O log N width and O log log N height

iv Place the drawings of the blo cks vertically one ab ove the other sorted from

b ottom to top according to the inorder sequence of the asso ciated no des of



S See Fig d



v For eachinternal no de of S route separator s u v on the current

drawing creating b ends and adding extra tracks grid rows or columns when

ever needed See Fig d

Fig e shows a drawing constructed by this algorithm of the binary tree shown

in Fig b

Theorem Given a binary tree T with N nodes a planar orthogonal upward

grid drawing of T with O N bends O N log log N area O log N width and

O N log log N log N height c an beconstructedinO N time

Pro of By Lemma the union of the drawings of the blo cks constructed in

Step iv has width O log N and height O N log log N log N Weshowthatall

the separators can b e routed in Step v by adding a total of O log N vertical tracks

and O N log N horizontal tracks Wesay that a separator spans a blo ck T if its

endp oints are one b elow and the other ab ove the drawing of T A separator s is

routed using one vertical track either on the left or on the rightsideofthedrawing

of a blo ck T spanned by s dep ending on whether T is to the left or the rightof

the path from s to the ro ot in mo died T mo died b ecause of the conversion of

each T into a leftheavy tree in lemma

A switch o ccurs when s changes side b etween two blo cks or enters a blo ck

Each switch needs a distinct horizontal trackandtwobendsFor each basic blo ck

T only the separators asso ciated with ancestors of in S can span T sothat

O log N extra vertical tracks are sucient to route all the separators in Step v

The numb er of horizontal tracks added in Step v is equal to the total number of

switches The numb er of switches in the routing of separator s is b ounded bythe



height of the subtree ro oted at in S If corresp onds to a partial subtree of size



k the height of the subtree ro oted at in S is O logk log N Thus the total

numberofswitches sN is the solution of the recurrence sk skc sk

c O logk log N slog N where c lies b etween and It is easy to see

that sk is less than or equal to c k log N c logk log N c for appropriate

constants c c and c Therefore the total numb er of switches is O N log N

The log log N factor in the area achieved by the algorithm of Theorem may

at rst seem unnatural butitisnotasweshow in the next section that an

N log log N areab ound is tight within a constant factor

A Superlinear Lower Bound on the Area

We show that the sup erlinear areab ound of Theorem is tight within a constant

factor Let T b e the N no de binary tree consisting of see Fig

N

p

N no des where every log N th no de of C is called a joint achain C with

of C complete nodes binary trees 1/2

N/3 nodes with (log N)1/2 nodes (log N)

complete binary tree with N/3

nodes

Fig Tree for the lower b ound of Theorem

p p

log N complete subtrees where each subtree has log N no des and is N

ro oted at a child of a jointofC

a complete subtree with Nnodeswhichisrootedatachild of the rst no de

of C

Theorem Any planar upwardorthogonal grid drawing of the N node tree T

N

requires area N log log N

Pro of Consider any planar upward orthogonal grid drawing of T andletW

N

and H b e the width and height of the drawing resp ectivelyIfW is more than

N then the area of the drawing is N log N since by Lemma H log N

Now supp ose W is at most N Since T contains a complete subtree with N

N

no des byLemmawehave that W is log N Consider the sub drawing of any

sub chain S of C with W no des We claim that the height of the drawing of S

is log log N Since the drawing is upward the drawings of anytwo consecutive

sub chains of C must b e vertically stacked Hence the claim implies the statement

of the theorem

The pro of of the claim is illustrated in Fig For the sakeofcontradiction

we need only to consider the case when the height of the drawing of S is less



than log log N Let b e the horizontal line through the b ottommost no de of S in

the drawing Since S has W no des the drawing of S has width at most W and

contains at least W obstructed no des recall the denition of obstructed from

Section Also by a simple pigeonhole argument there are at least W log log N

  

obstructed no des of S on the same horizontal line where is ab ove Thus

p



log N log log N obstructed joints along line Consider there are at least W

p

the subtrees with log N no des connected to such obstructed joints Since the



drawing is upward these subtrees are drawn b elow line Ifanysuch subtree u subchain S l" joint

l' v

x = x' x = x"

Fig Drawing of sub chain S in the pro of of Theorem



is drawn entirely ab ove thenby Lemma the heightofthedrawing of S is

log log N and the claim is veried Otherwise every subtree has a leaf v b elow



or on line and we consider the path from v to its closest ancestor joint u

 

Let x and x b e the minimum and maximum xco ordinates of the drawing of S



b elow line The path b etween u and v must intersect one of the vertical lines

 

at x x or x x Also since wehave a planar upward orthogonal grid

drawing suchintersections must o ccur at distinct grid p oints of these twovertical

p

 

lines and b etween and Since there are at least W log N log log N such

p

paths wehave that the heightofthedrawing of S is at least W log N log log N

Recalling that W logN we conclude that the heightofthedrawing of S is

p

log N log log N log log N whichcontradicts our height assumption

ab out S This completes the pro of of the claim

The drawings constructed by the algorithm of Theorem do not preservethe

lefttoright order of the children Note that the lower b ound of Theorem applies

also to orthogonal drawings

Exp erimental Results

Wehave implemented the algorithm of Corollary given in section for con

structing planar upward p olyline drawings of trees on a Sun Sparcstation in

language C Our implementation takes a binary tree as its input The implemen

k

tation places d e no des in a blo ck in step c of the algorithm The theoretical

upp er b ound for width and heightofthedrawing with of a N no de binary

tree pro duced by our implementation computed as in the pro of of theorem is

p

p

W idth d N log N e

p p

H eig ht d N log N e

The additivetermoflog N app ears in width b ecause the implementation places

k k

d e no des in a blo ck in the step c as compared to no des as describ ed in the

algorithm The ratio of theoretical area b ound of drawing and number of nodes in

input tree therefore lies b etween and

The exp erimental results obtained for complete binary trees and Fib onacci trees

with are presented in Table In the table wehave denoted the theoretical

area b ound by A and the exp erimental area by A Fig and Fig givea

th ex

comparison of the the ratios r A N and r A N for complete binary

th th ex ex

and Fib onacci trees resp ectivelyThevalue of r for b oth complete binary and

ex

Fib onacci trees is less than even up to ab out million no des and hence the

algorithm is quite areaecient in practice









Theoretical Bounds

c

Exp erimental Results







































Area

N

c

cc cc c

c

c

cc c

c

c c

c

c

c

c

c

c

c

c

c

c

N

Fig Exp erimental results on the area of the drawings of complete binary

trees pro duced by the algorithm of Corollary with and comparison

with the theoretical upp er b ounds

Conclusion

In this pap er wehaveinvestigated the area requirement of dierenttyp es of

planar upward drawings of a ro oted b oundeddegree tree T with N no des Our

results are summarized as follows T admits a planar upward p olyline grid drawing

with area O N and with width O N forany presp ecied constant suchthat

If T is a binary tree then T admits a planar orthogonal upward grid

drawing with area O N log log N If T is ordered then T admits an O N log N

area planar upward grid drawing that preserves the lefttoright ordering of the

children of each no de All of the ab ove area b ounds are asymptotically optimal in

the worst case Also there are O N time algorithms for constructing eachofthe

ab ovetyp es of drawings of T with asymptotically optimal area

The drawings obtained with the techniques presented in this pap er indicate that

p erhaps there is a tradeo b etween the aesthetic quality and area b ound achieved

by tree drawing algorithms This issue needs to b e further explored A p ossible

direction is to investigate the tradeo b etween the maximum numb er of b ends p er

Theoretical Bounds Exp erimental Results

Nodes Width Area r Width Height Area r

ex

th

A

A

th ex

N Height A A

ex

th

N N

Complete

Binary

Tree

Fib onacci

Tree

Table Exp erimental results on the drawings of complete binary trees and

Fib onacci trees pro duced by the implementation of the algorithm of Corollary

with and comparison with the theoretical upp er b ounds



 

Theoretical Bounds



c





Exp erimental Results





















































Area

N

c

c

c c

c c

c

c

c

c

c

c

c

c

c c

c

c c

c

c

c

c

c c

c

c

c

c

c

c

c

c

c

N

Fig Exp erimental results on the area of the drawings of Fib onacci trees

pro duced by the algorithm of Corollary with and comparison with

the theoretical upp er b ounds

edge and the arearequirementofadrawing For example our algorithm for p olyline

drawings gives area O N but allows O N b ends p er edge whereas our algorithm

for orthogonal drawings gives area O N log log N andO log N b ends p er edge

In view of our results the main op en problem on this sub ject is determining

the area requirementofplanarupward straightline drawings of ro oted trees There

is still a gap b etween the trivial N lower b ound and the O N log N upper

Itwould also b e interesting to determine the total edgelength of our b ound

O N area p olyline drawings and extend our results to unb oundeddegree trees

A related op en problem is to investigate the area requirementofplanarupward

straightline drawings of ro oted trees suchthatthe angular resolution ie the

minimum angle b etween anytwo edges incident on the same no de is maximized

Previous results on the angular resolution of non upward drawings of graphs ap

p ear in

Acknowledgement

Wewould like to thank Giusepp e Di Battista Gun ter Rote and the anonymous

referees for many helpful comments

Research at Brown University supp orted in part by the National Science Foun

dation under grants CCR and CCR by the US Army Research

Oce under grants DAALG DAAH and MAMUR

and by the Oce of Naval ResearchandtheAdvanced Research Pro jects Agency

under contract NJ ARPA order

Research at The Johns Hopkins University supp orted in part by the National

Science Foundation under Grants CCR CCR and IRI

and by the NSF and DARPA under Grant CCR

References

S Bhatt and S Cosmadakis The complexity of minimizing wire lengths in VLSI

layouts Inform Process Lett

S N Bhatt and F T Leighton A framework for solving VLSI graph layout prob

lems J Comput Syst Sci

F J Brandenburg Nice drawings of graphs and trees are computationally hard

Technical Rep ort MIP Fakultat fur Mathematik und Informatik Univ Pas

sau

R P Brent and H T Kung On the area of binary tree layouts Inform Process

Lett

B Chazelle A theorem on p olygon cutting with applications In Proc rdAnnu

IEEE Sympos Found Comput Sci pages

R F Cohen G Di Battista R Tamassia I G Tollis and P Bertolazzi A frame

work for dynamic graph drawing In Proc th Annu ACM Sympos Comput

Geom pages

P Crescenzi G Di Battista and A Pip erno A note on optimal area algorithms for

upward drawings of binary trees Comput Geom Theory Appl

P Crescenzi and A Pip erno Optimalarea upward drawings of AVL trees In

R Tamassia and I G Tollis editors Graph Drawing Proc GD volume

of Lecture Notes in Computer Science pages SpringerVerlag

H de Fraysseix J Pach and R Pollack Small sets supp orting Fary emb eddings of

planar graphs In Proc th Annu ACM Sympos Theory Comput pages

G Di Battista P Eades R Tamassia and I G Tollis Algorithms for drawing

graphs an annotated bibliography Comput Geom Theory Appl

G Di Battista R Tamassia and I G Tollis Area requirement and symmetry

displayofplanarupward drawings Discrete Comput Geom

G Di Battista and L Vismara Angles of planar triangular graphs In Proc th

Annu ACM Sympos Theory Comput STOC pages

P Eades T Lin and X Lin Twotreedrawing conventions Technical Rep ort

Department of Computer Science University of Queensland to app ear

in Comput Geom Theory Appl

P Eades T Lin and X Lin Minimum size hv drawings In Advanced Visual In

terfaces Proceedings of AVI volume of World Scientic Series in Computer

pages Science

M Formann T Hagerup J Haralambides M Kaufmann F T Leighton

A Simvonis E Welzl and G Wo eginger Drawing graphs in the plane with high

resolution SIAM J Comput

M Furer X He MY Kao and B Raghavachari O n log nwork parallel al

gorithm for straightline grid emb edding of planar graphs In Proc ACM Sympos

Paral lel Algorithms Architect pages

L J Guibas J Hershb erger D Leven M Sharir and R E Tarjan Linear

time algorithms for visibili ty and shortest path problems inside triangulated simple

p olygons Algorithmica

G Kant Drawing planar graphs using the canonical ordering Algorithmica sp e

cial issue on Graph Drawing edited by G Di Battista and R Tamassia To app ear

G Kant G Liotta R Tamassia and I Tollis Area requirement of visibili ty

representations of trees In Proc th Canad Conf Comput Geom pages

Waterlo o Canada

C E Leiserson Areaecient graph layouts for VLSI In Proc st Annu IEEE

Sympos Found Comput Sci pages

S Malitz and A Papakostas On the angular resolution of planar graphs SIAM

J Discrete Math

J ORourke Computational geometry column Internat J Comput Geom

Appl Also in SIGACT News

E Reingold and J Tilford Tidier drawing of trees IEEE Trans Softw Eng

SE

P Rosenstiehl and R E Tarjan Rectilinear planar layouts and bip olar orientations

of planar graphs Discrete Comput Geom

W Schnyder Emb edding planar graphs on the grid In Proc st ACMSIAM

Sympos Discrete Algorithms pages

Y Shiloach Arrangements of Planar Graphs on the Planar Lattice PhD thesis

Weizmann Institute of Science

K J Sup owit and E M Reingold The complexityofdrawing trees nicely Acta

Inform

R Tamassia and I G Tollis A unied approach to visibil ity representations of

planar graphs Discrete Comput Geom

R Tamassia and I G Tollis editors Graph Drawing Proc GD volume

of Lecture Notes in Computer Science SpringerVerlag

W T Tutte Howtodraw a graph Proceedings London Mathematical Society

L Valiant Universality considerations in VLSI circuits IEEE Trans Comput

C