Upward Planar Drawing of Single Source Acyclic Digraphs
Total Page:16
File Type:pdf, Size:1020Kb
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 Lubiw. 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 directed acyclic graph 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<v. ::::::::: 46 ix 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 planar graph 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.