Upward Planar Drawing of Single Source Acyclic Digraphs

(Extended Abstract)

y z

Michael D. Hutton

UniversityofWaterlo o UniversityofWaterlo o

convention, the edges in the diagrams in this pap er Abstract

are directed upward unless sp eci cally stated otherwise,

An upward plane drawing of a is a

and direction arrows are omitted unless necessary.The

plane drawing of the graph in which each directed edge is

digraph on the left is upward planar: an upward plane

represented as a curve monotone increasing in the vertical

drawing is given. The digraph on the rightisnot

direction. Thomassen [14 ] has given a non-algorithmic,

upward planar|though it is planar, since placing v

graph-theoretic characterization of those directed graphs

inside the face f would eliminate crossings, at the

with a single source that admit an upward plane drawing.

cost of pro ducing a downward edge. Kelly [10] and

We present an ecient algorithm to test whether a given

single-source acyclic digraph has an upward plane drawing

v

and, if so, to nd a representation of one suchdrawing.

The algorithm decomp oses the graph into biconnected

and triconnected comp onents, and de nes conditions for

merging the comp onents into an upward plane drawing of

the original graph. To handle the triconnected comp onents

f

we provide a linear algorithm to test whether a given plane

drawing admits an upward plane drawing with the same

faces and outer face, which also gives a simpler, algorithmic

Upward planar Non-upward-planar

pro of of Thomassen's result. The entire testing algorithm

(for general single-source directed acyclic graphs) op erates

2

in O (n ) time and O (n) space.

Figure 1: Upward planar and non-upward planar

graphs.

1 Intro duction

There are a wide range of results dealing with drawing,

Kelly and Rival [11]have shown that for every upward

representing, or testing planarity of graphs. Fary [4]

plane drawing there exists a straight-line upward plane

showed that every can b e drawn in the

drawing with the same faces and outer face, in which

plane using only straight line segments for the edges.

every edge is represented as a straight line segment.

Tutte [15] showed that every 3-connected planar graph

This is an analogue of Fary's result for general planar

admits a convex straight-line drawing, where the facial

graphs. The problem of recognizing upward planar

cycles other than the unb ounded face are all convex

digraphs is not known to b e in P, nor known to

p olygons. The rst linear time algorithm for testing

b e NP-hard. For the case of single-source single-

planarityofa graphwas given by Hop croft and Tarjan

sink digraphs there is a p olynomial time recognition

[6].

algorithm provided by Platt's result [12] that sucha

An upward plane drawing of a digraph is a plane

graph is upward planar i the graph with a source-

drawing such that each directed arc is represented as

to-sink edge added is planar. An algorithm to nd

a curve monotone increasing in the y -direction. In

an upward plane drawing of such a graph was given

particular the graph must b e a directed acyclic graph

DiBattista and Tamassia [2].

(DAG). A digraph is upward planar if it has an upward

In this pap er we will solve these problems for

plane drawing. Consider the digraphs in Figure 1. By

single-source digraphs. For the most part we will b e

concerned only with constructing an upward planar

representation|enough combinatorial information to



Supp orted in part by NSERC.

y

sp ecify an upward plane drawing without giving actual

Currently [email protected].

z

Currently [email protected] o.edu. numerical co ordinates for the vertices. This notion will 1

Upward Planar Drawing of Digraphs 2

vertices, GnS denotes G with the vertices in S and all b e made precise in Section 3. We will remark on the

edges incidenttovertices in S removed. If S contains a extension to a drawing algorithm in the Conclusions.

2

single vertex v we will use the notation Gnv rather than Our main result is an O (n ) algorithm to test whether

Gnfv g. G is k -connected if the removal of at least k ver- a given single-source digraph is upward planar, and if

tices is required to disconnect the graph. By Menger's so, to giveanupward planar representation for it. This

Theorem [1] G is k -connected if and only if there ex- result is based on a graph-theoretic result of Thomassen

ist k vertex-disjoint undirected paths b etween anytwo [14, Theorem 5.1]:

vertices. Asetofvertices whose removal disconnects

Theorem 1.1. (Thomassen) Let bea plane

the graph is a cut-set. The terms cut vertex and sepa-

drawing of a single-source digraph G. Then thereex-

0

ration pair apply to cut-sets of size one and two resp ec-

ists an upward plane drawing strongly equivalent to

tively. A graph whichhasnocutvertex is biconnected

(i.e. having the same faces and outer faceas) if and

(2-connected). A graph with no separation pair is tri-

only if the source of G is on the outer faceof, and

connected (3-connected). For G with cut vertex v ,a

for every cycle  in ,  has a vertex which is not

component of G with resp ect to v is formed from a con-

the tail of any directededge inside or on .

nected comp onent H of Gnv byaddingto H the vertex

The necessity of Thomassen's condition is clear: for

0

v and all edges b etween v and H .For G with separation

a graph G with upward plane drawing , and for any

0

pair fu; v g,acomponent of G with resp ect to fu; v g is

cycle  of , the vertex of  with highest y -co ordinate

formed from a connected comp onent H of Gnfu; v g by

cannot b e the tail of an edge of , nor the tail of an

adding to H the vertices u; v and all edges b etween u; v

edge whose head is inside .

and vertices of H . The edge (u; v ), if it exists, forms

Thomassen notes that a 3-connected graph has a

acomponentby itself. An algorithm for nding tricon-

unique planar emb edding (up to the choice of the outer

1

nected comp onents in linear time is given in Hop croft

face) and concludes that his theorem provides a \go o d

and Tarjan [7]. A related concept is that of graph union.

characterization" of 3-connected upward planar graphs

We de ne G [ G , for comp onents with \shared" ver-

1 2

(i.e. puts the class of 3-connected upward planar graphs

tices to b e the inclusive union of all vertices and edges.

in NP intersect co-NP). An ecient algorithm is not

That is, for v in b oth G and G , the vertex v in G [ G

1 2 1 2

given however, nor do es Thomassen address the issue of

is adjacent to edges in each of the subgraphs G and G .

1 2

non-3-connected graphs.

Contracting an edge e =(u; v )inG results in a

The problem thus decomp oses into two main issues.

graph, denoted G=e, with the edge e removed, and

The rst is to describ e Thomassen's result algorithmi-

vertices u and v identi ed. Inserting new vertices within

cally; we do this in Section 4 with a linear time algo-

edges of G generates a subdivision of G. A directed

rithm, which provides an alternative pro of of his the-

subdivision of a digraph results from rep eatedly adding

orem. The second issue is to isolate the triconnected

anewvertex w to divide an edge (u; v )into (u; w )

comp onents of the input graph, and determine howto

and (w; v). G and G are homeomorphic if b oth are

1 2

put the \pieces" back together after the emb edding of

sub divisions of some other graph. G is planar if and

each is complete. This more complex issue is treated

only if every sub division of G is planar [1].

in Section 5. The combined testing/emb edding algo-

In a directed graph, the in-degree ofavertex v is

rithm is left out due to space constraints; a full version

the numb er of edges directed towards v , denoted deg v .

is available in the rst author's Masters Thesis [8], or in

+

Analogously the out-degree (deg v )ofv is the number

[9].

of edges directed away from v .Avertex of in-degree 0

The algorithm for splitting the input into tricon-

is a source in G,andavertex of out-degree 0 is a sink.

nected comp onents and merging the emb eddings of each

2

Adopting some p oset notation: we will write u< v

op erates in O (n ) time. Since a triconnected graph is



is there is a directed path u ! v . Vertices u and v

uniquely emb eddable in the plane up to the choice of the

are comparable if u< v or v

outer face, and the numb er of p ossible external faces of

otherwise. If (u; v ) is an edge of a digraph then u

a planar graph is linear by Euler's formula, the over-

dominates v .

all time to test a given triconnected comp onentisalso

2

O (n ), so the entire algorithm is quadratic.

3 ACombinatorial View of Upward Planarity

As discussed by Edmonds and others (see [5]) a con- 2 Preliminaries

nected graph G is planar i it has a planar representa-

In addition to the de nitions b elowwe will use standard

terminology and notation of Bondy and Murty[1].

1

A digraph G is connected if there exists an undi-

Note that Hop croft and Tarjan's \comp onents" include an

rected path b etween anytwovertices. For S a set of extra (u; v ) edge.

Upward Planar Drawing of Digraphs 3

If v is on the outer face of then the edge (v; t)has tion: a cyclic ordering of edges around eachvertex such

0

b een added to G . Otherwise consider the minimum i that the resulting set of faces F satis es 2 = jF jjE j +

suchthatv is not on the outer face of G . Note that jV j (Euler's formula). A face is a cyclically ordered se-

i

i>v. Then v is in a face f containing vertex i, and the quence of edges and vertices v ;e ;v ;e ;:::;v ;e ,

0 0 1 1 k 1 k 1

0

edge (v; i) has b een added to G . where k  3, such that for any i =0;:::;k 1 the edges

e (subscipt addition mo dulo k )ande are incident

i1 i

Note that this pro of provides a simple linear-time

with the vertex v and consecutive in the cyclic edge

i

algorithm to convert an upward planar representation

ordering for v .

i

of G to the set of edges which should b e added to G to

One metho d of combinatorially sp ecifying an up-

pro duce a planar s-t graph.

ward planar drawing is provided by the result of (inde-

Two plane drawings are equivalent if they have the

p endently) DiBattista and Tamassia [2], and Kelly [10]

same representation|i.e. the same faces. Twoplane

that a DAG G is upward planar i edges can b e added

drawings are strongly equivalent if they have the same

to obtain a planar s-t graph, de ned to b e a DAGwhich

representation and the same outer face.

has a single source s, a single sink t, contains the edge

In the remainder of this section we givesome

(s; t), and is planar. DiBattista and Tamassia givean

op erations which preserveupward planarity. The rst

algorithm using O (n log n) arithmetic steps to nd an

op eration contracts an edge connected to a vertex of in-

upward plane drawing of a planar s-t graph. We will

(out-) degree 1. The second attaches one upward planar

nd it useful to have a slightly di erent notion for our

graph to another at a single vertex. The third attaches

sp ecial case:

an upward planar graph in place of an edge of another

Definition 3.1. An upward planar representation

upward planar graph. The last splits a vertex into two

of a single sourceDAG G =(V; E) consists of a planar

vertices. These results can b e proved using Prop osition

representation together with: a designated outer face;

3.1. Pro ofs can b e found in [8]or[9].

and a vertex ordering 1; 2;:::;n such that vertex 1 is

Lemma 3.1. Let G bea DAGand v , dominatedby

on the outer face, and for each i =2;:::;n vertex i is

u,be a vertex of G with in-degree1.Then, G=(u; v ) is

a sink in G and is on the outer faceofG .Here G is

i i i

upward planar if G is upward planar.

the subgraph induced on vertices 1;:::i, and inherits its

Note that the same result holds for G and edge (u; v )

planar representation and outer facefrom those of G. +

with deg u =1 by symmetry.

Proposition 3.1. A single-source acyclic digraph

Lemma 3.2. Let G beanupward planar digraph

is upward planar i it has an upward planar represen-

with a vertex u, and let H beadigraph which has an

0

tation.

upward planar representation with a source u on the

0

Proof. ())Anupward plane drawing provides a

outer face. Let G bethegraph formed by identifying u

0 0

planar representation and a distinguished outer face.

and u in G [ H . Then G is upward planar.

Order the vertices by increasing y co ordinate. It is easy

Lemma 3.3. Let G beanupward planar digraph

to verify that the required conditions hold.

withanedge (u; v ),and H be a digraph which has an

(()Let G b e the digraph, and b e an upward pla-

0

upward planar representation with a source u and a sink

nar representation of G.We will showhow to add edges

0 0

v on the outer face. Let G be the graph formedby

0

to augment G to a planar s-t graph G and augment

removing the (u; v ) edge of G and adding H , identifying

0

to a planar representation of G . Then by the result of

0 0 0

vertex u with u and vertex v with v . Then G is upward

0

DiBattista and Tamassia [2], G has an upward plane

planar.

0

drawing corresp onding to the representation .Thus

Lemma 3.4. Let G beaDAG which has an upward

G has an upward plane drawing whose representation is

planar representation where the cyclic edge order about

.

0

vertex v is e ;:::;e . Let G be the DAG formedby

1 k

For each face f of , let v b e the vertex of f

f

0

splitting v into two vertices: v incident with edges

maximum in the ordering. Add edges (u; v ) for each

f

00

e ;:::;e ,andv incident with edges e ;:::;e . Then

1 i i+1 k

vertex u 6= v in face f for which suchanedgedoesnot

f

0

G is upward planar.

0 0

already exist. Call the result G . Clearly G is acyclic.

0

G is upward planar|wemust just augment the planar

4 Strongly-EquivalentUpward Planarity

representation for G to obtain a planar representation

0 0

for G , and use the same vertex ordering. G has a Consider the following question: Given a single-source

single source s, the vertex numb ered 1, and the vertex acyclic digraph G and a plane drawing of G,doesG

t,numb ered n, is a sink. The edge (s; t) has b een added admit an upward plane drawing strongly equivalentto

0

in G . In order to prove that t is the only sink, we will ? Expressing this in terms of representations: Given

provethatany other vertex v has some edge leaving it: a planar representation of G with some distinguished

Upward Planar Drawing of Digraphs 4

and a cut vertex v is upward planar i each of the outer face, can we augment this to an upward planar

k components H of G (with respect to v ) is upward representation of G|i.e. can we ndavertex ordering

i

planar. of G satisfying De nition 3.1?

We will rework Thomassen's condition in the form

Proof. If G is upward planar then so are its sub-

of a linear time algorithm to answer this question.

graphs the H 's. For the converse, note that if v 6= s

i

De ne a violating cycle of G with resp ect to to

then v is the unique source in all but one of the H 's;

i

b e a cycle  such that every vertexofisthetailof

and if v = s then v is the unique source in each H .

i

an edge inside or on . Our algorithm will nd either

Apply Lemma 3.2.

a violating cycle of G|evidence that G do es not have

Dividing G into triconnected comp onents is more

an upward plane drawing strongly equivalentto|ora

complicated, b ecause the cut-set vertices imp ose restric-

vertex ordering satisfying De nition 3.1|evidence (by

tive structure on the merged graph. In the biconnected

Prop osition 3.1) that G has an upward plane drawing

case, it is sucient to simply test each comp onent sep-

strongly equivalentto. The correctness pro of for

arately, since biconnected comp onents do not interact

the algorithm will provide a new pro of of Thomassen's

in the combined drawing; this is not the case for tri-

theorem.

connected comp onents, as illustrated by the two exam-

The algorithm is recursive, and the pro of that it

ples in Figure 2. (Recall our convention that direction

works is by induction. If there is a sink v on the outer

arrow-heads are assumed to b e \upward" unless other-

face of , give it the number n, and recurse on Gnv

wise sp eci ed.) In (a), the union of the graphs is upward

with resp ect to the induced plane drawing nv . By

planar, but adding the edge (u; v )toeach makes the sec-

induction we will nd an upward planar representation

ond comp onent non-upward-planar. In (b), the graph

of Gnv augmenting nv , or a violating cycle for Gnv .In

is non-upward-planar, but each of the comp onents is

the rst case we get the required ordering for G;andin

upward planar with (u; v ) added.

the second case we get a violating cycle for G.

It remains to deal with the case when the outer

face of has no sink. We claim that in this case G

v v

has a violating cycle: If the outer face of is a cycle

then it is a violating cycle. If the outer face is a walk,

then follow it starting at s, and let v b e the rst vertex

which rep eats. Vertex v must b e a cut vertex. Consider

the segment of the walk from v to v . If this segment

(a)

contains only one other vertex, say u, then u isasink,

u u

contradiction. Otherwise we obtain a cycle C from v to

v . The two edges incident with v must b e directed away

from v , and thus C is a violating cycle.

v

v

5 Separation into Tri-Connected Comp onents

The algorithm of Section 4 tests for upward planarity

of a single-source DAG G starting from a given planar

representation and outer face of G. In principle, we

(b)

could apply this test to all planar representations of G,

u

u

but this would takeexponential time. In order to avoid

this, we will decomp ose the graph into biconnected and

Figure 2: Added complication of 2-vertex cut-sets.

then into triconnected comp onents. Each triconnected

comp onent has a unique planar representation (see [1]),

We will nd it convenient, particularly for the case

and only a linear numb er of p ossible outer faces. We

where the source s is in a separation pair, to split the

can thus test upward planarity of the triconnected

graph into exactly two pieces at separation pairs.

comp onents in quadratic time using the algorithm of

There are two main issues. Firstly,wemust iden-

Section 4. Since we will p erform the splitting and

tify which comp onent will b e the \outer" comp onent,

merging of triconnected comp onents in quadratic time,

b ecause this imp oses restrictions on the other (\inner"

the total time will then b e quadratic.

comp onent) to adapt to its facial structure (in order to

To decomp ose G into biconnected comp onents we

b e injected within a face). It will always b e true that

use:

the inner comp onentwillhave more restrictions up on

Lemma 5.1. ADAG G with a single source s

its emb edding, b ecause it must t within the prescrib ed

Upward Planar Drawing of Digraphs 5

face. Sp eci cally, a list of vertices will b e required to b e vertices of attachment as source, sink or neither, as

on the outer face of anyemb edding to retain planarity appropriate for the particular op eration.

in the merge. Secondly,wemust b e able to prop erly Due to space constraints, wehave not included the

represent the facial structures of the twocomponents to pro ofs of the rst and third cases, when u and v are

ensure that the recursively calculated emb eddings can incomparable, and when u = s resp ectively. The second

b e merged without destroying upward planarity. case, u

Our general subproblem instance consists of a bi- required, so we attempt to provide some detail. For full

connected graph G, and a set of vertices X = fx g pro ofs see [8] or [9].

i

V (G) which will b e required to b e on the outer face

of any planar emb edding of G. G is broken up into 5.1 Cut-set fu; v g; u and v are incomparable.

two comp onents at a cut-set fu; v g, and recursive calls

Theorem 5.1. Let G bea biconnected directed

made. We will give conditions based on the typ e of cut-

acyclic graph with a single source s and let X = fx g

i

set involved as to whether upward plane drawings of

V (G) beasetofvertices. Let fu; v g be a separation pair

the two comp onents can b e put back together into an

of G, with u and v incomparable. Let S be the connected

upward plane drawing of the whole. These conditions

component of G with respect to fu; v g containing s,and

are broken into three cases: where u and v are incom-

H be the union of al l other components. Then, G ad-

parable; where u and v are comparable with u 6= s (i.e.

mits an upward plane drawing with al l vertices of X on

s

the outer face if and only if

0

The conditions prescrib ed will b e in the form of

(i) S = S [ M admits an upward plane drawing

t

markers added to each comp onent to representthe

with al l vertices of X in S on the outer face, and

shap e of the other comp onent in the decomp osition.

w on the outer faceifsomex 2 X is containedin

t

If the graph were undirected, it would b e sucient

H .

0

to add a single edge b etween the cut vertices in each

(ii) H = H [ M admits an upward plane drawing

s

comp onent, b ecause the only requirementwould b e that

with al l vertices of X in H on the outer face.

the vertices share a face. Wewould also not need to

require anyvertices to b e on the outer face, b ecause

5.2 Cut-set fu; v g, where u< v, u 6= s.

any face can b e made the outer face. This is not true

Here we consider any other vertex cut-sets not involving

for upward planarity. The typ e of markers needed will

the source s.We divide the graph at a vertex cut fu; v g

dep end on the particular graph.

into two subgraphs|the sourcecomponent S (the one

The markers are necessary for three reasons: rstly,

comp onent whichcontains the source s), and the union

to ensure that the original graph is upward planar i

of the remaining comp onents H . Note that v can b e a

the two comp onents (with markers) are upward planar;

source in S , as long as there is a u; v path in H .

secondly,tomaintain biconnectedness; and thirdly,to

In this section wewillgive the full pro of. First we

maintain the single source prop erty. The markers we

need some preliminary results:

will b e interested in are shown in Figure 3.

Proposition 5.1. If G is a connectedDAGwith

exactly two sources u and v , then there exists some u v w v w

t t

w such that two vertex disjoint (except at w ) directed

t t

v

+ +

paths u ! w and v ! w exist in G.

t t

Proof. Let G b e suchaDAG and let P be an

undirected path from u to v . Note that every x in

u

w u v u

s

P is comparable with either u or v , otherwise G has

more than two sources. Follow P from u to the rst

(a) M (b) M (c) M (d) M

s t uv uv t

no de x (following y on P ) incomparable with u (in G).

Figure 3: Marker Graphs.

Then x is comparable with v and (x; y )isanedgein

G (otherwise u< x), so y is also comparable with v .

An imp ortant note to make at this time is that

+

Taking the rst common vertex in the paths u ! y and

the markers, except for M , are subgraphs attached

uv

+

v ! y gives w .

t

at only twovertices, which means that fu; v g will still

constitute a cut-set. For the purp oses of determining The following results show the existence of lower

cut-sets, and making recursive calls, the markers should b ounds and upp er b ounds (in the partial order corre-

b e treated as distinguished edges|a single edge lab elled sp onding to G) under certain conditions. This allows

to indicate its role. As long as the typ e of marker us to prove the necessity conditions in Theorem 5.2 (to

is identi ed, the algorithm can continue to treat the come).

Upward Planar Drawing of Digraphs 6

Lemma 5.2. If G is a biconnectedDAG with a faceand w (if it exists, otherwise the edge (u; v ))

t

single sources,and u and v areincomparable vertices on the outer faceifsomex 2 X is containedinH .

0

in G, then there exists some w such that two vertex (ii) H =(H [ S -marker) admits an upward plane

s

+ +

drawing with w (if it exists, otherwise the edge

t

disjoint (except at w )directedpaths w ! u and w ! v

s s s

(u; v )) and al l vertices of X in H on the outer face.

exist in G.Iffu; v g is a cut-set in G, then therealso

where

exists some w such that two vertex disjoint (except at

t

+ +

8

w ) directedpaths u ! w and v ! w exist in G.

t t t

M if v is a sourceinH

<

t

Proof. Since G is a single source digraph, there exist

M if v is a sink in H

H -marker =

uv

:

directed paths from s to u and s to v in G.Taking the

M otherwise.

uv t

last common vertex in these paths gives w .

s

and

For the existence of w ,let u and v b e an incompa-

t



rable separation pair of G. Since fu; v g cuts G into at

M if v is a sourceinS

t

least two connected comp onents, any non-source com-

S -marker =

M otherwise.

uv

p onent H has u and v as its (exactly) two sources, and

the result follows from Prop osition 5.1.

Proof. (Necessity) Supp ose G admits an upward

Lemma 5.3. If G is a biconnectedDAG with a

plane drawing with all x 2 X on the outer face.

i

single source s and cut-set fu; v g, where u< v in G

(Necessity of condition (i)): If v is a source in H ,

and u 6= s, then in any non-sourcecomponent H of G

then there exists some w in H and vertex disjoint paths

t

+

+ +

0

with respect to fu; v g, where deg v>0,there exists

u ! w and v ! w by Prop osition 5.1; so S = S [ M is

t t t

+ +

some w such that u ! w and v ! w are vertex disjoint

homeomorphic to a subgraph of G andisupward planar.

t t t

directedpaths in H .

If v is a sink in H ,then u is the single source of H ,as

only u and v are p ossible sources. Thus, in H ,there

Proof. No vertex other than u and v can b e a source

+

0

is a path u ! v ,soS = S [ M is homeomorphic to

in H , otherwise G has more than one source. u is always

uv

a subgraph of G and is upward planar. If v is neither

a source in H , otherwise G contains a directed cycle. If

a source nor a sink in H then, by Lemma 5.3, there is

v is also a source, then we are done by Prop osition 5.1.

+

If v is not a source, let w 2 H be a vertex dominated

also some w >v and disjoint directed paths u ! w

t t

+

by v . G is biconnected, so there are twovertex disjoint

and v ! w in G.Sincev is a non-source in H ,there

t

+

+

u ! w undirected paths in G. But u and v are

is also a u ! v path in H . This path crosses the

+

cut-vertices in G, so at least one of the paths P lies

u ! w path at some latest vertex z on that path, so

t

completely within H and do es not contain v (as w is in

 + + +

S [ (u ! z ) [ (z ! v ) [ (z ! w ) [ (v ! w ) is a subgraph

t t

H and the only exit p oints from H are u and v ). Every

of G and hence upward planar. Note that these four

x on P is comparable with either u or v ,orelseG has

paths are disjoint. Since z has in-degree one we can

more than one source. Find the last vertex y on P which



contract the u ! z path to u without destroying upward

+

has a u ! y path (in G) without v .Ify = w ,thenwe

planarity,by Lemma 3.1, so S [f(u; v ); (u; w ); (v; w )g

t t

are done. Otherwise, the vertex x following y on P has

has an upward planar sub division and is upward planar

+

any u ! x path necessarily going through v . Then there

itself. No other vertices of this graph can lie inside the

+ +

exist directed paths v ! x, u ! x with the latter not

u; v ; w triangle, as s

t

containing v so the last common vertex on these paths

triangle) and there are no other (u; v ) comp onents in

0

provides a w .

S (as wechose S to b e the single source comp onent),

t

so the extra edges and vertex for M can b e added

We are now ready to pro ceed with the statementof

uv t

2

without destroying planarity .

the main result of the decomp osition.

(Necessity of condition (ii)): If v is a source in S ,

Theorem 5.2. Let G be a biconnecteddirected

then, by Prop osition 5.1, there are vertex disjoint paths

acyclic graph with a single source s, and let X = fx g

i

+ + +

s ! w and v ! w in S . There must b e an s ! u

V (G) be a set of vertices. Let fu; v g be a separation pair

t t

path in S , otherwise there is either a second source (u

of G with u

is a source in H , so it cannot also b e a source in S )ora

component of G with respect to fu; v g and H bethe

+

union of al l other components. Then, G admits an up-

cycle in G (u< v in G, so there can b e no v ! u directed

ward plane drawing with al l vertices of X on the outer

path in S ). Let z b e the last vertex common to paths

face if and only if

0

2

(i) S =(S [ H -marker) admits an upwardplane

The p oint of adding these edges is to x the face in S for the

suciency conditions. drawing with al l vertices of X in S on the outer

Upward Planar Drawing of Digraphs 7

+ +

s ! u and s ! w . Then, H [f(z; u); (z; w ); (v; w )g is

t t t

0

homeomorphic to a subgraph of G and is upward planar.

H

Since deg u = 1 (in this graph), the edge (z; u)can

0

S

w

be contracted without destroying upward planarity,by

t

0

Lemma 3.1, and H = H [ M is upward planar.

t

Otherwise (v a non-source), if u< v in S ,then

0

H = H [ M is homeomorphic to a subgraph of G and,

v

uv v

hence, is upward planar. If u and v are incomparable in

u

S , then they share a greatest lower b ound w ,byLemma

s

5.2, and H [f(w ;u); (w ;v)g is upward planar. Again,

s s

u

deg u =1 in H ,sothe(w ;u) edge can b e contracted

s

(a) v a source in H

0

to give H = H [ M .

uv

The necessity of the outer facial conditions on the 0

v S

0

x 's can also b e shown.

i

H

0 0

v

(Suciency) Supp ose S and H admit upward

plane drawings meeting the requirements (i)and(ii).

Case 1: v is a source in H :Ifv is a source in H it

cannot at the same time b e a source in S ,asu

u

0

either S or H .Thus H = H [ (u; v )isupward planar

u

0

with single source u. Using Lemma 3.2, add H (with u

0 0 0 0

(b) v a sink in H , non-source in S

and v renamed as u and v )toS , identifying u with

0

w .We can do this so that edges (v; w ) and (w ;v ) are

t t t

w

0

t

0

v S

H

consecutive in the cyclic order ab out w . Using Lemma

t

3.4, split w by making these two edges incident with a v

t

new vertex u and the remaining edges incident with a

1

new vertex u .Now v and u have in-degree 1, so use

2 1

Lemma 3.1 to contract their in-edges, thus identifying

u

0

v and v .Vertex u has in-degree 1 so contract (u; u ).

2 2

The result is the graph G, and thus G is upward planar.

See Figure 4(a).

u

Case 2: v is a sink in H :Ifv is a non-source in S ,

(c) v asinkinH , source in S

0

then H = H [ (u; v )isupward planar with u and v on

w

t

the outer face by assumption. If v is a source in S ,then

0

0

0

H

H = H [ M is upward planar with w on the outer

S

t t

v

face. In either case H is upward planar with source u

v

and sink v on the outer face. By Lemma 3.3 wecan

0 0

add H to S in place of the (u; v )edgeinS , and the

result, G,isupward planar. The two p ossibilities are

illustrated in Figure 4 (b) and (c).

u

Case 3: v is a non-source/sink in H : Supp ose v is

u

0

a source in S .ThenH = H [ M is upward planar with

t

(d) v a non-source/sink in H , source in S

the sink w on the outer face. Using Lemma 3.3, add

t

0 0 0 0

H (renaming u and v to u and v resp ectively) to S

0

H

0

0

in place of the edge (u; v ), identifying u with u and w

t

S

v w

t

with v . Throwaway the edge (u; w ) and the remaining

t

0

marker edges of S .Vertex v now has in-degree 1 so the

v

0

edge (v ;v) can b e contracted by Lemma 3.1, and the

result, G,isupward planar. See Figure 4(d).

u

Supp ose then that v is a non-source in S . Consider

u

0

a plane representation of S and throwaway the marker

(e) v a non-source/sink in H , non-source in S

edges, savefor(u; w ); (v; w ); (u; v ), which then form a

t t

0

face. H = H [ (u; v )isupward planar with u and v

Figure 4: Merging S and H ; cut-set fu; v g and u< v.

on the outer face. Let z b e some sink on the outer face,

Upward Planar Drawing of Digraphs 8

00

and add the edge (v; z )toobtainH ,upward planar drawing with al l vertices of X in F on the outer

with u; v ; z on the outer face. Using Lemma 3.3, add face, and w (if it exists, otherwise the edge (u; v ))

t

00 0 0 0

H (with u and v renamed to u and v )toS in place also on the outer face if some x 2 X containedin

0

of the edge (u; w ), identifying u with u and z with E .

t

0 0

w . Do this so that v and v share the face of edges (ii) E =(E [ F -marker) admits an upward plane

t

0 0

(u; v ); (v ;z); (u; v ); (v; z ). Clearly wecannowidentify drawing with w (if it exists, otherwise the edge

t

0

the vertices v and v .We obtain an upward planar graph (u; v )) and al l vertices of X in E on the outer face,

containing G as a subgraph. See Figure 4(e). where

8

It can b e shown that the conditions on the x 's,

i

M if v is a sourceinE

<

t

when they arise, are also sucient.

M if v is a sink in E

E -marker =

uv

:

M otherwise.

uv t

5.3 Cut-set fs; v g.

As mentioned in the intro duction to this chapter, it is

and

imp ortant to b e able to distinguish the \inner" and



\outer" comp onents. The inner comp onent will b e

M if v is a sourceinF

t

F -marker =

emb edded in a face of the outer one, and thus the inner

M otherwise.

uv

comp onent will havetohave its marker on its outer face

Proof. Similar to that of Theorem 5.2. since this marker is a proxy for the outer comp onent. If

wehavetocheckeach comp onent as a p otential inner

Theorem 5.4. Let G be a biconnectedDAGwith

comp onent, wemust recursively solvetwo subproblems

a single source s and let X = fx g V (G) be a set

i

for each comp onent, and an exp onential time blowup

of vertices. Let fu; v g bea separation pair of G where

results.

u = s, E be a 3-connectedcomponent of G with respect

Until now, the outer comp onent has b een uniquely

to fu; v g, and F be the union of al l other components of

identi ed as the sourcecomponent, since that comp o-

G with respect to fu; v g.IfE does not admit an upward

nent cannot lie within an internal face of any other com-

plane drawing with u and v on the outer face, then G

p onent. If wehave a cut-set of the form fs; v g where s

admits an upward plane drawing with al l vertices of X

is the source, then we lose this restriction, so we handle

on the outer face if and only if

it instead by requiring one of the comp onents, E ,tobe

(i) Thereisnox 2 X containedinF .

3-connected so that deciding if it can b e the inner face

0

(ii) F =(F [ E -marker) admits an upward plane

do es not require recursive calls. To decide if E can b e

drawing with w (if it exists, otherwise the edge

t

the inner face we need to test if it is upward planar with

(u; v )) also on the outer face if some x 2 X is

s; v on the outer face. This can b e done in linear time

containedinE .

using the algorithm of Section 4. If G has only cut-sets

0

(iii) E =(E [ F -marker) admits an upward plane

of the form fs; v g, then, for at least one such cut-set,

drawing with al l x 2 X on the outer face,

one of the comp onents will b e triconnected. Given the

where

list of cut-sets we can nd such a cut-set and sucha

8

M if v is a sourceinE

<

comp onent in linear time using depth- rst search.

t

E -marker = M if v is a sink in E

We capture these ideas in terms of two theorems.

uv

:

M otherwise.

One is applicable if the triconnected comp onentcanbe

uv

the inner comp onent, and one if it cannot. Note that

and

in the statement of these theorems, we continue to use

8

u (redundant since u = s) for consistency with previous

M if v is a sourceinF

<

t

usage.

F -marker = M if v is a sink in F

uv

:

Theorem 5.3. Let G be a biconnectedDAGwith

M otherwise.

uv t

a single source s, and let X = fx g V (G) beaset

i

of vertices. Let fu; v g bea separation pair of G where Proof. (outline) Since E has no upward plane draw-

u = s, E bea 3-connectedcomponent of G with respect ing with s and v b oth on the outer face, the only way G

to fu; v g, and F be the union of al l other components of could b e upward planar is if F canbeemb edded within

G with respect to fu; v g.IfE admits an upwardplane afaceofE .Thus, the outer face of G is xed as b e-

0

drawing with u and v on the outer face, then G admits ing some face of the drawing of E not containing v .It

an upward plane drawing with al l vertices of X on the remains to ensure that there is some emb edding of F

outer face if and only if which will t the structural constraints of the shap e of

0

(i) F =(F [ E -marker) admits an upwardplane a face shared by s and v in the drawing of E .These

Upward Planar Drawing of Digraphs 9

[6] J. Hopcroft and R. Tarjan. Ecient planarity are exactly the conditions previously required by E for

testing.J.ACM 21,4, pp. 549-568, 1974.

emb edding within the drawing of F . The remainder of

[7] J. Hopcroft and R. Tarjan. Dividing a graph into

the pro of do es not rely on the triconnectedness of either

triconnectedcomponents. SIAM J. Comput. 2, pp. 135-

comp onent, and is similar to the pro of of Theorem 5.3.

158, 1972.

[8] M. D. Hutton. Upward planar drawing of single

6 Conclusions and Further Work

source acyclic digraphs. Masters Thesis, Universityof

Waterlo o, Sept. 1990.

Wehavegiven a linear time algorithm to test whether

[9] M. D. Hutton and A. Lubiw. Upward planar draw-

a given single-source digraph has an upward plane

ing of single source acyclic digraphs. In preparation.

drawing strongly equivalenttoagiven plane drawing,

[10] D. Kelly. Fundamentals of planar ordered sets. Dis-

and give a representation for this drawing if it exists.

crete Math 63, pp. 197-216, 1987.

2

Wehave used this result to outline an ecient O (n )

[11] D. Kelly and I. Rival. Planar lattices. Can. J. Math.,

algorithm to test upward planarity of a single-source

Vol 27, No. 3, pp. 636-665, 1975.

digraph.

[12] C. R. Platt. Planar lattices and planar graphs.J.

Alower b ound for the single-source upward pla-

Comb. Theory (B) 21, pp. 30-39, 1976.

narity problem is not known, although we b elievethat

[13] R. Tamassia and P. Eades. Algorithms for drawing

it may b e p ossible to p erform the entire test in sub-

graphs: an annotated bibliography.Brown University

quadratic (p erhaps linear) time. An obvious extension

TR CS-89-09, 1989.

[14] C. Thomassen. Planar acyclic orientedgraphs. Order

of this work would b e to nd such an algorithm or prove

5, pp. 349-361, 1989.

alower b ound.

[15] W. T. Tutte. Convex representations of graphs. Pro c.

This pap er has concentrated on the issues of e-

London Math. So c. Vol.10, pp. 304-320, 1960.

ciently testing for an upward plane drawing and out-

putting an abstract representation of suchadrawing.

Using the representation it is easy to add edges to the

graph to get a planar s-t graph. Then an upward plane

drawing can b e obtained from the algorithm of DiBat-

tista and Tamassia in O (n log n) arithmetic steps [2].

However, DiBattista, Tamassia and Tollis haveshown

that there exist upward planar graphs which require an

exp onential sized integer grid [3] so the algorithm is ac-

tually output sensitive, and hence exp onential in the

worst case. It would b e interesting to characterize some

classes of digraphs which p ermit upward plane drawings

on a p olynomially sized grid. Guaranteeing minimum

in all cases is, however, NP-hard [13].

The more general problem of testing upward pla-

narity of an arbitrary acyclic digraph is op en. The only

known characterization is that anysuch graph is a sub-

graph of a planar s-t graph [2].

References

[1] J. A. Bondy and U. S. R. Murty. Graph Theory

with Applications. MacMillia n Co. New York, 1976.

[2] G. DiBattista and R. Tamassia. Algorithms for

plane representations of acyclic digraphs. Theoretical

Computer Science 61, pp. 175-178, 1988.

[3] G. DiBattista, R. Tamassia and I. G. Tollis. Area

requirement and symmetry display in drawing graphs.

Pro c. ACM Symp osium on Computational Geometry,

pp. 51-60, 1989.



[4] I. Fary. On straight line representations of planar

graphs. Acta. Sci. Math. Szeged 11, pp. 229-233, 1948.

[5] I. S. Filotti, G. L. Miller, J. Reif. On determining

O (g )

the genus of a graph in O (v ) steps, Pro c. 11th ACM Symp. on Theory of Computing, 1979, pp. 27-37.