Chapter 9 Drawing Algorithms
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 9 Drawing Algorithms During the last decades manydrawing algorithms have b een describ ed in the lit- erature, b oth from the theoretical and the practical p ointofview. The problem of nicely drawing a graph in the plane has received increasing attention due to the large numb er of applications. Examples include VLSI layout, algorithm an- imation, visual languages and CASE to ols. In Chapter 1 some more detailed examples are presented. Several representations are p ossible. Typically,vertices are represented by distinct p oints in a line or plane, and are sometimes restricted to b e grid p oints. Alternatively,vertices are sometimes represented by line seg- ments [58, 89, 96, 104 ]. Edges are often constrained to b e drawn as straight lines [15, 31 , 32 , 34 , 58 , 80, 89, 96 , 98 , 104 ] or as a contiguous line segments, i.e., when b ends are allowed [100 , 102 , 105 , 106 ]. The ob jectiveisto ndalayout for a graph that optimizes some cost function such as area, minimum angle, numb er of b ends, or that satis es some other constraint. In [18], Di Battista, Eades, Tamassia & Tollis give a go o d annotated bibliography with more than 250 references including several p ointers to applications in whichdrawing algorithms app ear. In this section we describ e several techniques in more detail, which deal with undirected planar graphs. Wedonothavetheintention of b eing complete in our overview, but we try to give the more recent general techniques that leads to interesting theoretical and practical b ounds. The algorithms serve as a starting p oint for the new results, presented in Part C. 9.1 Straight-line Drawings By a result, indep endently obtained byWagner [113 ], F ary [31] and Stein [99], every planar graph can b e drawn in the plane with straight-line edges. This is also obtained by the following constructive pro of, due to Read [92 ]: assume G is a triangular planar graph. If G is not triangulated, then in linear time we can add edges such that G is triangulated, see Chapter 6. By planarity one can verify that every vertex v of G has at least one neighbor u suchthat u and v have exactly two neighb ors in common. 115 116 Drawing Algorithms If v do es not b elong to the outerface, then wecontract edge u; v , i.e., we add edges from u to all neighb ors of v ,which are not a neighbor of u yet, and removevertex 0 v .We draw the reduced graph G with n 1vertices recursively. Afterwards we remove the added edges from u to the previous neighb ors of v and place v inside the corresp onding face suchthatv is visible from its previous neighb ors. This gives a drawing with straight-line edges. Using the observation that every planar graph G has a vertex v with degv 5, we can implement this algorithm such that it runs 2 in O n time, requiring O n space [92]. a a a a b b w u v u v u v c d c d b c b c d d Figure 9.1: The basic concept of Read's drawing algorithm. A drawback of this algorithm is that vertices are placed on real co ordinates. Moreover, it sometimes distributes the vertices unevenly,thus requiring high-reso- lution display devices for a drawing, since the vertices can b e placed very close to each other this is called clustering. Using a more advanced and deep er characterization of planar graphs one can drawevery triangular planar graph planar with straight lines such that the vertices are placed on grid co ordinates. A metho d for this, describ ed bydeFraysseix, Pach &Pollack [34 ] will b e outlined in Chapter 10. Indep endently,Schnyder [98] obtained a linear time algorithm to draw a triangular planar graph on an n 2 n 2 grid, based on a novel representation of triangulated planar graphs, called the barycentric representation. The vertices are widely distributed on the grid, and there is a lower 2 b ound on the minimum edge length. Planar drawings require an n area in the worst-case [34 ]. However, a drawback of all these drawing algorithms is that the minimum angle b etween lines can b e very small, whichmakes the drawing unattractive. In [80], Malitz & Papakostas showed that every d-planar graph G can d b e drawn in the plane such that the minimum angle is at least radians, where 0 < <1 is a constant approximately 0.15. This follows by the remarkable result that one can representevery vertex v of a triangular planar graph G by a closed disc D v such that if u; v 2 G, then the discs D uandD v touch each other a so-called disc-packing. A disc packing D induces a planar graph G in the obvious way: place a vertex at the center of each disc and for each pair of touching discs, create an edge b etween the vertices at the centers of the two discs. Unfortunately,the pro of is non-constructive, and the minimum angle is quite small. A p olynomial-time 9.2 Convex Drawings 117 approximation of a disc-packing realization, and a nice generalization to triconnected planar graphs is announced by Mohar p ersonal communication. On the other hand, G can b e drawn non-planar with straight lines such that 1 the minimum angle is at least , by a result of Formann et al. [32]. They also d proved that deciding whether a graph with maximum degree 4 can b e drawn with is NP-complete. In Kant [66]ititisproved that deciding minimum angle 2 whether a biconnected planar graph can b e drawn planar with the minimum angle K is NP-complete. 9.2 Convex Drawings Another way for drawing planar graphs is bydrawing it with convex faces, i.e., a planar straight-line drawing such that all internal face b oundaries are convex p olygons. This problem of obtaining convex drawings was rst studied in more detail byTutte [110 ]. Tutte also gave a simple metho d for nding a convex drawing. Here the external face is any prescrib ed convex p olygon and the p osition P v = xv ;yv of eachvertex v is given by X X 1 1 xv = xw y v = y w degv degv v;w2E v;w2E Using Gaussian elimination the co ordinates can b e found by a simple algorithm, 3 2 working in O n time, and requiring O n space. Using a more sophisticated sparse matrix elimination scheme which relies on the planar separator theorem, this leads p to an O n n algorithm, requiring only O n log n space [79]. Thomassen [109] characterized the class of planar graphs that admit a convex drawing. We do not give the full characterization here, but it can b e describ ed as the class of biconnected planar graphs, where \almost" all separation pairs are part of the outerface. Based on this characterization, Chiba et al. [14] presentanO n time recursive algorithm, which can b e outlined as follows: assume an outerface F of the biconnected planar graph G has b een chosen, assume that all vertices v 2 F are placed, and that vertices of degree two are eliminated, while connecting their neighb ors. The vertex of degree 2 can later b e placed on the straight-line segment joining the twovertices adjacent to it. The remaining part of the algorithm is as follows: ConvexDrawG; f assume n 4, otherwise G is drawn as a triangle g let v be a vertex, which is a corner p oint of the outerface; 0 let G := G fv g; 0 let B ;:::;B b e the blo cks of G ; 1 p let for each B , v and v be twocutvertices of B ,withv; v ; v; v 2 E ; i i i+1 i i i+1 place the vertices on the outerface of every B onaconvex area i inside triangle v; v ;v such that: i i+1 118 Drawing Algorithms v vp+1 v1 Bp B1 v v 2 Bp−1 p B 2 .... v3 vp−1 Figure 9.2: Drawing a planar graph convex from [14 ]. the vertices adjacentto v are corner p oints of a convex p olygon; the other vertices are on straight-line segments of this p olygon; for each blo ck B do ConvexDrawB rof; i i End ConvexDraw See Figure 9.2 for an idea of the algorithm, and see [14] for a complete descrip- tion. In [13 ], Chiba et al. extended the algorithm to general planar graphs such that the outerface of eachdrawn triconnected comp onentisdrawn as a convex p oly- gon. Unfortunately, exp eriments showed that this algorithm sometimes distributes unevenly,thus requiring high-resolution display devices. 9.3 Drawing Planar Graphs Using the st-Numb e- ring Several drawing algorithms for planar graphs are based on the st-numbering. An st-numb ering is a numb ering of the vertices v ;:::;v of G suchthatv ;v 2 E 1 n 1 n and every vertex v 1 <i<nhasedgestovertices v and v ,with k<i<l.This i k l is only p ossible when G is biconnected, hence assume G is biconnected. Otherwise, dummy edges can b e added to G to make G biconnected while preserving planarity. See Chapter 4 for an extensiveinvestigation of this augmentation problem. The dummy edges are suppressed in the nal drawing. The st-numb ered graph is called an st-graph .