<<

Upward Planar Drawing

of Single Source Acyclic Digraphs

by

Michael D. Hutton

A thesis

presented to the UniversityofWaterlo o

in ful lmentofthe

thesis requirement for the degree of

Master of Mathematics

in

Computer Science

Waterlo o, Ontario, Canada, 1990

c

Michael D. Hutton 1990 ii

I hereby declare that I am the sole author of this thesis.

I authorize the UniversityofWaterlo o to lend this thesis to other institutions

or individuals for the purp ose of scholarly research.

I further authorize the UniversityofWaterlo o to repro duce this thesis by pho-

to copying or by other means, in total or in part, at the request of other institutions

or individuals for the purp ose of scholarly research. ii

The UniversityofWaterlo o requires the signatures of all p ersons using or pho-

to copying this thesis. Please sign b elow, and give address and date. iii

Acknowledgements

The results of this thesis arise from joint researchwithmy sup ervisor, .

Anna also deserves credit for my initial interest in Algorithms and Graph Theory,

for her extra e ort to help me makemy deadlines, and for nancial supp ort from

her NSERC Op erating Grant.

Thanks also to NSERC for nancial supp ort, and to my readers Kelly Bo oth

and DerickWo o d for their valuable comments and suggestions. iv

Dedication

This thesis is dedicated to my parents, David and Barbara on the o ccasion of their

26'th wedding anniversary. Without their years of hard work, love, supp ort and

endless encouragement, it would not exist.

Michael David Hutton

August 29, 1990 v

Abstract

Aupward plane drawing of a is a straightlinedrawing in the

Euclidean plane such that all directed arcs p ointupwards. Thomassen [30] has given

a non-algorithmic, graph-theoretic characterization of those directed graphs with a

single source that admit an upward drawing. We present an ecient algorithm to

test whether a given single-source acyclic digraph has a plane upward drawing and,

if so, to nd a representation of one suchdrawing.

The algorithm decomp oses the graph into biconnected and triconnected comp o-

nents, and de nes conditions for merging the comp onents into an upward drawing

of the original graph. For the triconnected comp onents weprovide a linear algo-

rithm to test whether a given plane representation admits an upward drawing with

the same faces and outer face, whichalsogives a simpler (and algorithmic) pro of of

Thomassen's result. The entire testing algorithm (for general single source directed

2

acyclic graphs) op erates in O (n )timeand O (n) space. vi

Contents

1 Intro duction 1

2 Preliminaries 5

3 Related Results 10

3.1 Testing for Planarity of Graphs :::::::::::::::::::: 11

3.1.1 The Hop croft-Tarjan Algorithm : :: ::: :: :: :: :: :: 11

3.1.2 The Lemp el-Even-Cederbaum Algorithm ::::::::::: 12

3.2 Drawing Planar Graphs :::::::::::::::::::::::: 15

3.3 Testing for Upward Planarity ::::::::::::::::::::: 16

3.4 Drawing Upward Planar Graphs :::::::::::::::::::: 18

3.5 Graphs and Partially Ordered Sets : :: :: ::: :: :: :: :: :: 19

4 Strongly-EquivalentUpward Planarity 22

4.1 Implementation Details : ::: :: :: :: :: ::: :: :: :: :: :: 25

5 Separation into Bi-Connected Comp onents 28 vii

6 Separation into Tri-Connected Comp onents 30

6.1 Some Basic Results : :: ::: :: :: :: :: ::: :: :: :: :: :: 32

6.1.1 Facial Structure of Upward Planar Graphs :: :: :: :: :: 32

6.1.2 Prop erties of Cut Sets in Digraphs : ::: :: :: :: :: :: 33

6.1.3 Top ological Prop erties of Upward Planar Graphs :: :: :: 36

6.2 Marker Comp onents :: ::: :: :: :: :: ::: :: :: :: :: :: 39

6.3 The cut-set fu; v g,where u and v are incomparable ::::::::: 40

6.4 The cut-set fu; v g,where u< v, u 6= s : :: ::: :: :: :: :: :: 43

6.5 The cut-set fs; v g :: :: ::: :: :: :: :: ::: :: :: :: :: :: 48

7 An Algorithm for Upward Planar Emb edding 54

8 Drawing Upward Planar Graphs 59

9 Conclusions 60 viii

List of Figures

2.1 Upward planar and non-upward planar graphs. :: :: :: :: :: :: 9

3.1 st-numb erings of G (a) and G (b); bush-form B for G (c). :: :: 14

4 4 4

3.2 Bush form (a) and its asso ciated PQ-tree (b). :: :: :: :: :: :: 15

4.1 Cases for v in Algorithm S-E-UP-PLANAR. ::::::::::::: 27

G from its bi-connected comp onents :: :: :: :: 29 5.1 Construction of

6.1 Added complication of 2-vertex cut-sets. ::::::::::::::: 31

6.2 Facial structure in an upward plane drawing. ::::::::::::: 33

6.3 Transformations preserving upward planarity. :: :: :: :: :: :: 38

6.4 Marker Graphs. : :: :: ::: :: :: :: :: ::: :: :: :: :: :: 40

6.5 Merging of S and H when cut-set fu; v g is incomparable. :: :: :: 42

6.6 Merging of S and H with cut-set fu; v g and u

Chapter 1

Intro duction

There are a wide range of results dealing with drawing, representing, or testing

planarity of graphs. Fary [16] showed that every can b e drawn in

the plane using only straight lines for the edges. Tutte [33] showed that every

3-connected planar graph admits a convex straight-line drawing, where the facial

cycles other than the unb ounded face are all convex p olygons. The rst linear

time algorithm for testing planarityofagraphwas given by Hop croft and Tarjan

[18 ]. Planar graph layout has manyinteresting applications in automated circuit

design, for representation of network ow problems (e.g. PERT graphs in software

engineering [14]) and arti cial intelligence.

A upward plane drawing of an directed acyclic graph (DAG) is a straight line

drawing in the Euclidean plane such that all directed arcs p ointupwards (i.e. from

alower to a higher y -co ordinate). A DAGisupward planar if it has an upward plane

drawing. Kelly [20] and Kelly and Rival [21 ] haveshown that every upward plane

drawing with monotonic edges (each arc is drawn as a curve monotone increasing

in the y -direction) has a similar upward plane straightlinedrawing, an analogue 1

CHAPTER 1. INTRODUCTION 2

of Fary's result for general planar graphs. Thus, the straight line condition of the

upward planar de nition do es not restrict the class of upward planar graphs. We

will use this fact to simplify the discussion. The de nition of upward planar will b e

detailed in Chapter 2. In this thesis we will consider only single source DAGs. Ini-

tially we will b e concerned with constructing an abstract emb edding. This will then

b e extended to encompass a physical drawing algorithm. The di erence b etween

2

these terms will b e explained in Chapter 2. Our main result is an O (n ) algorithm

to test whether a given graph is upward planar, and if so, to give a representation

of an upward plane drawing for it. This result is based on a graph-theoretic result

of Thomassen [30 , Theorem 5.1]:

Theorem 1.1 (Thomassen) Let be a planar representation of a single source

0

DAG G. Then there exists an upward plane drawing strongly equivalent to (i.e.

having the same faces as) if and only if the source of G is on the outer faceof

, and for every cycle  in ,  has a vertex which has a directededge from each

of its two neighbours on , and which is not the tail of any directededge inside .

The terms of this theorem are de ned more precisely in Chapter 2. Intuitively,

for a graph G with planar emb eddedding , if some cycle  of has every vertex

which is on a directed edge from eachofitstwo neighb ours also having another

edge directed \into",thennovertex on  can b e the maximal vertex of , so

0

no drawing with the same faces as (i.e. containing  as a cycle) can b e an

upward plane drawing of G. So intuitively, Thomassen's condition is necessary.

The interesting part of the thero em is that the condition is also sucient for to

b e strongly equivalenttoanupward planar representation of G.

Thomassen notes that a 3-connected graph has a unique planar emb edding (up

to the choice of the outer face) and concludes that his theorem provides a \go o d

CHAPTER 1. INTRODUCTION 3

characterization" of 3-connected upward planar graphs. Neither a concrete time

b ound nor an ecient algorithm is, however, given, nor is a metho d for isolating

and joining 3-connected comp onents.

The problem thus decomp oses into two main issues. The rst is to describ e

Thomassen's result algorithmically; we do this in Chapter 4 with a linear time

algorithm, at the same time providing an alternative pro of of his theorem. The

second is to isolate the triconnected comp onents of the input graph, and determine

how to put the \pieces" back together after the emb edding of each is complete.

This more complex issue comprises the remainder of the thesis.

The algorithm for splitting the input into triconnected comp onents and merging

2

the emb eddings of each op erates in O (n )time. Since a triconnected graph is

uniquely emb eddable in the plane, up to the choice of the outer face, and the

numb er of p ossible external faces of a planar graph is linear by Euler's formula,

2

the overall time to test a given 3-connected comp onentisalso O (n ), so the entire

algorithm is quadratic.

The primary fo cus of this thesis is to test a single-source DAG for upward

planarity, and to generate an upward planar emb edding in the pro cess (whenever

p ossible). This pro cess can b e extended to a drawing algorithm by transforming

the emb edding for use bytheknown algorithm of DiBattista and Tamassia [10] to

draw single-source, single-sink planar DAGs. The main issue in this extension is

the size of the output of the drawing algorithm, whichwe will address in Chapter

3 and again in Chapter 7. Upward plane drawings can require an exp onential sized

co ordinate grid (a precise de nition is given in Chapter 3), so no algorithm can,

in general, output an upward plane drawing in time p olynomial in the size of the graph.

CHAPTER 1. INTRODUCTION 4

Chapter 4 discusses an algorithm for determining an upward planar representa-

tion for a 3-connected graph with a prescrib ed outer face. Chapters 5 and 6 discuss

the isolation of the comp onents of an input graph G, and merging of the (recursively

determined) comp onents into an upward planar emb edding. The combined test-

ing/emb edding algorithm is given in Chapter 7. The \abstract emb edding" output

by the algorithm of Chapter 7 is a representation of a particular memb er of the set

of p ossible drawings using the cyclic order of edges around eachvertex, and some

additional structural information, to identify the faces; this will b e de ned more

precisely in Chapter 2. Chapter 8 extends the previous result to the construction of

aphysical drawing from the abstract emb edding of Chapter 7 (i.e. giving Euclidean

co ordinates for the vertices).

Chapter 2

Prelimi nari es

For the most part we use the terminology and notation of Bondy and Murty [3],

supplemented by that of Thomassen [30].

A (combinatorial) graph G consists of a set of vertices or no des V and a set E

of pairs of vertices called edges connecting these vertices. Late lower case Roman

letters (e.g. u; v ; w ; x; y ) denote vertices unless otherwise stated, and early letters

(e.g. a; b; c; d; e) denote edges. A graph is directed,calleda digraph,ifeach edge

e =(u; v )is directed from the vertex u, called the tail of e,tothevertex v , called the

head of e, also denoted u ! v .Awalk W = v e v e v :::e v of G is an alternating

0 1 1 2 2 k k

sequence of (p ossibly rep eating) incidentvertices and edges of G.Apath in G is

an alternating sequence of distinct (except p ossibly for the rst and last vertex)

incidentvertices and edges; a path is hence a walk with no rep eating edges or

vertices, other than p ossibly v and v .Acycle C of a graph G is a exactly sucha

0 n

+

closed path (from one no de back to itself ), denoted u ! u. Analogously in a directed



graph, a directedpath is also denoted by u ! v , (connected through 0 or more edges)

+ k

! v (connected by 1 or more edges) or u ! v (connected by exactly k edges). or u 5

CHAPTER 2. PRELIMINARIES 6

+

A directed path u ! u is called a directed cycle. When the notation is ambiguous,

we sp eci cally state whether a path is directed or undirected. A directed graph is

acyclic if it contains no directed cycles (although the underlying undirected graph

maycontain cycles). A subgraph H of a graph G is a subset of the no des and edges

of G. Subgraph H is proper if it is not equal to G. G[H ] is the vertex-induced

subgraph of G | the vertices of H  G, and any edges of G connecting no des in

H .

A planar representation of a graph G, denoted by an upp er case Greek letter

suchasorby G, is an abstract emb edding (in terms of a data structure) in

the plane. We will describ e suchanemb edding in terms of a cyclic (counter-

clo ckwise) ordering of edges/vertices around eachvertex in the emb edding, and a

sp eci cation of which face is the outer face. An upward planar representation is

suchanemb edding, with an additional sp eci cation of the extra edges required to

makeithave no sinks other than on the outer face|to resolve the internal sinks.

This allows it to b e extended to a single-source, single-sink graph whichcanbe

drawn easily. A plane drawing is a physical realization of a planar emb edding;

where eachvertex is assigned a co ordinate p oint in the Euclidean plane, and each

edgeisancurve or arc b etween p oints in the plane; no two arcs intersect except at

incidentvertices on their endp oints. G is planar if it can b e represented by a plane

drawing . As mentioned in Chapter 1, if G has an upward plane drawing with

monotonic arcs as edges, it also has some upward plane drawing with straight line

arcs as edges. The latter is the de nition we use for upward plane, but as a result

of this equivalence we will ignore the straight line issue for the purp oses of testing

upward planarity, and address it as required for the upward drawing in Chapter

8. In a planar representation, the representation of a cycle which has no vertices

inside of it is called a face or facial cycle, and the outermost face (having no vertices

CHAPTER 2. PRELIMINARIES 7

outside of it, and all vertices of G inside or on it) is called the outer facial cycle.

Two representations of a graph G are equivalent if they haveidentical facial cycles,

and strongly equivalent if they are equivalent and have the same face identi ed as

the outer face.

Wesaythatadrawing of G is oriented if a direction (in the Euclidian plane)

is imp osed up on the directed arcs representing the edges of G.For our purp oses,

this means that all directed arcs must b e monotonic upward (p ositiveinthe y

direction), i.e. upward plane. Unless otherwise stated, all gures in the thesis are

drawn using this convention, so arrow heads will often b e omitted from the graph

edges. A representation of G is convex if all facial cycles of are convex p olygons.

A digraph G is connected if there exists an undirected path b etween anytwo

vertices. Gnv  G[V fv g] denotes G with v and all edges incidentto v in

G removed. G is k -connected if the removal of at least k vertices is required to

disconnect the graph. An equivalent de nition (by Menger's Theorem [3]) would

b e to say G is k -connected if and only if there exist k vertex-disjoint undirected

paths b etween anytwovertices. A set of vertices whose removal disconnects the

graph is a cut-set.Acut vertex and separation pair denote cut-sets of size one and

two resp ectively. A graph which has no cut vertex is biconnected (2-connected). A

graph with no separation pair is triconnected (3-connected). For G with cut vertex

v ,acomponent of G with resp ect to v is formed from a connected comp onent H

of Gnv by adding to H the vertex v and all edges b etween v and H .For G with

separation pair fu; v g,acomponent of G with resp ect to fu; v g is formed from a

connected comp onent H of Gnfu; v g G[V fu; v g]by adding to H, u; v and all

edges b etween u; v and vertices of H . The edge (u; v ), if it exists, forms a comp onent

by itself. If S is a cut-set, then the vertices of attachment of a comp onent H of GnS

are those vertices in H which share an edge with some vertex of S in the graph

CHAPTER 2. PRELIMINARIES 8

1

G. An algorithm for nding tri-connected comp onents in linear time is given in

Hop croft and Tarjan [19 ]. A related concept is that of graph union. We de ne

G [ G , for comp onents with \shared" vertices to b e the inclusive union of all

1 2

vertices and edges. That is, for v in b oth G and G ,thevertex v in G [ G is

1 2 1 2

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

1 2

0

Contracting an edge e =(u; v ), denoted G=e, results in a graph G with the edge

0

e removed, and vertices u and v identi ed (as the same vertex in G ). Inserting

new vertices within edges of G generates a subdivision of G.Adirectedsubdivision

(of a digraph) is a sub division within directed edges (i.e. (u; v ) can b e sub divided

into (u; w ); (w; v ), but not (u; w ); (v; w)). G and G are homeomorphic if b oth are

1 2

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

G is planar [3].

In a directed graph, the in-degree of a vertex v is the numb er of edges directed

+

towards v , denoted deg v . Analogously the out-degree (deg v )of v is the number

of edges directed away from v .Avertex of in-degree 0 is a source in G,anda vertex

of out-degree 0 is a sink.

Directed/oriented graphs are often used to represent partially ordered sets (posets);

+

in particular, a corresponding digraph G of a p oset P has an directed path u ! v

in G if and only if u

9w j(u; w ) and (w; v ) 2 G), then the drawing of G is called a . The

problem of drawing plane Hasse diagrams is equivalent to the problem of drawing

general DAGs, since sub dividing everyedgeofaDAG pro duces a corresp onding

graph with no transitive edges.

Adopting some p oset notation: twovertices u; v are comparable if there is a

1

Note that Hop croft and Tarjan's \comp onents" include an extra (u; v ) edge.

CHAPTER 2. PRELIMINARIES 9

 

directed path u ! v (u

often use u

is an edge in the digraph of P , then u dominates v .

Figure 2.1 shows two drawings of upward planar and non-upward planar graphs.

The rst is a drawingofanupward planar graph. The second is planar, but non-

upward planar, since placing v inside the face f would eliminate crossing, but

require a downward edge. Recall our convention that edges are directed upward

unless otherwise stated.

v

f

Upward planar Non-upward-planar

Figure 2.1: Upward planar and non-upward planar graphs.

Chapter 3

Related Results

The problem of drawing a graph on a two dimensional surface has many di erent

applications. The most obvious are in circuit design/layout, and VLSI, esp ecially

in the of automated to ols to realize schematics of an abstract circuit. Other

applications are to software engineering and information analysis (PERT diagrams,

subroutine-call charts, data- ow diagrams); databases (entity relationship graphs);

and knowledge representation (ISA hierarchies and neural networks).

The (algorithmic) problem of was broughtinto the op en after

twopapersbyTutte, on convex (and hence straight-line, except p ossibly for the

edges on the outer face) drawings of graphs [33], and graph drawing in general

[34 ]. Continuing Tutte's results on convex graphs, Thomassen [31] has presented

inductive criteria for the existence of a convex representation of a graph in the plane.

This was implemented as a linear time algorithm by Chiba et al [5]. These are

signi cant to the topic at hand b ecause they provide much of the graph-theoretical

background evidentintheworks which followed.

For general graphs, the problem of a \go o d" presentation is neither solved nor 10

CHAPTER 3. RELATED RESULTS 11

even clearly de ned. Since no obvious set of concrete requirements is known for

drawing a graph to easily p ortray its meaning to the (human) reader, work thus

far has b een in exploring various arbitrary aesthetics: minimum line crossings;

minimum area on some grid or set of p oints; preference for p olygonal lines, minimum

b ends within these, or straight lines; curves which are monotonic in some direction;

and isolation and display of symmetry in automorphisms or near automorphisms.

Many of these aesthetics have either b een proven NP-hard to determine or display,

or their complexity remains op en. Some aesthetics are con icting when applied in

tandem.

Of esp ecial interest is the sub-area of drawing planar graphs. For schematics it

is often necessary to have a planar realization of a circuit, as wires cannot cross. For

other applications, it is desirable to present a graph as planar whenever p ossible.

Thus algorithms for testing planarity, and op erating up on planar graphs have b een

heavily studied.

For a (continuing) bibliographic survey of the eld of graph drawing, including

a list of aesthetics (\graphic standards") and complexity results on their represen-

tation, see Tomassia and Eades' \Annotated Bibliography" [29].

3.1 Testing for Planarity of Graphs

3.1.1 The Hop croft-Tarjan Algorithm

The rst linear time planarity testing algorithm is due to Hop croft and Tarjan [18].

This algorithm rst isolates the biconnected comp onents of the graph, which are

easy to put together after each is separately tested.

CHAPTER 3. RELATED RESULTS 12

The op eration on the biconnected comp onents is a path addition algorithm: A

depth rst search is p erformed to order the graph into a tree-like structure with

tree-edges and non-tree-edges or fronds|called a palm tree. A simple k -circuit is

chosen to contain k 1 tree edges, and one frond. The set of paths generated by

the deletion of the cycle from G are then added to the cycle, one path at a time,

generating G.

The paths have to b e added either on the left or right of the tree-edge path of the

k -circuit, so two stacks are used to record the relevant information, and comp onents

are ipp ed back and forth b etween the two stacks (a non-trivial pro cess) as added

paths require. This pro cess continues until all paths are added or a path cannot b e

added.

3.1.2 The Lemp el-Even-Cederbaum Algorithm

One comp eting planarity algorithm is a vertex addition algorithm due to Lemp el,

Even and Cederbaum [22 ]. The original version required O (jV j jE j) time. This is

2

exactly O (n ) time, under the observation that a planar graph has no more than a

linear numb er of edges (Euler's formula, [3]), and the further assumption that the

graph is connected (requiring at least n 1 edges). The algorithm can, however,

b e mo di ed to run in linear time, and is more attractive to our discussion b ecause

it also has application to the drawing of upward planar graphs.

The Lemp el, Even and Cederbaum algorithm is divided into two main phases.

The rst is to compute an st-numbering of the graph, which can b e realized in

linear time due to a result of Even and Tarjan [15 ]. The second phase applies the

st-numb ering to the vertex-addition algorithm, using the PQ-tree data structure of

Bo oth and Lueker [4] to achieve the emb edding in linear time.

CHAPTER 3. RELATED RESULTS 13

De nition 3.1 An st-numbering is a numbering 1 :::n of the vertices of a bi-

connectedgraph G such that two distinguished vertices s and t arenumbered 1 and

n respectively, and for any other vertex j , there exist adjacent (to j ) vertices, i and

k , such that i

Such an ordering can b e imp osed on any biconnected undirected graph (Lemp el,

Even and Cederaum) [22] and can b e found in linear time (Even and Tarjan) [15].

We notice that an st-numb ering of a graph G identi es s as the single source of

G,andt as the single sink of G (directing edges from smaller to bigger numb ers).

In fact, the following is a more general indication of its usefulness:

Lemma 3.2 [Lemp el, Even and Cederbaum] Let 1  k  n.Ifedge (s; t) is drawn

on the boundary of the outer face in an embedding G of G, then al l the vertices and

G of G, where edges of G G aredrawn in the outer face of the plane subgraph

k k

G is the subgraph induced by the vertices 1 :::k of the st-numbering of G.

k

We can use this ordering to e ect an emb edding of G: De ne virtual edges

as edges b etween vertices of G and vertices of G G ,andvirtual vertices as

k k

endp ointvertices of virtual edges in G G . The virtual vertices are lab elled as

k

their corresp onding p oints in G G ,butkept separate. For example, Figure 3.1

k

shows a graph G lab eled with an st-numb ering, the subgraph G of G, and a bush

4

form (to b e de ned shortly) which illustrates the (multiple) virtual vertices for the

actual vertices numb ered 5 and 6 in the bush form for G . Notice that the problem

4

of nding a planar emb edding of G consists of mapping all sets of identically

6

lab eled virtual vertices (sets f5 g and f6 g in the example) of the bush form of G

i i 4

to one single p oint(points 5 and 6 in the example) in the emb edding. Thus to nd

an emb edding of G,we rst nd a planar emb edding of some G (l

CHAPTER 3. RELATED RESULTS 14

Lemp el-Even-Cederbaum theorem (ab ove), all vertices and edges of G G are

k l

in the outer face of the emb edding G , so the general step reduces to nding such

l

a mapping of the corresp onding virtual vertices fig to a common actual vertex i.

This is accomplished using a data structure called a PQ-tree.

De nition 3.3 A PQ-tree is a data structure with three di erent types of nodes,

P nodes whose children's order can bepermuted arbitrarily, Q nodes whose children

can bere ected only, and leaves.

1

t =6

5

2

4

3

4 3

3

4

2

2

1

5 6 6 5 5 6

1 1 2 2 3 3

s =1

(a) (b) (c)

Figure 3.1: st-numb erings of G (a) and G (b); bush-form B for G (c).

4 4 4

The main idea is to build a PQ-tree for the emb edding: P no des represent

cut-vertices of the embedding thus far (comp onents of cut-no des can b e p ermuted

in any order around the cut-vertex); Q no des represent 3-connected comp onents

(which can only b e re ected around their separation pairs), and leaves represent

virtual vertices. A bush form is an emb edding of such a graph with all the virtual

vertices on the outer face, as shown in Figure 3.1(a). Every planar graph G has

a bush form for each G ,1  k  n [4]. The algorithm of Bo oth and Lueker

k

[4] (in addition to de ning PQ-trees) determines the p ermutations and re ections

CHAPTER 3. RELATED RESULTS 15

required to get all like-lab elled vertices adjacent at the leaves of the structure so

that they can b e combined into one no de without crossing no des in the embed-

ding. The emb edding/testing thus consists of successively constructing bush forms

B ;B ; ;B , and p erforming p ermutations on eachtocombine virtual vertices

1 2 n

into single \real" vertices. An example of a bush form and its PQ-tree is given in

Figure 3.2. Note that P-no des are denoted by circles, Q-no des by rectangles, and

leaf no des (virtual vertices) are unmarked.

(a) (b)

Figure 3.2: Bush form (a) and its asso ciated PQ-tree (b).

3.2 Drawing Planar Graphs

A problem with the emb eddings given by b oth the Hop croft-Tarjan and the Lemp el-

Even-Cederbaum algorithms is that they can use p ossibly exp onential area (grid-

size) in the resulting drawing. Manyvertices could b e recursively emb edded within

successive faces of the output representation and a naivedrawing algorithm would

give impractical output. For general planar graphs, this is not optimal, however we

CHAPTER 3. RELATED RESULTS 16

shall see in Section 3.4 that for upward planar graphs, we will (provably) havethis

problem with any drawing algorithm.

DeFraysseix, Pach and Pollack[8]have describ ed an O (n log n) algorithm which

takes an upward planar emb edding (such as that from either planarity testing al-

gorithm describ ed) as input, and constructs a straight-line physical plane drawing

on the 2n 4by n 2 grid (i.e. vertices are mapp ed to integer co ordinates on the

2

0  x  2n 4, 0  y  n 2, < subplane, and edges are mapp ed to straight lines

between corresp onding vertices, suchthatnotwo edges intersect except at their

endp oints). This upp er b ound on the area of plane graph drawings applies to all

planar graphs. Chrobak [7] (referenced byTamassia and Eades' bibliography [29])

has improved their algorithm to linear time. Indep endently, the same result (upp er

b ound and linear time) was achieved bySchnyder [27], with the added feature that

the co-ordinates are not \ xed", but have a \purely combinatorial meaning". De-

Fraysseix, Pach and Pollack's pap er also gives a (slightly) sup er-linear lower b ound

on the size of a grid required to supp ort all planar graphs.

3.3 Testing for Upward Planarity

The problem of testing for upward planarityisnotaswell known,orasdevelop ed, as

that of general planarity.Obviously, a given digraph can only b e upward planar if it

contains no directed cycles. DiBattista and Tomassia have proven than anyupward

planar graph is a subgraph of an (upward) planar st-graph [10]. An st-graph is a

graph lab eled with an st-numb ering (de ned in the previous section) consistant with

its underlying partial order; i.e. u

Platt [24] has shown that a single-source single-sink directed graph is upward planar

if and only if the graph generated by adding a single edge from the source to the

CHAPTER 3. RELATED RESULTS 17

sink is planar; this also follows from the Lemp el-Even-Cederbaum theorem of the

previous section. Thus it can b e tested in linear time whether an st-graph has

an upward plane drawing. However, the problem of determining whether a given

digraph is a subgraph of a st-graph is op en (ie. not known to b e p olynomial or

NP-hard) [29 ], so the characterization is not a strong one.

The currentwork considers the case of only one source, but anynumb er of sinks.

If all sinks but one could b e removed, then the problem would degenerate into the

known case|this is exactly what our algorithm achieves. We nd the problem

to b e more dicult than just mo difying the Even-Tarjan algorithm, b ecause more

freedom is available for movement in the drawing when multiple sinks are allowed,

and depth rst search is not directly applicable in the directed case. Thomassen's

theorem (1.1) is our starting p oint. A reasonable amountofwork will havetobe

done b efore it can b e applied.

A similar result to ours is to test planarity of a \hierarchical" graph, in which

the vertices of G are partitioned into k (a constant, usually given as part of the

input) subsets, with no twovertices in any subset b eing connected by an edge in G

(as in a subroutine call chart where all subroutines are assigned a \level", and any

subroutine can call others at only a strictly lower level), and the drawing must put

all vertices at a lower level b elow all vertices of a higer level. A linear algorithm for

this problem is given by DiBattista and Nardelli [11].

Avery recent result of DiBattista, Liu and Rival is that any is

upward-planar if and only if it is planar [9]. A graph G =(V; E)isbipartite if V

can b e partitioned into two disjoint subsets V and V suchthatevery edge (u; v )

1 2

of E connects u in V (V )to v in (V ) (i.e. no twovertices of V are joined byan

1 2 1 1

edge, and no twovertices of V are joined by an edge). 2

CHAPTER 3. RELATED RESULTS 18

3.4 Drawing Upward Planar Graphs

All known algorithms for drawing upward planar graphs make assumptions ab out

the form of the graph. DiBattista and Tomassia givean O (n log n) algorithm for

determining a straight line drawing of a single-source single-sink graph; i.e. an

st-graph. A monotonic grid drawing, where all edges are represented by p olygonal

lines with p ositively growing y -co ordinate, can b e constructed in linear time. The

straight line drawing can have exp onential grid-size, but the p olygonal grid drawing

guarantees no more than O (n) b ends in the p olygonal edges and a linear size grid.

The same result is achieved by Chiba and Nishizeki [6, 23 ] as a linear extension

of Bo oth and Lueker's PQ-tree algorithm. The algorithm assumes an st-numbering

which also realizes the partial order implied by the digraph G, and mo di es the

PQ-tree algorithm to retain direction while emb edding the graph.

No p olynomial algorithms are known for emb edding a general directed upward-

planar graph, or for determining if suchanemb edding exists [29].

A hierarchical graph (mentioned brie y in the previous section) can b e drawn

in linear time (Eades, Lin and Tamassia) [13].

An interesting result, also due to DiBattista, Tomassia, and Tollis [12 ] is the

following, whichshows that upward plane graphs do not have the same lower b ounds

on drawing area as undirected plane graphs:

Theorem 3.4 [DiBattista, Tomassia, and Tollis] There exists a class of planar

digraphs that require exponential area in any straight-line upwardgriddrawing.

We can claim the same result for single source DAGs, using the ab ove, and the

fact that every upward planar graph is a subgraph of a planar st-graph (the pro of

CHAPTER 3. RELATED RESULTS 19

of which [10] adds no more than O (n)vertices or edges in its construction). The

same pap er treats the issue of displaying symmetries and isomorphic subgraphs in

upward planar drawings.

3.5 Graphs and Partially Ordered Sets

Platt's Theorem [24 ] states that any single-source single-sink digraph admits an

if and only if the underlying undirected graph with an edge

added from the source to the sink is planar [24].

A is a in whichevery two elements have a unique

least upp er b ound or join, and greatest lower b ound or meet. It is known that

any planar p oset with a least and greatest element is a lattice [21]. The theory

of lattices is more develop ed than that of arbitrary p osets (see [2]), whichmaybe

cause for algorithms for upward planarity testing of lattices to b e \easier" than the

more general case.

Although any directed graph corresp onds to some partially ordered set P , the

minimal graph which captures the ordering of P is called the Hasse diagram or order

graph of P . A Hasse diagram has no transitive edges; ie. (u; v ) 62 G if 9w j(u; w )

and (w; v ) 2 G.

We note that the problem of testing a Hasse Diagram for planarity is identi-

cal to that of testing an arbitrary digraph, since a Hasse Diagram is a digraph

and, conversely, sub dividing each edge of a digraph with a new vertex yields a

graph with no transitive edges. Equivalence do es not however hold for a drawing

algorithm, since an upward plane straight-line drawing of a sub divided Hasse di-

agram would generate a monotonic grid drawing of the Hasse diagram itself (not

CHAPTER 3. RELATED RESULTS 20

necessarily a straight-line drawing); however, this do es immediately imply that the

lattice-drawing algorithm of DiBattista and Tomassia [10] can nd a monotonic grid

drawing of an arbitrary st-graph in linear time, such that the resulting drawing will

havenomorethann b ends [10].

For a given partial order P , one can always determine a linear extension Q of

P , i.e. any total order which includes (is consistent with) P . There always exists

such a linear extension, and the intersection of all linear extensions of P is P itself

[32 ]. A minimal set R of linear extensions of P whose intersection is P is called a

realizer of P and the dimension of P is the minimum cardinalityofany realizer of

P .

Various work has b een done on determining a characterization of upward pla-

narity through p oset theory rather than graph theory; a survey of the work has

b een done byTrotter [32 ]. Some of the more interesting results are the following:

Kelly and Rival [21] haveshown that there exist planar p osets of arbitrary

dimension. This is signi cant, b ecause it was originally thought that the dimension

of a p oset could b e related to the minimum genus of a surface up on which its Hasse

diagram could b e emb edded. The same line of researchledTrotter [32] to determine

that emb edding Hasse diagrams on the sphere is \di erent" from emb edding them

in the plane. These results showthatupward planarity has a more complicated

structure than planarity.

Work on sp eci c issues in the drawing of lattices, suchasminimizing the set of

edge slop es required for a plane emb edding, is discussed in Tamassia and Eades'

Bibliography[29].

A spherical order is an order with a unique top and b ottom element whose Hasse

diagram can b e emb edded on the sphere with no crossing arcs. This class di ers

CHAPTER 3. RELATED RESULTS 21

from the class of planar orders, as mentioned ab ove and in the requirement for a

least and greatest element. Note that every planar lattice is a spherical order (Kelly

and Rival) [21 ]. A truncated spherical order is a spherical order with its b ottom and

top elements removed. Foldes, Rival and Urrutia [17 ] show that an ordered set is

spherical if and only if it has a b ottom and a top element and its Hasse diagram is

planar; that an ordered set is truncated spherical if and only if it has a light source

representation, and that there is a linear algorithm to determine if an ordered set

has a light source representation. Alight source representation is a \blo cking"

generated by a p ointlight source, and a set of ob jects emb edded in the

plane. These prop erties of \light source order" and \sphericity" are hence said to

be invariant for lattice diagrams. Rival [26] discusses p ossible invariant prop erties

for order diagrams (no non-trivial invariant is known).

Chapter 4

Strongly-Equivale nt Upward

Planarity

We wish to consider the following sub-question: Given an acyclic digraph G with a

single source s and a planar representation G of G,does G admit an upward planar

representation strongly equivalenttothegiven emb edding G ? That is, can we

contort G slightly to make it a representation of an upward plane drawing without

changing any of the facial cycles or the outer face?

Thomassen's Theorem (1.1) provides the requirements for checking this, but no

ecient algorithm immediately follows. Here we provide an alternative statement

of Thomassen's result in the form of an optimal (linear) algorithm to test G for

upward planarity strongly equivalent to some given emb edding G .

Recall that an upward planar emb edding is, in e ect, a planar emb edding with

additional dummy edges which \resolve" those sinks not on the outer face|which

connect them to another vertex, so that the graph is still upward planar, but the

sink vertex is no longer a sink. We claim that given such a representation, it is 22

CHAPTER 4. STRONGLY-EQUIVALENT UPWARD PLANARITY 23

easy to drawanupward planar graph. How to do so will b e addressed in Chapter

8. The algorithm of this chapter will output an upward planar emb edding of G

strongly equivalentto G , if one exists, by adding edges to G .

We de ne a violating cycle of G as a cycle C whichhasnovertex v whichis

dominated by b oth its neighbours in C and which is not the tail of anyinward edge

G . The algorithm nds either a from a vertex on C with resp ect to the embedding

strongly equivalentupward plane representation or a violating cycle and it is clear

that wecannothave b oth so the pro of of correctness for algorithm also provides a

pro of of the theorem.

The idea of the algorithm is the following: we nd a sink v on the outer face

of G , delete it, recursively nd an upward planar embedding of Gnv strongly

equivalent (with resp ect to the orginal edges of G only) to Gnv , and then return v

to the outer face of this upward planar emb edding.

The input is a single-source digraph G and a planar emb edding G of G with the

source on the outer face. The algorithm returns either an upward planar emb edding

ofG such that is strongly equivalent (with resp ect to the original edges only)

G or a violating cycle C . to

De ne an outer-facial walk of a connected planar graph G, with resp ect to some

planar representation G , as a cyclic walk induced by the outer face of G . The

outer facial walk W of a single source DAG G with its source s on the outer face

G (which sp eci es the cyclic order of is assumed to travel from s to s, so, given

vertices around s), the outer facial walk we are concerned with is unique. Within

the sequence of vertices and edges which sp ecify the outer facial walk, there exist

one or more cycles|consisting of a subsequence of the walk starting at one vertex,

called the attachment of the cycle, and returning to the same vertex, with no other

CHAPTER 4. STRONGLY-EQUIVALENT UPWARD PLANARITY 24

vertices or edges rep eated. In the simple case, the outer facial walk is itself a cycle

from s to s.

Algorithm: If there is no sink on the outer facial walk W of G , then return a

violating cycle C as follows: If W is itself a cycle, then it is the (only) violating

cycle, as it contains no sink (and hence no vertex can satisfy the conditions for

\v "). If W is not a cycle, consider the cycles existing within W as discussed ab ove.

If any one of these cycles C within W contains s as its attachmentto W , then it

is violating, as all vertices on C , other than s, are non-sinks, and s is not a sink.

Otherwise, cho ose some cycle C within W which do es not contain s, and let u be

its attachmentto W . Then u is a source in C ; if not, the comp onent H of Gnu

with C as its outer face would havetocontain a source other than u,and s is not

in H ,soG has more than one source|a contradiction. This same issue is treated

more rigorously in the pro of of Lemma 5.1 on page 28.

Otherwise (there is a sink on W ), let v b e the rst sink on W . Recursively test

whether Gnv has an upward planar emb edding strongly equivalentto Gnv .Ifnot,

return the violating cycle of Gnv which is also a violating cycle contained in G .If

an upward planar embedding is returned then add v into the outer face of

v v

to form by connecting it with a directed edge from all adjacent(inG)vertices

and all sinks on W between the rst and last such adjacentvertex (this is the

resolving of the internal (no longer on the outer face) sinks mentioned in Chapter

2). The latter edges (from sinks) are marked as \dummy" edges as they are not

part of the original G. Since G has v on its outer face, and G nv has a strongly

equivalentupward plane emb edding ,allvertices of attachmentof v and all these

v

sinks are on the outer face of ,so v , and all edges b etween v and Gnv can added

v

to the outer face of without destroying planarity. Since all internal sinks have

v

b een \resolved" with dummy edges, the result is an upward planar emb edding

CHAPTER 4. STRONGLY-EQUIVALENT UPWARD PLANARITY 25

strongly equivalentto G.

Note that when we are refering to equivalence and strong equivalence of embed-

dings the extra dummy edges are not counted; they obviously change the faces of the

graph, but do not a ect the prop erties weareinterested in (which are determined

by the (unchanged) outer face, once an upward planar emb edding is found).

+

Since s ! v for all vertices in V (G)(i.e. s is the single source of G), and s

is never deleted while there is any other vertex on W , the subproblems retain the

single source prop erty. Since v can never have an edge p ointing downwardinthe

cycle, G remains acyclic, even with the extra edges.

To prove that the algorithm is correct it remains to note that if at some stage,

say for the induced graph G S , no sink is found on the outer face of G S then

since none of the vertices inside this outer face haveyet b een deleted the outer face

forms a violating walk, and contains a violating cycle as discussed ab ove.

Since the op erations necessary to implement this algorithm in linear time may

not b e obvious, the following section gives a more detailed discussion of the data

structures and op erations involved and a pro of of the time b ound.

4.1 Implementation Details

Since we can use the Hop croft Tarjan algorithm to compute a planar emb edding

in linear time, we will assume that the input is a collection of no des, with vertices

adjacenttoagiven no de in circular (counter-clo ckwise) order that o ccur in the

emb edding around that no de, and a sp eci cation of the outer face.

We implement W (of the previous section) as a doubly linked list, chained

through the graph G ,which is a collection of no des and (doubly linked) p ointers

CHAPTER 4. STRONGLY-EQUIVALENT UPWARD PLANARITY 26

to adjacent no des. We assume that the input comes in this form, with the list of

adjacentvertices to a given no de in circular order around that no de's emb edding in

the plane. De ne an additional list D , called the candidate list, whichcontains a

list of all sinks in W . This list is also doubly linked, and shares no des with G and

W .Wethus have a single copy of each no de, and a linear number of pointers in

total, so the space is O (n). Assume that the incoming and outgoing degree of each

no de is stored with the no de, and up dated as edges are deleted, so that a no de can

b e determined to b e a sink or source in constanttime.

Algorithm S-E-UP-PLANAR:

I. Cho ose the rst vertex v from D .

(i) If D is empty, G is not upward planar, so return a violating cycle within W

as describ ed in the previous section. If v = s,thenG is trivially upward planar, so

just return an emb edding of the single no de.

(ii) If deg v = 1 (edge (u; v )), then simply delete v from G, W ,and D , and also

delete the extra copyofu in W .Ifu is a sink in Gnv ,thenadd u to D as well,

0 0 0

yielding G , W and D .

(iii) Otherwise deg v>1. For each edge (u; v ), starting with the one preceding

v in W , add all new vertices in the face containing v to W and any sinks that are

0 0 0

, W and D . discovered to D . Delete v from G, W ,andD , yielding G

II. Recursively determine an upward plane emb edding or violating cycle of Gnv ,

0 0 0

using G , W and D .

0

III. Replace v in cyclic order around its vertices of attachmentin G , giving G. The

order do es not change from the original emb edding. At the same time, traverse the

0

vertices of W covered by v |those which are on W but not on W , and add an edge

from any sink covered by v ,asmentioned in the previous section.

CHAPTER 4. STRONGLY-EQUIVALENT UPWARD PLANARITY 27

EachnodeinG can b e added to W at most once, by planarity. Since adjacentnodes

are sorted in circular order, no searching need b e done, so the total time is linearly

prop ortional to the number of nodes in G, namely O (n). The twointeresting cases

((ii) and (iii) ab ove) are illustrated in Figure 4.1(a): v is case (ii), and v is (iii).

1 2

Figure 4.1(b) shows the addition step on v after the sub-emb edding is returned.

v v

1

W

(a)

(b)

v

2

Figure 4.1: Cases for v in Algorithm S-E-UP-PLANAR.

The standard abstract planar emb edding of a graph is to have eachnodeinG

contain a list of the vertices app earing in circular order around it. Our algorithm

determines if suchanemb edding extends to an upward emb edding with the same

facial structure, but with (p ossibly) some numb er of new edges from internal sinks

to vertices which rst cover them. Thus, the output from this algorithm is either

failure (and a violating cycle) or the mo di ed abstract upward emb edding.

This result is exactly that of Theorem 1.1, but the pro of is algorithmic, and the

algorithm is provably linear time.

Chapter 5

Separation into Bi-Connected

Comp onents

Lemma 5.1 ADAG G with a single source vertex s and a cut vertex v admits

an upwardplanedrawing i each of the k components H of G (with respect to v )

i

admits an upwardplanedrawing.

Pro of: The necessityisobvious; any subgraph of G must haveanupward plane

drawing if G do es. For the converse, wehave 2 cases, s = v and s 6= v .

H . Since v is the single Supp ose s = v , and all H haveupward plane drawings

i i

source of G, it is also the single source of each H , and is the lowest p oint on the

i

outer face in anyupward plane drawing. We complete the emb edding of G by

dividing the half-plane ab ove v into k \pie shap ed" segments, eachcontaining one

comp onent, with v identi ed at the same p ointin G. The construction is illustrated

in Figure 5.1(a).

If s 6= v , then identify the comp onentof G with resp ect to v containing s as

H . All other comp onents (i>2) must have v as a single source, otherwise G

1 28

CHAPTER 5. SEPARATION INTO BI-CONNECTED COMPONENTS 29

(a) (b)

H

1

f :::

H H

1 k

:::

H

k

H

2

v

v

Figure 5.1: Construction of G from its bi-connected comp onents

has more than one source. If some comp onent other than H had a vertex x

1

then either that comp onentcontains a second source in G or G contains a cycle as

+ + +

s ! v ! x ! v . Supp ose there is an upward plane drawing H of H . Consider some

1 1

face f of H containing some p ortion of the half-plane ab ove v . Then all other

1

comp onents can b e emb edded into the k segments of this face as they were added

to the op en face in the rst case. This is illustrated in Figure 5.1(b). As b efore,

anyupward drawing must have its single source as the lowest p oint on the outer

face.

Note that the op eration of inserting the comp onents H within faces of H ,or

i 1

into the regions of the plane around the half-plane ab ove v in an emb edding of H ,

1

will require scaling of the inserted sub-emb eddings. Any scaling will preserve b oth

upward planarity and the outer face of the \inserted" graphs, but the problem of

\bunched up" vertices or precise real arithmetic is not addressed.

Tarjan's well known algorithm [28] nds the cut-vertices and biconnected com-

ponents of a graph in linear time, and can b e used as a subroutine for our algorithm.

Chapter 6

Separation into Tri-Connected

Comp onents

The algorithm of Chapter 3 tests for upward planarityof G by examining a strongly-

equivalent planar emb edding G . In principle, we could apply this test to all planar

emb eddings of G, but this would take exp onential time. In order to maintain a

tractable number of emb eddings, we will rst isolate the triconnected comp onents

of the input graph, each of which has a unique planar emb edding under equivalence,

and only a linear number of planar emb eddings under strong equivalence [3]. Since

we will p erform the splitting and merging of triconnected comp onents in quadratic

time, the total time will then b e quadratic.

This step is similar in spirit to the previous op eration of splitting biconnected

comp onents and merging the recursively calculated drawings. However, the degree

of complication is much greater, b ecause the cut-set vertices imp ose restrictive

structure on the merged graph. In the previous section describing splitting into

biconnected comp onents, it was sucient to simply test each comp onent separately, 30

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 31

since biconnected comp onents did not interact in the combined drawing; this is not

the case for triconnected comp onents, as illustrated bythetwo examples in Figure

6.1. In (a), the union of the graphs is upward planar, but adding the edge (u; v )

to each makes the second comp onent non-upward-planar. In (b), the graph is non-

upward-planar, but each of the comp onents is upward planar with (u; v ) added. The

problem of sp ecifying necessary and sucient conditions for the split and merge is

nontrivial. Recall our convention that direction arrow-heads are assumed to b e

\upward" unless otherwise sp eci ed.

v

v v v

(b)

(a)

u

u u u

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

We will nd it convenient, particularly for the case where the source s is in a

separation pair, to split the graph into exactly two pieces at separation pairs.

There are two main issues. Firstly,wemust identify which comp onentwillbe

the \outer" comp onent, b ecause this imp oses restrictions on the other (\inner"

comp onent) to adapt to its facial structure (in order to b e injected within a face).

It will always b e true that the inner comp onentwillhave more restrictions up on

its emb edding, b ecause it must t within the prescrib ed face. Sp eci cally, a list of

vertices will b e required to b e on the outer face of anyemb edding to retain planarity

in the merge. Secondly,wemust b e able to prop erly represent the facial structures

of the two comp onents to ensure that the recursively calculated emb eddings can b e

merged without destroying upward planarity.

Our general subproblem instance consists of a biconnected graph G,andaset

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 32

of vertices X = fx gV (G)which will b e required to b e on the outer face of any

i

planar emb edding of G. G is broken up into two comp onents at a cut-set fu; v g,

and recursive calls made. We will give conditions based on the typ e of cut-set

involved as to whether upward plane drawings of the two comp onents can b e put

back together into an upward plane drawing of the whole. These conditions are

broken into three cases: where u and v are incomparable, u and v are comparable

with u 6= s (i.e. s

The conditions prescrib ed will b e in the form of markers added to eachcom-

ponent to represent the shap e of the other comp onent in the decomp osition. If

the graph were undirected, it would b e sucient to add a single edge b etween the

cut vertices in each comp onent, b ecause the only requirementwould b e that the

vertices share a face. Wewould also not need to require anyvertices to b e on the

outer face, b ecause any face can b e made the outer face. This is not true for upward

planarity.Thetyp e of markers needed will dep end on the particular graph.

6.1 Some Basic Results

The following are some preliminary results and de nitions useful throughout this

section. Recall our convention that connected, biconnected and triconnected are

de ned in terms of the underlying undirected graph, and that [ refers to the the

inclusive union of graphs.

6.1.1 Facial Structure of Upward Planar Graphs

Wewould rst of all like to get an intuitive idea of what the faces of upward plane

drawings must really lo ok like; See Figure 6.2. The outer face of anyupward plane

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 33

diagram must have a \similar" shap e to the upward facing hand shown in Figure

6.2(a), b ecause there is only one source s,whichmust b e at the b ottom of the

outer face and there can b e anynumb er of sinks. An inner face must have a shap e

\similar" to the downward facing hand in Figure 6.2(b): if there were more than

one vertex like w on the upp er side of the face, then there would havetobean

extra source b etween them. Note that b oth cases degenerate to the shap e of Figure

6.2(c).

w

w

outer inner

face face

s

s

(c)

(a) (b)

Figure 6.2: Facial structure in an upward plane drawing.

De nition 6.1 Let G beabiconnectedDAG with a single source s and separation

pair fu; v g, where u; v 6= s. Then, the connectedcomponent of G with respect to

fu; v g containing s is cal led the source comp onent of G with respect to fu; v g.

6.1.2 Prop erties of Cut Sets in Digraphs

Wecannow make the following two observations.

Prop osition 6.2 If G is a single sourceconnectedDAG with a cut-set fu; v g,

where u and v areincomparable, then u and v have in-degree 0 (i.e. are sources)

in al l components of G with respect to fu; v g except the sourcecomponent.

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 34

Pro of: Note that G is connected, otherwise it would have more than one source.

Also, if anyvertex x is incomparable with the source, then G would have more than

one source. This implies that neither u nor v is a source in the source comp onent.

Consider any comp onent H of G with resp ect to fu; v g, not containing the

source s.InG,anyvertex x of H is connected by a directed path from s (only)

through either u or v ,asfu; v g separates s from H .Thus, u

vertices x 2 H . Without loss of generality, supp ose that v has an incoming edge

+

(x; v ); then, either u

b oth contradictions.

Prop osition 6.3 If G isaconnectedDAG with exactly two sources u and v , then

there exists some w such that two vertex disjoint (except at w ) directedpaths

t t

+ +

u ! w and v ! w exist in G.

t t

Pro of: Let G b e suchaDAG and let P b e an undirected path from u to v . Note

that every x in P is comparable with either u or v , otherwise G has more than

two sources. Follow P from u to the rst no de x (following y on P ) incomparable

with u (in G). Then, x is comparable with v and (x; y )isanedgeinG (otherwise

u

+ +

u ! y and v ! y gives w .

t

Wearenow in the p osition to discuss the structure of comp onents arising from

2-vertex cuts. Sp eci cally, the following results show the existence of lower b ounds

and upp er b ounds (in the partial order corresp onding to G) under certain condi-

tions. This allows us to prove the necessity conditions of the next section, b ecause

the existence of such structures indicate that certain subgraphs must exist as sub-

graphs within G. It is these subgraph prop erties whichwillbeusedtoshowthat

the comp onent-markers are appropriately chosen.

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 35

Lemma 6.4 If G is a biconnectedDAG with a single sources,andu and v are

incomparable vertices in G, then there exists some w such that two vertex disjoint

s

+ +

(except at w )directedpaths w ! u and w ! v exist in G.Iffu; v g is a cut-set

s s s

in G, then there also exists some w such that two vertex disjoint (except at w )

t t

+ +

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

t t

Pro of: Since G is a single source digraph, there exist directed paths from s to u

and s to v in G, so if these paths are vertex disjointthenw = s and we are done.

s

Otherwise, there is some maximal element (in the orders imp osed by the twochains

on the elements within them) which is shared by b oth paths, and this suces for

w .

s

For the existence of w , let u and v b e an incomparable separation pair of

t

G. Since fu; v g cuts G into at least two connected comp onents, any non-source

comp onent H has u and v as its (exactly) two sources, and the result follows from

Prop osition 6.3.

Lemma 6.5 If G isabiconnectedDAG with a single source s and cut-set fu; v g,

where u

+ +

+

fu; v g,where deg v>0, there exists some w such that u ! w and v ! w are

t t t

vertex disjoint directedpaths in H .

Pro of: No vertex other than u and v can b e a source in H , otherwise G has more

than one source. u is always a source in H , otherwise G contains a directed cycle.

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

If v is not a source, let w 2 H be a vertex dominated by v . G is biconnected,

+

so there are twovertex disjoint u ! w undirected paths in G. But u and v are

cut-vertices in G, so at least one of the paths P lies completely within H and do es

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 36

not contain v (as w is in H and the only exit p oints from H are u and v ). Every x

on P is comparable with either u or v ,orelseG has more than one source. Find

+

the last vertex y on P whichhasau ! y path (in G) without v .Ify = w , then we

+

are done. Otherwise, the vertex x following y on P has any u ! x path necessarily

+ +

going through v . Then there exist directed paths v ! x, u ! x with the latter not

containing v so the last common vertex on these paths provides a w .

t

6.1.3 Top ological Prop erties of Upward Planar Graphs

Wenowprove that certain contractions and transformations on a digraph preserve

the prop ertyofupward planarity. The rst result is used to simplify the structure

of graphs in the decomp osition/merging phases; the remaining results are necessary

for pro ofs in the next section.

De nition 6.6 A sub division vertex of G is any vertex v which satis es

+

deg v = deg v =1. A directed sub division is a subdivision of G which pre-

serves edge-transitivity (i.e. inserting w into (u; v ) can only yield (u; w ); (w; v ),so

the property u

Note that sub division vertices add no information or structure to the problem

of testing for upward planarityasproven by Thomassen [30].

Lemma 6.7 G admits an upward plane drawing if and only if any directed subdi-

vision of G admits an upwardplanedrawing.

As a result, we can prepro cess G to contract long paths of a directed sub division

into single edges in the following way: For anypath P = v v :::v of G with k  2

0 1 k

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 37

+

and deg v = deg v =1(i =1 k 1), replace P by the single edge v v .

i i 0 k

The identi cation of such no des can b e done with a single depth- rst search of the

graph, collapsing edges as the search pro ceeds, and thus takes linear time.

Using this contraction pro cess b efore pro cess of isolating triconnected comp o-

nents will allowustoassumethatany non-source, non-sink no des have degree at

least three (or they would have b een contracted).

Another result is the following, which also implies Lemma 6.7:

Lemma 6.8 Let G beaDAGand v , dominatedbyu,be a vertex of G with in-degree

1. Then, G=(u; v ) is upward planar if G is upward planar.

Pro of: Supp ose G is some upward planar emb edding of G. Then, there is

an "region or \corridor" around the edge (u; v )down which v and its monotonic

upward-directed edges can b e contracted without destroying planarity. The partial

order through v is preserved since v has no other incoming edges, so there are no

vertices b etween u and v in the partial order. See Figure 6.3(a).

+

Corollary 6.9 The same result holds for G and edge (u; v ) with deg u =1by

symmetry.

We can now extend Lemma 6.7 to cover arbitrary digraphs rather than single

vertices.

Lemma 6.10 Let G bea connectedDAGwithanedge (u; v ) and H beaconnected

0 0 0

DAG with a single source u and a sink v .Let G be G with the edge (u; v ) subdivided

0 0 0 0 0 0

by u and v (i.e. (Gn(u; v ) [ (u; u ) [ (u ;v ) [ (v ;v)),andcontaining H attached

0 0 0

at u and v . Then, G is upward planar if and only if G is upward planar and H

0 0

is upward planar with u and v on the outer face.

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 38

w w w w

l r l r

v

0

v

v

v

u

0

u

u u u u u

l r l r

(c)

(a) (b)

Figure 6.3: Transformations preserving upward planarity.

0 0

Pro of: Since u and v are forced to b e on the outer face of an upward planar

0 0

emb edding of H , and u is the (only) source of H ,andv is a sink, an upward plane

emb edding H can b e inserted b eside the edge (u; v ) along an "-corridor without

destroying upward planarity.For the other direction, G is upward planar b ecause

0

it is homeomorphic to a subgraph of G . H is upward planar as it is a subgraph

0

of G and the source u and all sinks share the outer face, so the edge (u; v ) can b e

added without destroying planarity|the source can always \see" any sink on the

outer face in an upward planar emb edding. See Figure 6.3(b).

A similar result to sub dividing an edge as just discussed, is to extend the digraph

beyond (ab ove) a sink no de; where there is no edge (i.e. by adding an edge or graph

with a connection to a the sink):

Lemma 6.11 Let G be an upward planar digraph containing a sink u. Then for

some new vertex v , G [ (u; v ) is also upward planar. Similarly for an upward planar

digraph H with single source v , G [ H [ (u; v ) is upward planar.

Pro of: Since u is a sink in G,inany drawing G of G, there is an epsilon ball in

the half-plane ab ove u containing no other vertices or edges. Inserting v into this

area, and adding the edge (u; v ) retains upward planarity. By rep eated applications

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 39

of this op eration of inserting edges, and and the previous top ological results such

as sub divisions, any single source upward planar graph can b e inserted (\grown")

ab ove u in G.

Note that this do es not address the problem of arithmetic precision or scaling;

only the issue of upward planarity.

+

Lemma 6.12 Let G beaDAGandv be a vertex of G with deg v = deg v =2.Let

G be an upward plane embedding of G with u and u the left and right dominating

l r

vertices of v respectively, and w ;w the left and right vertices dominatedby v

l r

respectively. Then Gnv [f(u ;w ); (u ;w )g is upward planar as wel l.

l l r r

Pro of: For some suciently small ",the"ball around v contains four regions,

de ned by the four edges incidentupon v . The leftmost (rightmost) two can b e

joined into a single monotonic edge to the left (right) of v ,and v deleted to givean

upward plane emb edding of Gnv [f(u ;w ); (u ;w )g. See Figure 6.3(c).

l l r r

6.2 Marker Comp onents

In order to e ectively decomp ose our input graph for testing purp oses, we will nd it

necessary to reduce the biconnected comp onents to their simplest relevant structure.

An elementary step in this op eration consists of splitting the input graph into

exactly twocomponents, replacing each comp onentby a marker comp onentinits

companion, and recursively testing the two for upward planarity. The crucial p oint

is to cho ose the appropriate marker, so as to suciently represent the structure

of the companion. The markers are necessary for three reasons: Firstly, to ensure

that the original graph is upward planar if and only if the twocomponents (with

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 40

markers) are upward planar; secondly,tomaintain biconnectedness; and thirdly,to

maintain the single source prop erty. The markers wewillbeinterested in are shown

in Figure 6.4. An imp ortantpointtomake at this time is that the markers, except

u v w v w

t t

v

u

w u v u

s

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

s t uv uv t

Figure 6.4: Marker Graphs.

for M , are attached to the graph at only twovertices, which means that fu; v g

uv

still constitutes a cut-set. For the purp oses of determining cut-sets and making

recursive calls, each marker should b e treated as a distinguished edge|a single

edge lab elled to indicate its role. As long as the typ e of marker is identi ed, the

algorithm can continue to treat the vertices of attachment as source, sink or neither

as appropriate for the particular op eration.

The following three subsections describ e the markers to use for di erenttyp es

of cut-sets fu; v g.

6.3 The cut-set fu; v g, where u and v are incom-

parable

Theorem 6.13 Let G be a biconnected directed acyclic graph with a single source

s and let X = fx gV (G) beasetofvertices. Let fu; v g beaseparation pair

i

of G, with u and v incomparable, where S is the connectedcomponent of G with

respect to fu; v g containing s,andH is the union of al l other components. Then,

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 41

G admits an upward plane drawing with al l vertices of X on the outer face if and

only if

0

(i) S = S [ M admits an upward plane drawing al l any vertices of X in S

t

on the outer face, and w on the outer face if some x 2 X is containedinH .

t

0

(ii) H = H [ M admits an upwardplanedrawing with al l vertices of X in H

s

on the outer face.

Pro of: (Necessity) Supp ose G admits an upward plane drawing with all x 2 X

i

+

on the outer face. By Lemma 6.4 there exist vertex disjoint paths P = u ! w and

u t

+

P = v ! w in H , for some w .IfG is upward planar, then any subgraph of G

v t t

0 0

is, so S [ P [ P is upward planar. But this is a directed sub division of S ,so S

u v

is also upward planar by Theorem 6.7. Similarly, there is some w in S suchthat

s

0

H = H [f(w ;u); (w ;v)g is homeomorphic to a subgraph of G and is upward

s s

planar.

Since all x 2 X are on the outer face of G, they are certainly on the outer face

i

0 0

of the sub-emb eddings S and H of the upward emb edding G .Ifsomex 2 H is

i

on the outer face of G , then the sub-emb edding of the H p ortion of G is within the

outer face of the sub-emb edding of S ,soanemb edding of S [ M will have w on

t t

the outer face.

0 0

0 0

(Suciency) Supp ose S and H admit upward plane drawings S and H with

0

all x 2 X on their resp ective outer faces and w on the outer face of S if some

i t

x 2 X is contained in H . Since u and v have in-degree 0 in H (Lemma 6.2), and

i

H has no other sources, all of H lies in some region ab ove u and v in any plane

emb edding (since the added source w dominates b oth u and v and forces them to

s

b e on the outer face, and the lower p ortion of that face). Rename u and v in H as

0 0 0 0 + 0

u and v resp ectively and consider S [ H [ (w ;w ). Since deg w = 0 (in S ), this

s t t

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 42

combined graph is upward planar (Lemma 6.11). Applying Lemma 6.8 to contract

(w ;w )into a single vertex w and splitting w (which has in-degree and out-degree

s t

0 0

two) into two edges (u; u )and(v; v ), by Lemma 6.12, gives an upward planar

0 0 0 0

graph S [ H [f(u; u ); (v; v )g.Butdeg u =1 and deg v =1,soby Lemma 6.8

applied twice, G = S [ H is upward planar. See Figure 6.5(a), and Figure 6.3(c)

on page 38.

w

t

x

1

x

2

H

x

k

w

t

v

u

f

H

x

k

v

u

u

v

w

s

S

v

x

x x

3

1 2

u

S

w

s

(b) x 's in H .

i

(a) No x 's in H .

i

Figure 6.5: Merging of S and H when cut-set fu; v g is incomparable.

If no x 2 H , then this is sucient for the emb edding. Otherwise, consider the

i

0 0

op erations carried out ab ove. The joining S [ H obviously preserves the outer face

0 0 0 0

of H and all vertices on the outer face of H are also on the outer face of S [ H

0

as w is on the outer face of H by (ii). Other than for the vertex w ,whichisnot

0

in G, this face is also preserved by the splitting of w and the contraction of (u; u )

0 0

0

H , they are also on and (v; v ). Thus, if all x 2 H are on the outer face of some

i

the outer face of G generated by these steps. This is illustrated in Figure 6.5(b).

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 43

6.4 The cut-set fu; v g,where u

Here we consider any other vertex cut-sets not involving the source s.We divide

the graph at a vertex cut fu; v g into two subgraphs|the source comp onent S , and

the remaining subgraph H . Note that v can b e a source in S , as long as there

is a u; v path in H . Again we p oint out that the markers are required for three

purp oses|to enforce structural restrictions on the sub-emb eddings; to maintain

bi-connectivity of the subproblems; and to maintain the single-source prop erty.

Theorem 6.14 Let G be a biconnected directed acyclic graph with a single source

s, and let X = fx gV (G) beasetofvertices. Let fu; v g be a separation pair of

i

G with u

to fu; v g and H is the union of al l other components. Then, G admits an upward

plane drawing G with al l vertices of X on the outer face if and only if

0

0

(i) S =(S [ H -marker) admits an upwardplanedrawing S with al l vertices

of X in S on the outer faceandw (if it exists, otherwise the edge (u; v )) on

t

the outer face if some x 2 X is containedinH .

0

0

(ii) H =(H [ S -marker) admits an upward plane drawing H with w (if it

t

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

where

8

>

>

>

M if v is a sourcein H

t

>

>

<

H -marker =

M if v is a sink in H

uv

>

>

>

>

>

:

M otherwise.

uv t

and

8

>

<

M if v is a sourcein S

t

S -marker =

>

:

M otherwise. uv

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 44

Pro of: (Necessity) Supp ose G admits an upward plane drawing with all x 2 X

i

on the outer face.

(Necessity of condition (i)): If v is a source in H , then there exists some w in

t

+ +

0

H and vertex disjointpaths u ! w and v ! w by Prop osition 6.3; so S = S [ M

t t t

is homeomorphic to a subgraph of G and is upward planar. If v isasinkinH ,

then u is the single source of H ,asonlyu and v are p ossible sources. Thus, in H ,

+

0

there is a path u ! v ,so S = S [ M is homeomorphic to a subgraph of G and is

uv

upward planar. If v is neither a source nor a sink in H then, by Lemma 6.5, there

+ +

is also some w >v and disjoint directed paths u ! w and v ! w in G. Since v is a

t t t

+ +

non-source in H , there is also a u ! v path in H . This path crosses the u ! w path

t

 + + +

at some latest vertex z on that path, so S [ (u ! z ) [ (z ! v ) [ (z ! w ) [ (v ! w )is

t t

a subgraph of G and hence upward planar. Note that these four paths are disjoint.



Since z has in-degree one we can contract the u ! z path to u without destroying

upward planarity,by Lemma 6.8, so S [f(u; v ); (u; w ); (v; w )g has an upward

t t

planar sub division and is upward planar itself. No other vertices of this graph can

lie inside the u; v ; w triangle, as s

t

0

and there are no other (u; v ) comp onents in S (as wechose S to b e the single

source comp onent), so the extra edges and vertex for M can b e added without

uv t

1

destroying planarity .

(Necessity of condition (ii)): If v is a source in S , then, by Prop osition 6.3, there

+ + +

are vertex disjointpaths s ! w and v ! w in S . There must b e an s ! u path in

t t

S , otherwise there is either a second source (u is a source in H , so it cannot also

+

b e a source in S ) or a cycle in G (u

+ +

path in S ). Let z b e the last vertex common to paths s ! u and s ! w . Then,

t

H [f(z; u); (z; w ); (v; w )g is homeomorphic to a subgraph of G and is upward

t t

1

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

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 45

planar. Since deg u = 1 (in this graph), the edge (z; u) can b e contracted without

0

destroying upward planarity,by Lemma 6.8, and H = H [ M is upward planar.

t

0

Otherwise (v a non-source), if u

uv

to a subgraph of G and, hence, is upward planar. If u and v are incomparable in S ,

then they share a greatest lower b ound w ,by Lemma 6.4, and H [f(w ;u); (w ;v)g

s s s

is upward planar. Again, deg u =1 in H ,sothe(w ;u) edge can b e contracted to

s

0

give H = H [ M .

uv

The necessity of the outer facial conditions on the x 's is similar to the pro of of

i

Theorem 6.13.

0 0

0 0

(Suciency) Supp ose S and H admit upward plane drawings S and H with

0

H ,andw on the all x 's of X on the resp ective outer faces, v on the outer face of

t i

0

outer face of S if some x in X is contained in H . Consider rst the case when no

i

x 's are contained in H .

i

Case 1: v is a source in H : If v is a source in H it cannot at the same time

0

b e a source in S as u

00 0

single source u, and (u; v ) on an outer face, H = H [f(w ;u); (w ;v)g is upward

s s

00 0 00

planar by Lemma 6.11. H can b e added ab ovesink w ,soS [ H with w and w

t s t

identi ed as the same vertex w is upward planar. Since w is of in-degree two and

out-degree two, it can b e split into left and right edges and these can b e contracted,

by Lemma 6.8, to giveanupward planar graph whichcontains G as a subgraph, so

G is upward planar; see Figure 6.6(a).

0

Case 2: v is a sink in H :Ifv is a non-source in S ,thenH = H [ (u; v )isupward

0

S , there exists an planar with u and v on the outer face by assumption. Then, in

0

"ball around some p ointontheemb edded edge (u; v )into which H (with u and v

0 0 0 0

renamed as u and v ) can b e emb edded (Lemma 6.10), and (u ;v )removed. Since

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 46

0

S

0

H

w

t

v

u

v

u

(a) v a source in H

v

w

t

v

0

H

v

v

0

H

u

0

u

S

0

S

u

u

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

w

t

v v

v

v

0

H

0

H

u

0 0

u u

S S

u

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

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

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 47

0 0 0

u and v have in-degree and out-degree one resp ectively, the extra edges (u; u ) and

0

(v; v ) can b e contracted, by Lemma 6.8, and the result G is upward planar. If v is

+ 0

a source in S , deg v =1 in H = H [ M so we rst apply Lemma 6.8 to contract

t

the edge (v; w ) and the the result G is upward planar. These two p ossibilities are

t

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

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

t

0 0

0

on the outer face of some emb edding H of H by condition (ii) of the theorem. S

0 0 0 0

with H inserted into the marker edge (u; v ) (with u; v in H renamed to u ;v ), and

0

attached at u and w is upward planar by Lemma 6.10. The subgraph with all but

t

0

(u; v ) of the H -marker is thus upward planar. Now u and v have in-degree one,

0 0

so the edges (u; u ) and (v; v ) can b e contracted, by Lemma 6.8. Similarly w now

t

0

has in-degree one1, so (v ;w ) can also b e contracted and G is upward planar; see

t

Figure 6.6(d).

Supp ose then that v is a non-source in S . The reasoning ab ove applies except

0 0

for that we cannot immediately contract the (v ;v) edge (since v no longer has

0 0

in-degree one). Now, the edge (u ;v )liesbetween u and v and the the fact that u

0 0

is the single source of H ensure that H can b e scaled to some small area in the

0

left half-plane b eside v so that it requires some part of the upp er half-plane ab ove

0

v . Some such region must exist in the face f of S containing the marker, since

0

S is upward planar with the dummy edge ab ove v .Thus with H appropriately

0

scaled b efore the inserting it into the (u; v ) edge, the edge (v; v ) can b e contracted

without destroying upward planarity.

Again, the conditions on the x 's follow in a similar manner to those in the

i

previous section, as they simply involvethechoice of the outer face of H [ S .

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 48

6.5 The cut-set fs; v g

As mentioned in the intro duction to this chapter, it is imp ortant to b e able to

identify the comp onent which is going to b e the \outer" one|that will contain the

other comp onent. The \inner" comp onentwillhavetohave its marker on the outer

face since this is the structure it will b e a proxy for. If this prop erty is not known,

wehavetocheck the subproblems sub ject to b oth cases, and an exp onential time

blowup results.

Until now, this comp onent has b een uniquely identi ed as the sourcecomponent,

since that comp onent cannot lie within an internal face of any other comp onent.

This provided the needed structural restrictions for the emb edding|in that H can

lie inside S ,butS can never lie inside H . If the cut-set we wish to use contains

s as one of the cut-set vertices, we lose this restriction, so we handle it instead

bycho osing a 3-connected comp onentasan\identi ed" comp onent, to avoid the

exp onential blowup that results from searching for the \outside" comp onent. The

reason that this works is b ecause a triconnected comp onent can b e checked for up-

ward planarity without any further recursive calls to nd triconnected comp onents,

and can b e checked in linear time by algorithm S-E-UP-PLANAR of Chapter 3|

since the restriction for s and v on the outer face will x the outer face, only one

p ossible emb edding that needs to b e checked exists. If G has only cut-sets of the

form fs; v g, then, for at least one such cut-set, a triconnected comp onent exists. In

linear time, given the list of cut-sets, this comp onent can b e found by depth- rst

search.

We state this result in terms of two theorems. One is applicable if the tricon-

nected comp onentcanbeemb edded within the other comp onent, and one when it cannot.

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 49

Theorem 6.15 Let G be a biconnectedDAG with a single source s, and let X =

fx gV (G) be a set of vertices. Let fs; v g beaseparation pair of G, E bea

i

3-connectedcomponent of G with respect to fs; v g, and F be the union of al l other

components of G with respect to fs; v g.IfE admits an upward plane drawing with

s and v on the outer face, then G admits an upward plane drawing with al l vertices

of X on the outer face if and only if

0

0

(i) F =(F [ E -marker) admits an upward plane drawing F with al l vertices

of X in F on the outer face, and w (if it exists, otherwise the edge (u; v ))

t

also on the outer face if some x 2 X containedinE .

0

0

(ii) E =(E [ F -marker) admits an upward plane drawing E with w (if it

t

exists, otherwise the edge (u; v )) and al l vertices of X in E on the outer face,

where

8

>

>

>

M if v is a sourcein E

t

>

>

<

E -marker =

M if v is a sink in E

uv

>

>

>

>

>

:

M otherwise.

uv t

and

8

>

<

M if v is a sourcein F

t

F -marker =

>

:

M otherwise.

uv

Pro of: The similarity of this theorem to Theorem 6.14 of the previous section

should b e evident; the only ma jor di erence is the wayinwhich the outer comp o-

nent is isolated; as such, we will b e more terse in its pro of. For compatibility with

previous notation, we will continue to use u and v as the cut-vertices, even though

u = s.

(Necessity) Assume that G hasanupward plane emb edding G with all vertices

of X on the outer face, and furthermore that E admits an upward plane emb edding

E with v on the outer face.

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 50

(Necessity of condition (i)): If v is a source in E , then there exist vertex disjoint

+ +

0

directed paths u ! w and v ! w for some w in E (Prop osition 6.3) and F = F [ M

t t t t

+

is upward planar. If v is a sink in E , then there is a directed path u ! v in E and

0 +

F = F [ M is upward planar. Otherwise, deg v  1 and there exists some

uv

 + + +

vertices w and z in E such that u ! z , z ! v , v ! w and z ! w are vertex disjoint

t t t

directed paths in E (Lemma 6.5) and F [f(u; v ); (v; w ); (u; w )g is homeomorphic

t t

to a subgraph of an upward planar graph, G,andisupward planar. Within this

triangle in anyupward plane emb edding, we can add the additional \dummy"

0

vertex and F = F [ M is also upward planar. If some x 2 X is on the outer

uv t

0

face of G, it is certainly on the outer face of the sub-emb edding F .

(Necessity of condition (ii)): If v is a source in F , then there exist vertex

+ +

disjoint directed paths u ! w and v ! w for some w in F (Prop osition 6.3) and

t t t

0

E = E [ M is upward planar. Otherwise, we note that u

t

0

the single source of G,soE = E [ M is homeomorphic to a subgraph of G and

uv

is upward planar.

Note that the necessity of the outer facial conditions again follows from Theorem

6.5.

(Suciency) Supp ose G, E and F are as de ned, and conditions (i)and(ii)of

the theorem are met.

Consider rst when no x 2 X is contained in E .

Case 1: v is a source in E :Ifv is a source in E it cannot at the same time b e

0

a source in F as u

00 0

source u, and (u; v ) on an outer face, E = E [f(w ;u); (w ;v)g is upward planar.

s s

00 0 0 00

By Lemma 6.11, E can be added abovesinkw in F ,so F [ E with w and w

t s t

identi ed as the same vertex w is upward planar. By application of Lemmas 6.12

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 51

and 6.8, w can b e split, and the resulting edges contracted, resulting in an upward

planar graph which contains G as a subgraph, so G is upward planar.

0

Case 2: v is a sink in E :Ifv is a non-source in F , then E = E [ (u; v )isupward

planar with (u; v ) on the outer face by condition (ii) of the theorem. By Lemmas

0 0 0

6.10 and 6.8 an emb edding of E (with u; v renamed to u ;v ) can b e inserted into

0 0 0 0

the edge (u; v )of F (attached at u and v ) the edge (u ;v ) removed, the other

extra edges contracted, and the result G is upward planar. If v is a source in F ,

+ 0

deg v =1inE = E [ M ,sowe rst apply Lemma 6.8 to contract the edge (v; w ),

t t

and the result follows.

Case 3: v is a non-source/sink in E : Supp ose v is a source in F .Thenw is a

t

0

0

sink on the outer face of some embedding E of E by condition (ii) of the theorem.

0 0 0 0

F with E inserted into the marker edge (u; v ) (with u and v in E renamed to u

0 0

and v ) and attached at u and w is upward planar by Lemma 6.10. The subgraph

t

0

with all but (u; v )ofthe E -marker is thus upward planar. Now u and v have

0 0

in-degree one, so the edges (u; u )and(v; v ) can then b e contracted by Lemma

0

6.8. Similarly w now has in-degree one, so (v ;w ) can also b e contracted, and G

t t

is upward planar.

Supp ose then that v is a non-source in F . The reasoning ab ove applies except

0 0

for the abilitytoimmediately contract the (v ;v) edge (since v no longer has in-

0 0

degree one). Now, the edge (u ;v )between u and v and the the fact that u is

0 0

the single source of E ensures that E can b e scaled to some small area in the

0

left half-plane b eside v and requires some part of the upp er half-plane ab ove v .

0 0

Some such region must exist in the face f of F containing the marker, since F is

upward planar with the \dummy" edge ab ove v .Thus with E appropriately scaled

0

b efore its insertion into the (u; v ) edge, the edge (v; v ) can b e contracted without

destroying upward planarity.

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 52

Theorem 6.16 Let G beabiconnectedDAG with a single source s and let X =

fx gV (G) be a set of vertices. Let fs; v g beaseparation pair of G, E bea

i

3-connectedcomponent of G with respect to fs; v g, and F be the union of al l other

components of G with respect to fs; v g. If E does not admit an upward plane

drawing with s and v on the outer face, then G admits an upward plane drawing

with al l vertices of X on the outer face if and only if

(i) Thereisnox 2 X containedinF .

0

0

=(F [ E -marker) admits an upward plane drawing (ii) F F with w (if it

t

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

containedinE .

0

0

(iii) E =(E [ F -marker) admits an upward plane drawing E with al l x 2 X

on the outer face,

where

8

>

>

>

M if v is a sourcein E

t

>

>

<

E -marker =

M if v is a sink in E

uv

>

>

>

>

>

:

M otherwise.

uv

and

8

>

>

>

M if v is a sourcein F

t

>

>

<

F -marker =

M if v is a sink in F

uv

>

>

>

>

>

:

M otherwise.

uv t

Pro of: If E has no upward plane drawing with u and v b oth on the outer face,

then the only way G could b e upward planar is if F can b e emb edded within a face

0

E not containing of E .Thus, the outer face of G is xed as b eing some face of

v or anyvertices of F , or some face which can b e partitioned into vertices from

the outer face of F and the outer face of G. It remains to ensure that there is

CHAPTER 6. SEPARATION INTO TRI-CONNECTED COMPONENTS 53

some emb edding of F which will t the structural constraints of the shap e of a face

shared by u and v in E . These are exactly the conditions previously required by E

for emb edding within F . The pro of is identical to Theorem 6.15 up to the naming

of E and F . The di erences in the statement of the theorems a ect only the time

bound. The result is identical, as it do es not dep end up on triconnectedness of

either comp onent.

Chapter 7

An Algorithm for Upward Planar

Emb edding

The algorithm works as follows: A directed acyclic graph G with a single source s

is given to BI-MERGE, which splits G into biconnected comp onents, calls CON-

TRACT whichcontracts sub division edges, identi es the triconnected comp onents

in the result, and calls TRI-MERGE to split the result into triconnected comp o-

nents. TRI-MERGE calls itself recursively to isolate triconnected comp onents, then

calls TRI-EMBED to test all of the emb eddings of a triconnected comp onentfor

upward planarity with MOD-S-E-UP-PLANAR (mo di ed slightly from S-E-UP-

PLANAR of Chapter 4 to takeaccount of markers), returning an emb edding. As

the emb eddings are returned to the calling routines, CONTRACT un-contracts

the edges and TRI-MERGE merges the emb eddings of the recursively de ned sub-

graphs, as do es BI-MERGE. If any violations of upward planarity are found, the

algorithm rejects.

Algorithm BI-MERGE: Find the set of cut-vertices, \CutList", and the set 54

CHAPTER 7. AN ALGORITHM FOR UPWARD PLANAR EMBEDDING 55

of biconnected comp onents, \Comp onentList", of the input graph G. Find an

upward planar emb edding (if one exists) of each comp onent in Comp onentList

with the CONTRACT algorithm. Then, for each cut vertex v ,remove the source

comp onent S and remaining v -comp onents fH g from Comp onentList. Determine

i

afaceabove v in S and embed the H 's in the prescrib ed face f .Iff is not the

i

outer face, add dummy edges from the sinks of eachemb edding H to the covering

i

vertex of v ,toresolvetheinternal sinks generated bytheH 's (analagous to the

i

more detailed description of Chapter 4). Add the result to Comp onentList, and

continue until CutList is exhausted.

Finding biconnected comp onents can b e done in linear time, and since the merge

step considers eachcut-vertex at most once and need not search the remainder of

the graph, this step requires linear time plus the time taken by CONTRACT on

each sub-problem (subgraph).

Algorithm CONTRACT:

Perform a depth rst search of the input graph G and contract edges around

anyvertices of in-degree one and out-degree one, (following Lemma 6.7) storing

the required information within the contracted edges. Use the tri-connected com-

ponents algorithm [19] to nd the list of separation pairs of G. Call TRI-MERGE

with the contracted graph to nd an upward plane emb edding, then sub divide the

edges of the emb edding with the previously contracted vertices.

Depth rst search takes linear time, so this step is also linear time plus the time

taken by TRI-MERGE on the initial subproblem.

Algorithm TRI-MERGE:

The input is a graph G, a list of separation pairs L in G and a list X of vertices

G .Pick a cut-set fu,vg of G from the list of cut-sets X required on the outer face of

CHAPTER 7. AN ALGORITHM FOR UPWARD PLANAR EMBEDDING 56

L,(cho osing all cut-sets not containing s b efore those containing s) and determine

whether u and v are comparable in G. If they are, ensure that u< v in the lab eling.

If no such cut-set exists, call TRI-EMBED to nd an upward planar representation

of G with the x 's on the outer face, and return the result.

i

If u 6= s, isolate the source comp onent S with a depth- rst search, form the

union H of the remaining comp onents (following Theorems 6.13 and 6.14) and add

the required marker edges to each comp onent. At the same time, determine the

new sets X and X ,and L and L , from X and L resp ectively, and recursively

S H S H

call TRI-MERGE with each sub-problem. X and X are a partition of X into

S H

the set of vertices of X which are also in S and the set of vertices of X which

are also in H , plus the additional required vertices whichmust b e on the outer

face of the sub-problems, and p ossible additions for new marker edges. L and L

H S

are a partition of L into the set of cut-sets of G contained in H and S resp ectvely.

With the results of each sub-problem, apply the algorithm implicit in the suciency

pro of of Theorems 6.13 or 6.14 (as appropriate) to combine the twoemb eddings

with contraction op erations. As in BI-MERGE, if one comp onent is added within

an internal face of another, add an edge from each of its sinks to the vertex covering

u in the outer comp onent to resolve the inner sinks. Return the result.

If u = s, isolate a comp onent E of G with resp ect to some fs; v g whichis

triconnected, and let F b e the union of all other fs; v g-comp onents. This is p ossible

b ecause wecho ose 3-connected comp onents to avoid s when non-source cut-sets

exist, and if all cut sets involve one vertex s, then at least one has a triconnected

comp onent. Add the marker edges and determine X and X as ab ove p er Theorem

E F

0

6.15. Call TRI-MERGE with the (E ; ;;X [fu; v g) sub-problem, to test whether

E

E has an upward emb edding satisfying the previous conditions and also having u

and v on the outer face. The cut-set list is emptyas E is triconnected.

CHAPTER 7. AN ALGORITHM FOR UPWARD PLANAR EMBEDDING 57

If TRI-MERGE passes, then E can b e emb edded in a face of F (p ossibly the

0

outer face), so compute the subproblem (F ;L ;X ), merge results according to

F F

the pro of of Theorem 6.15, and resolve the sinks of E which are internal in the

result. Reject if the subproblem fails.

If TRI-MERGE fails, then F cannot haveany x 's (by Theorem 6.16); the

i

emb edding of F must lie strictly within an internal face of the emb edding of E

(i.e. it is not even p ossible for E and F to \together" form the outer face; the

outer face must consist entirely of vertices of E ), so reject if X is not empty.

F

0 0

Call TRI-MERGE with the subproblems (F ;L ; fu; v g) and (E ; ;;X ), merge the

F E

results with the contraction op erations of the algorithm implicit in the suciency

conditions of Theorem 6.16, and resolve the sinks of F which are internal in the

result. Again, reject if either subproblem fails.

Depth rst search is a linear time op eration that can determine all the required

information, such as whether u and v are comparable and the partitions of X and

L. The rst call to TRI-EMBED in the s = u case is with a tri-connected graph

and thus requires only linear time (time for of S-E-UP-PLANAR). Subsequently,

the outer face is chosen, so a constantnumb er of disjoint calls are made to TRI-

MERGE (i.e. no backtracking is required to nd the outer face). In total, we

execute a linear time op eration for each cut-set, of which there are no more than n,

2

followed byan O (n ) time op eration (TRI-EMBED) on some numb er of subgraphs

of G. The total time is thus quadratic.

Algorithm TRI-EMBED:

Compute the faces of the tri-connected input graph G and a planar emb edding

of G using a linear time algorithm [18, 4].

For each face f adjacent to the source, transform the abstract emb edding G

CHAPTER 7. AN ALGORITHM FOR UPWARD PLANAR EMBEDDING 58

of G to have outer face f and test for strongly equivalentupward planarity with

Algorithm MOD-S-E-UP-PLANAR (b elow). The transformation is simply a matter

of cho osing a di erent outer face in the sp eci cation of the abstract emb edding. If

the list of faces is exhausted, ab ort, otherwise return the rst valid emb edding.

Note that if wehave more than just the source (i.e. another vertex or an edge)

sp eci ed to b e on the outer face, then there are no more than a constantnumber

of faces to check.

This step requires a linear numb er of calls to MOD-S-E-UP-PLANAR, since a

planar triconnected graph has a linear numb er of p ossible outer faces [3]. Sp eci -

+

cally, it requires deg s calls if no other vertices are sp eci ed on the outer face and

at most two calls otherwise.

Algorithm MOD-S-E-UP-PLANAR:

Perform the algorithm of S-E-UP-PLANAR, with the following mo di cation:

Whenever a distinguished edge is uncovered, expand it into markers

and edges with all M markers outside of all M markers, all M

t uv t uv t

markers outside all M markers, and all M markers outside all real

uv uv

edges (u; v )of G which are in turn outside all M markers, then continue

s

as b efore.

This step requires only lo cal changes and the time is still prop ortional to the

numb er of marker comp onents hidden in the given edge, whichislinearover the

total time of the algorithm. Thus MOD-S-E-UP-PLANAR runs in linear time.

Chapter 8

Drawing Upward Planar Graphs

Here we wish to address the issue of constructing a physical drawing from the

abstract representation constructed thus far. This is straightforward, since the

output of the algorithm of Chapter 7 is an upward planar emb edding G of G (with

all internal sinks resolved by extra edges). All sinks are on the outer face, so a

new vertex t can b e added to the outer face and connected to eachsinkof G and

to s (also on the outer face if G is to b e upward planar). The result is then a

representation of a planar st-graph, and we can then apply the known algorithms

of either Chiba and Nishizeki [6] or DiBattista and Tomassia [10 ] to give a drawing

(in linear time for a monotonic drawing or \O (n log n)" time for a straight-line

drawing), and then remove the dummy edges.

Recall that the straight-line algorithm is output sensitive, and with time mea-

sured on this basis, can take p ossibly exp onential time, as discussed in Section 3.4.

This is, however, optimal for the output sensitive case. 59

Chapter 9

Conclusions

Wehavegiven a linear time algorithm that tests whether a given single source

acyclic digraph is upward planar strongly equivalenttoa given planar emb edding,

and gives representation of this drawing if it exists. Wehaveusedthisresulttogive

2

an ecient O (n ) algorithm to test for upward planarity of a single source acyclic

digraph.

Alower b ound for the single-source upward planarity problem is not known,

although we b elievethatitmay b e p ossible to p erform the entire test in sub-

quadratic (p erhaps linear) time. An obvious extension of this work would b e to

nd such an algorithm or provea lower b ound.

This thesis has concentrated on the issues of eciently testing for an upward

planar emb edding and outputting an abstract representation of suchanemb edding.

However, by illustrating how the input graph can b e emb edded within a planar st-

graph, wehave also shown howtotakeadvantage of known metho ds for constructing

aphysical upward plane drawing of the graph.

Although it is not p ossible to achieve sub-exp onential area in drawing an arbi- 60

CHAPTER 9. CONCLUSIONS 61

trary upward planar graph, it would b e an interesting problem to guarantee sub-

exp onential area where p ossible and to characterize the class of upward planar

graphs requiring exp onential grid-size. Guaranteeing minimum area in all cases is,

however, NP-hard [29].

The more general problem of testing for an upward planar drawing of an arbi-

trary acyclic digraph is op en. The only known characterization is that any such

graph is a subgraph of an upward planar graph with a single source and sink [10 ].

Bibli og raphy

[1] A.V. Aho, J.E. Hopcroft and J.D. Ullman. The Design and Analysis of

Computer Algorithms. Addison-Wesley, Reading, Mass., 1974.

[2] G. Birkhoff. LatticeTheory, 3rd ed. Amer. Math. So c., Providence, R.I.,

1967.

[3] J.A. Bondy and U.S.R. Murty. Graph Theory with Applications. MacMil-

lian Co. New York, 1976.

[4] K.S. Booth and G.S. Lueker. Testing the consecutive ones property, inter-

val graphs, and graph planarity using PQ-tree algorithms. J.Comput.Syst.Sci.

13, pp. 335-379, 1976.

[5] N. Chiba, T. Yamanouchi and T. Nishizeki. Linear algorithms for convex

drawings of planar graphs,in Progress in Graph Theory (J.A. Bondy and U.S.R.

Murty eds.) Academic Press, New York. pp. 153-173, 1984.

[6] N. Chiba, T. Nishizeki, S. Abe and T. Ozawa. Alinear algorithm for

embedding planar graphs using PQ-trees. J.Comput.Syst.Sci. 30,1, pp. 54-76,

1985.

[7] M. Chrobak. Alinear-time algorithm for drawing a planar graph on a grid.

Manuscript, Univ.Calif.Riverside,1988. 62

BIBLIOGRAPHY 63

[8] H. DeFraysseix, J. Pach, and R. Pollack. Smal l sets supporting Fary

embeddings of planar graphs. Pro c. 20'th Annual Symp osium on the Theory of

Computing, pp. 426-433, 1988.

[9] G. DiBattista, W. Liu and I. Rival. Bipartite graphs, upwarddrawings,

and planarity. Universita Degli Studi di Roma, "La Sapienze", TR RAP.05.90

(1990).

[10] G. DiBattista and R. Tomassia. Algorithms for plane representations of

acyclic digraphs. Theoretical Computer Science 61, pp. 175-178, 1988.

[11] G. DiBattista and E. Nardelli. An algorithm for testing planarity of

hierarichical graphs,inGraph-Theoretic Concepts in Computer Science, Lecture

Notes in Computer Science 246. (Springer, Berlin), pp. 277-289, 1987.

[12] G. DiBattista, R. Tomassia and I.G. Tollis. Arearequirement and

symmetry display in drawing graphs. Pro c. ACM Symp osium on Computational

Geometry, pp. 51-60, 1989.

[13] P. Eades, X. Lin, and R. Tamassia. A new approach for drawing a hierar-

chical graph. Pro c. Second Canadian Conference on Computational Geometry,

J. Urrutia ed., August 1990.

[14] S. Even. Graph Algorithms. Computer Science Press, Ro ckville, Maryland,

1979.

[15] S. Even and R. Tarjan. Computing an st-numbering, Theoretical Computer

Science 2, pp. 339-344, 1976.



[16] I. Fary. On straight line representing of planar graphs. Acta. Sci. Math. (Szeged) 11, pp. 319-321, 1948.

BIBLIOGRAPHY 64

[17] S. Foldes, I. Rival and J. Urrutia. Light sources, obstructions and spher-

ical orders. UniversityofOttawa TR-88-32, August 1988.

[18] J. HopcroftandR.Tarjan. Ecient planarity testing.J.ACM 21,4, pp.

549-568, 1974.

[19] H. Hopcroft and R.E. Tarjan. Dividing a graph into triconnectedcom-

ponents. SIAM J. Comput. 2, pp. 135-158, 1972.

[20] D. Kelly. Fundamentals of planar ordered sets. Discrete Math 63, pp. 197-

216, 1987.

[21] D. Kelly and I. Rival. Planar lattices. Can. J. Math., Vol XXVI I, No. 3,

pp. 636-665, 1975.

[22] A. Lempel, S. Even, and I. Cederbaum. An algorithm for planarity test-

ing of graphs,in TheoryofGraphs, International Symposium, Rome,P. Rosen-

stiehl, Ed., Gordon and Breach, N.Y. pp. 215-232, (1967).

[23] T. Nishizeki and N. Chiba. Planar Graphs: Theory and Algorithms. Annals

of Discrete Mathematics 32, Elsevier Science Publishing Company, Inc. New

York, 1988.

[24] C.R. Platt. Planar lattices and planar graphs.J.Comb. Theory (B) 21, pp.

30-39, 1976.

[25] R. Read. New methods for drawing a planar graph given the cyclic order.

Congressus Numerantium Vol. 56, pp. 31-44, 1976.

[26] I. Rival. Order, invariance and visibility.University of Ottawa TR-89-47,

November 1989.

BIBLIOGRAPHY 65

[27] W. Schnyder. Embedding planar graphs on the grid. Pro c. First ACM-SIAM

Symp osium on Discrete Algorithms, pp. 138-148, 1990.

[28] R.E. Tarjan. Depth- rst search and linear graph algorithms.SIAMJ.Com-

put. 1,2, pp. 146-159, 1972.

[29] R. Tamassia and P. Eades. Algorithms for drawing graphs: an annotated

bibliography.Brown University TR CS-89-09, 1989.

[30] C. Thomassen. Planar acyclic orientedgraphs. Order 5, pp. 349-361, 1987.

[31] C. Thomassen, Planarity and duality of nite and in nite graphs. J. Combin.

Theory B 29, pp. 244-271, 1980.

[32] W.T. Trotter. Graphs and partial ly ordered sets,inSelectedTopics in

Graph Theory 2 (L.W. Beineke and R.J. Wilson, editors), Academic Press,

New York. pp. 237-268, 1983.

[33] W.T. Tutte. Convex representations of graphs. Pro c. London Math. So c.

Vol.10, pp. 304-320, 1960.

[34] W.T. Tutte. How to draw a graph. Pro c. London Math. So c. Vol.3, No.13, pp. 743-768, 1963.