drawing planar graphs using the canonical ordering · 2005-08-15 · drawing planar graphs using...

29
Algorithmica (1996) 16:4-32 Algorithmica c~. 1996 Springer-Verlag New YorkInc. Drawing Planar Graphs Using the Canonical Ordering I G. Kant 2 Abstract. We introduce a new method to optimize the required area, minimum angle, and number of bends of planar graph drawings on a grid. The main tool is a new type of ordering on the vertices and faces of triconnected planar graphs. Using this method linear-time-and-space algorithms can be designed for many graph-drawing problems. Our main results are as follows: Every triconnected planar graph G admits a planar convex grid drawing with straight lines on a (2n - 4) • (n - 2) grid, where n is the number of vertices. Ever), triconnected planar graph with maximum degree 4 admits a planar orthogonal grid drawing on an n • n grid with at most [3n/2] + 4 bends, and ifn > 6, then every edge has at most two bends. Every planar graph with maximum degree 3 admits a planar orthogonal grid drawing with at most [n/2J+ I bends on an [n/2J x [n/2J grid. Every triconnected planar graph G admits a planar polyline grid drawing on a (2n - 6) x (3n - 9) grid with minimum angle larger than 2/d radians and at most 5n - 15 bends, with d the maximum degree. These results give in some cases considerable improvements over previous results, and give new bounds in other cases. Several other results, e.g., concerning visibility representations, arc included. Key Words. Graph drawing, Canonical ordering, Linear time, Convex, Orthogonal, Visibility representation. 1. Introduction. The problem of"nicely" drawing a graph in the plane is an emerging area of research that combines flavors of topological graph theory and computational geometry. The large number of applications include VLSI layout, algorithm animation, visual languages, and CASE tools. Several criteria to obtain a high aesthetic quality have been established. Typically, vertices are represented by distinct points in a plane, and are sometimes restricted to being grid points. Alternatively, vertices are sometimes represented by line segments. Edges are often constrained to be drawn as straight lines or as a contiguous set of line segments (e.g., when bends are allowed). The objective is to find a layout for a graph that optimizes some cost function, such as area, minimum angle, or the total number of bends. In the annotated bibliography an up-to-date overview of the recent developments and optimization criteria in graph drawings is given, with more than 300 references [9]. It is well known that every planar graph can be drawn planar with straight lines [ 16], [40], [49], and by more recent algorithms this can be done in linear time and space on a grid of size O(n) • O(n) (e.g., see [7], [181, [21 I, and [39]), where n denotes the number I This work was supported by the ESPRIT Basic Research Actions program of the EC under Contract No. 7141 (project ALCOM II). An extended abstract of this paper was presented at the 33rd Annual IEEE Symposium on the Foundations of Computer Science, Pittsburgh, 1992. This is a revised version of Technical Report RUU-CS-92-33. 2 Department of Computer Science, Utrecht University, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. [email protected]. Received January 29, 1993; revised April 12, 1994, September 8, 1994, and November 16, 1994. Commu nicated by G. Di Battista and R. Tamassia.

Upload: others

Post on 18-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Algorithmica (1996) 16 :4 -32 Algorithmica c~. 1996 Springer-Verlag New York Inc.

Drawing Planar Graphs Using the Canonical Ordering I

G. Kant 2

Abstract . We introduce a new method to optimize the required area, minimum angle, and number of bends of planar graph drawings on a grid. The main tool is a new type of ordering on the vertices and faces of triconnected planar graphs. Using this method linear-time-and-space algorithms can be designed for many graph-drawing problems. Our main results are as follows:

�9 Every triconnected planar graph G admits a planar convex grid drawing with straight lines on a (2n - 4) • (n - 2) grid, where n is the number of vertices.

�9 Ever), triconnected planar graph with maximum degree 4 admits a planar orthogonal grid drawing on an n • n grid with at most [3n/2] + 4 bends, and ifn > 6, then every edge has at most two bends.

�9 Every planar graph with maximum degree 3 admits a planar orthogonal grid drawing with at most [ n /2 J+ I bends on an [n/2J x [n/2J grid.

�9 Every triconnected planar graph G admits a planar polyline grid drawing on a (2n - 6) x (3n - 9) grid with minimum angle larger than 2/d radians and at most 5n - 15 bends, with d the maximum degree.

These results give in some cases considerable improvements over previous results, and give new bounds in other cases. Several other results, e.g., concerning visibility representations, arc included.

Key Words. Graph drawing, Canonical ordering, Linear time, Convex, Orthogonal, Visibility representation.

1. Introduction. The problem of"nicely" drawing a graph in the plane is an emerging area of research that combines flavors of topological graph theory and computational geometry. The large number of applications include VLSI layout, algorithm animation, visual languages, and CASE tools. Several criteria to obtain a high aesthetic quality have been established. Typically, vertices are represented by distinct points in a plane, and are sometimes restricted to being grid points. Alternatively, vertices are sometimes represented by line segments. Edges are often constrained to be drawn as straight lines or as a contiguous set of line segments (e.g., when bends are allowed). The objective is to find a layout for a graph that optimizes some cost function, such as area, minimum angle, or the total number of bends. In the annotated bibliography an up-to-date overview of the recent developments and optimization criteria in graph drawings is given, with more than 300 references [9].

It is well known that every planar graph can be drawn planar with straight lines [ 16], [40], [49], and by more recent algorithms this can be done in linear time and space on a grid of size O(n) • O(n) (e.g., see [7], [181, [21 I, and [39]), where n denotes the number

I This work was supported by the ESPRIT Basic Research Actions program of the EC under Contract No. 7141 (project ALCOM II). An extended abstract of this paper was presented at the 33rd Annual IEEE Symposium on the Foundations of Computer Science, Pittsburgh, 1992. This is a revised version of Technical Report RUU-CS-92-33. 2 Department of Computer Science, Utrecht University, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. [email protected].

Received January 29, 1993; revised April 12, 1994, September 8, 1994, and November 16, 1994. Commu nicated by G. Di Battista and R. Tamassia.

Page 2: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 5

of vertices, f2 (n 2) is also a lower bound for the area of planar straight-line drawings [18]. However, a drawback of these drawing algorithms is that the minimum angle between lines can be very small which makes the drawing unattractive.

A criterion to improve the aesthetic quality is convexity: every interior face must be drawn convexly. Tutte showed that every triconneeted planar graph can be drawn with convex interior faces [47]. Thomassen [46] characterized the class of planar graphs which admit a convex drawing, and Chiba et al. [51 presented a linear-time drawing algorithm for this class. However, the coordinates of the vertices can be reals and a huge number of vertices can be clustered in a small area.

Another representation model is planar orthogonal drawing, in which the vertices are represented by points and edges by alternatingly horizontal and vertical segments, connecting the endpoints. Orthogonal drawings have numerous important applications in the field of VLSI design and graphics. Storer 141] and Tamassia and Tollis [43] presented heuristics to construct an orthogonal representation of a 4-planar (3-planar) graph with at most 2n + 4 bends (resp. n + 2 bends). (d-planar means that the planar graph has maximum degree d.) Every edge is bent at most four times. Tamassia presented an O(n 2 log n)-time algorithm for drawing an embedded 4-planar graph on an n • n grid with the minimum number of bends [42]. If the planar embedding is not given in advance, then the problem is polynomial-time solvable for 3-planar graphs [10], and NP-complete for 4-planar graphs [19]. In particular, Garg and Tamassia showed that it is even NP-hard to approximate the minimum number of bends in a planar orthogonal drawing with an O(n l-~) error, for any E > 0 [19].

In this paper we introduce a new ordering on the vertices and faces of a triconnected planar graph, called the canonical ordering. The canonical ordering can be computed in linear time. Refining the canonical ordering to a lefimost canonical ordering (or lmc- ordering) this leads to a general framework for drawing triconnected planar graphs on a grid, and implies several drawing results (n denotes the number of vertices and d the maximum degree):

1. Every triconnectcd planar graph with n vertices admits a planar straight-line convex grid drawing of area at most (2n - 4) x (n - 2). This is the first algorithm combining the aspects of grid size with convexity. It also implies a new and rather simple proof that every triconnected planar graph admits a convex drawing.

2. Every triconnected 4-planar graph,admits a planar orthogonal grid drawing with at most [3n] + 4 bends on an n • n grid. Ifn > 6, then every edge is bent at most twice.

3. Every 3-planar graph G admits a planar orthogonal grid drawing with at most [n/2J + 1 bends on an [n/2J • [n/2J grid. A nice characteristic is that G has a spanning tree using n - I straight-line edges and all nontree edges have at most one bend.

4. Every triconnected planar graph admits a planar polyline grid drawing on a (2n - 6) • (3n - 9) grid, with minimum angle > 2/d and at most 5n - I5 bends totally (we call this the mLred model). Every edge has at most three bends. According to our opinion, this is the first practical drawing algorithm, having good bounds on the area, number of bends, and minimum angle. This result is extended to general planar graphs as well.

The paper is organized as follows: in Section 2 we give some necessary definitions. In Section 3 we present the canonical ordering and the general drawing framework. In Sections 4, 5, and 6 we present the drawing results for convex drawing, orthogonal

Page 3: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

6 G. Kant

drawing, and the mixed model, respectively. Section 7 contains some final remarks and directions for further research.

2. Definitions. LetG = ( V , E)beaplanargraphwithn verticesandmedges. Agraph is called planar if it can be drawn without any pair of crossing edges. An embedding of a planar graph is the collection of circular permutations of the edges incident upon each vertex in a planar drawing of the graph. An embedded graph is a planar graph equipped with an embedding. An embedded graph divides the plane into a number of faces. The unbounded face is the exterior face or outerface, all other faces are called interior faces. Edges and vertices, belonging to the outerface, are called exterior edges and exterior vertices, respectively; the other edges and vertices are called interior edges and interior vertices. An interior edge, connecting two exterior vertices, is called a chord.

deg(v) denotes the degree of v, i.e., the number of neighbors of vertex v. A k-planar graph is a planar graph with maximum degree k. The induced subgraph on the vertices v~ . . . . . vk consists of the vertices vl . . . . . vk and the edges (vi, vj) with 1 _< i, j _< k. G - {v} denotes the graph after deleting vertex v and its incident edges from G. G is called k-connected if deleting any k - 1 vertices and incident edges from G preserves the connectivity. 2- and 3-connected are also called biconnected and triconnected, respec- tively. A vertex, whose deletion disconnects the graph, is called a cutvertex. A set of two vertices, whose deletion disconnects a graph is called a separation pair. It is well known that if the planar graph is triconnected, then its embedding is unique (up to chosing an exterior face). A path between two vertices x and y is an alternating sequence of vertices and edges such that x and y are at the end of this sequence and each edge in the sequence is preceded and followed by its end vertices. If the vertices on the path have degree 2, then the path is called a chain.

A drawing such that each edge is represented by a polygonal chain is a polyline drawing. There are two common special cases of this standard. A straight-line drawing maps each edge into a straight-line segment. An orthogonal drawing maps each edge into a chain of horizontal and vertical segments. In a convex drawing every interior face is mapped to a convex region, i.e., ever), angle of an interior face has size <_ n. Note that polyline drawings can be modified to give drawings with nicely curved edges, also called splines. A polyline drawing is a grid drawing if the vertices and the bends of the edges have integer coordinates. See also [9] for more definitions and illustrating figures, not presented here. In our drawing "algorithms we denote the position of vertex v by P(v) : (x(v), y(v)). All graphs considered in this paper are planar, and all corresponding drawings are planar as well, and drawn on a grid. Several other definitions and explaining figures, not presented here, are presented in the following sections when we need them.

3. The Canonical Ordering and Drawing Framework.

3.1. The Canonical Ordering. In this section we introduce the canonical ordering for triconnected planar graphs. In the next section we refine it to a leftmost canonical ordering, to get a linear-time drawing framework.

Page 4: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 7

Canonical Ordering. Let G = (V, E) be a triconnected plane graph with a vertex vl on the exterior face. Let rr = (V~ . . . . . VK) be an ordered partition of V, that is, Vl U . . . tO Vx = V and Vi A Vj = 0 for i =fi j . Define G~ to be the subgraph of G induced by VI tO �9 �9 �9 t3 Vk, and denote by Ck the exterior face of Gk. We say that Jr is a canonical ordering of G if:

�9 V 1 consists of {vl, v~}, where v2 lies on the outefface and (UI, '/)2) E E. �9 Vx is a singleton {v.}, where v. lies on the outerface, (vl, v~) 6 E, and v. r v2. �9 Each Ck (k > 1) is a cycle containing (Vl, vz). �9 Each Gk is biconnected and internally triconnected, that is, removing two interior

vertices of Gk does not disconnect it. �9 For each k in 2 . . . . . K - 1, one of the two following conditions holds:

(a) Vk is a singleton, {z}, where z belongs to Ck and has at least one neighbor in G - G k .

(b) Vk is a chain, {zl . . . . . ze}, where each zi has at least one neighbor in G - G~, and where Zl and ze each have one neighbor on Ck-l, and these are the only two neighbors of Vk in Gk_ I.

THEOREM 3. !. Every triconnected planar graph G with predefined vertex V l on the exterior face has a canonical ordering.

PROOF. Let G be a triconnected planar graph with vl given in advance. The decompo- sition of the vertices in VI . . . . . Vx will be defined by reverse induction. Let v2 and v~ be the neighbors of ol, also belonging to the exterior face. Notice that, by triconnectivity of G, the graph G,,_I =- G - {v,,} is biconnected and the outcrface C~-I is a cycle, containing (vl, v:).

Let 2 < k < K be fixed. Assume that Vi has already been determined for every i > k such that the subgraph Gk satisfies the conditions of the canonical ordering. Let Ck : v~ = Cl, ca . . . . . Cq-l, Cq = v2 be the corresponding outerface. Notice that if there are vertices v c Gk of degree 2, then v E Ck. Notice also by triconnectivity of G that there are at least three vertices c,~, c/~, c• ~ Ck having edges to vertices in G - G~. Assume without loss of generality that c,~ ~ v~, v2. If Gk is triconnected, then we take Vk = {c~ } because, by triconnectivity, c~ has at least three neighbors in Gk and Gk - c,~ is biconnccted.

Assume further that Gk is not triconnected, hence Gk contains separation pairs. Let vx, Vy be a separation pair, and let Gl, G2 be two components of Gk -- {Vx, v~,}. Since G is triconnected, there is a path P between G 1 and G2 in G, not visiting vx and vy. In Gk, vx and Vy are forming a separation pair, hence the edges of path P are removed in Gk. Since we defined the ordering by reverse induction, we removed only vertices and edges from the outerface. Hence path P goes between two vertices c~,, cy,, belonging to Ck with c~, ~ G l and cy, c G2. This yields that v~ and oy belong to Ck and one path between v~ and Vy on Ck is part of G l ; the other path on Ck between v~ and v~, is part of G2. This holds for every separation pair v~, v,., hence all vertices of the separation pairs belong to Ck.

Let ca, c~, be a separation pair such that b - a is minimal. If deg(ca+l) > 2, then there is a vertex c,~, a < ot < b, with at least one edge to a vertex deleted in step j > k,

Page 5: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

8 G. Kant

otherwise the graph G - {c~, cb} is d isconnected,which contradicts the triconnectivity

of G. By minimality of b - a, c,, is not part of a separation pair in Gk, hence Gk - c~ does not have a cutvertex and the outerface of Gk - c~ is biconnected. We take Vk = {c,,}.

Assume now that there is no separation pair c~, Cb with deg(c~+t) > 2. Then b = a +2, because c, and c,+2 are the only neighbors of c,,+j in Gk. Let now ! _< a ' _< a and b < b' < q besuchthat all verticesc~,+l, c,,+2 . . . . . Cb'-l have degree 2, anddeg(c~,) > 2 i f a ' > 1 and deg(c~,,) > 2 i f b ' < r. Notice that v l , w r {c,,+l . . . . . Cb'--l} and every v e r t e x c i , a ' < i < b', has an edge to G - Gk. If edge (c,, ,ch,) ~ G, then Gk - {c~,+l . . . . . Ch'-l} is biconnected and we set Vk = {c~,+l . . . . . cl,,-1 }.

Assume finally that (ca', Cb,) r G. Let F be the face in Gk, containing the vertices ca,, ca,+1 . . . . . cu. Wc claim that the path P in F between ca' and oh, not containing

ca'+l . . . . . Cb'+l, does not contain another vertex on the outerface of Gk. Suppose not, i.e, the path P contains a vertex Cd on the outerface of Gk. Suppose without loss of

generality 1 < d < a ' . However, it now follows that Cd+l . . . . . c,,_ I is a chain of vertices of degree 2. Since (Cd, Ca') q{ G it follows that deg(c~,) = 2, which is a contradiction. Hence Gk - {c~,f 1 . . . . . Cb; } is biconnected and we set Vk = {c~,+l . . . . . co,- 1 } ' []

If Vk = {zl . . . . . ze} with e > 1, then precisely one face is added, otherwise one

vertex is added to G k - l . The algorithm for computing the canonical ordering is based on the proof of Theorem 3.1: we start with the entire graph G, and in each step we delete a face or vertex. For this we introduce the variables outv(F) and oute(F) for each face

F , denoting the number of vertices and edges of F belonging to the current outerface. We also introduce a variable sepf(v) for every vertex v, denoting the number of incident faces of v, containing a separation pair. We call a face with a separation pair a separation

face. Using these variables we can prove the following theorem.

THEOREM 3.2. For ever)' triconnected planar graph a canonical ordering can be com- puted in linear time and space.

PROOF. Let an embedding of the triconnected planar graph G be given. Let every vertex v and edge e have pointers to the faces they belong to. Initially all variables outv(F), oute(F), and sepf(v) are set to 0. We take an arbitrary face F,,,,, as the outerface during the algorithm. Assign vl with neighbors v2 and v~ on Four. In every step we remove vertices from G and update F,,,,. For every vertex v c Fo,t and every edge e ~ Fo,,, e ~ (vl, v2), we increase outv(F~.) and oute(Fe) for every F,: ~ F,,,t to which

v belongs, and Fe ~ Fo~t, to which e belongs. For every vertex v which becomes part of Fo,t we have to compute sepf(v). Consider

for this problem a face F to which v belongs. We claim that F is a separation face if and only if outv(F) > 3 or if outv(F) = 2 and oute(F) = 0. This follows because, precisely in these cases, F has at least two nonadjacent vertices on the outerface which makes this face a separating face. To compute sepf(v) we simply inspect outwand oute of the incident laces.

A face becomes at most once a separation face, because when outv(F) or oute(F) decreases, then a vertex or edge from F is deleted and F is added to F,,,,t. Every face F with outv(F) = oute(F) + 1 and oute(F) > 2 can be the next face in our ordering, becausc in this case the vertices of F , belonging to the outerface, form a consecutive

Page 6: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 9

/// " ' - \

/ / ' ~<13 ~ 12 / / �9 ~ ~ II / /

/ I 6.,/" / I/ ~ ll~i

/IB \/ o ,I

Fig. 1. A graph with canonical ordering and corresponding variable-values at some step.

sequence. If no such face exists, then a vertex v, with v 5~ Vl, v2 and sepf(v) = 0 and visited(v) > 1 (with visited(v) the number of deleted neighbors of v), can be the next vertex vk in our ordering. By Theorem 3.1, such a face or vertex exists.

The time complexity of the algorithm is the following: every vertex v has deg(v) neighbors and belongs to deg(v) faces. When v becomes part of Four, then updating outv for all incident faces of v requires O(deg(v)) time in total. Computing sepf(v) requires O(deg(v)) time if v becomes part of Four, and O(1) time otherwise. Updating oute of the incident face of an edge e, which becomes part of Fo~t, requires O(1) time. When a face becomes a separation face, then sepf of the other vertices of this face, part of the outerface, must be increased by one. There are at most two vertices and this happens only once, hence requires constant time. Deleting a vertex or face can be done in time, constant in the number of deleted edges. Since Y~. deg(v) = 2m, and m = O(n), this yields a linear time-and-space algorithm. []

See Figure 1 for a graph with corresponding values of the variables visited(v), sepf(v), outv( F), and oute( F).

3.2. The Drawing Framework. The general idea for drawing the graph is to start with edge (Vl, v2), and add in step k the vertices of Vk. In step K vertex Vn is added. Assume without loss of generality that in step 1 vl is drawn furthest left and v2 furthest right. Let Ck-l: c~ = Vl, c2 . . . . . Cq = Vz be the vertices from left to fight on the outefface of Gk_j. When adding the vertices of Vk let ct and Cr be two neighbors of Vk on Gk-l, with l and r as small and as big as possible, respectively. We call ct the leftvertex and Cr the rightvertex. If v ~ Vk, then edges between w, w r Vk,, k' <_ k, and v are called incoming edges of v. The remaining incident edges of v are called outgoing edges, in(v) and out(v) denote the corresponding number.

We place the vertices in such a way on the grid that when adding Vk, the corresponding incoming edges have a downward direction. Moreover, we want to maintain the invariant that the vertices cl . . . . . Cq of Ck remain "visible from the top" during each step. This implies that after adding Vk, vertices c . . . . . . Cq must be "shifted to the right," as well as several interior vertices of Gk-l. However, updating all x-coordinates of the vertices in Gk in each step implies a quadratic running time. To avoid this, we use lazy evaluation:

Page 7: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

10 G. Kant

The exact coordinates of vertices in the current drawing are only computed when they are necessary to compute the insertcoordinates of vertices added in this step. This means that only the exact coordinates of the vertices on the outerface are essential during the insertions. As a first step toward this process, we refine the canonical ordering to the

lefimost canonical ordering, which we call the hnc-ordering from now on.

DEFINITION 3.1. A canonical ordering is a leftmost canonical (lmc-)ordering if we can add in any step a vertex set Vk with leftvertex ct or a vertex set Vk, with leftvertex ct,, and l < l ' holds, then k < k'.

In other words, we take this vertex set Vk, for which the corresponding leftvertex cl is minimal with respect to l. By planarity it follows that the corresponding rightvertex,

say c~, is also minimal with respect to r. To compute the lmc-ordering, we maintain a list Outerface-Stack for the vertices on

the outerface from left to right, implemented as a stack, and initialized as {v2}. Also, the vertex sets Vk of the canonical ordering, with pointers to its left- and rightvertex are stored. Notice that Vk can be added in step k', if all incoming edges of Vk are part of Ck,- i. We now delete vertices from the top from Outerface-Stack until we find a vertex Cr on top, which is the rightvertex of a vertex set V~, not added yet. Let Vk = {zl . . . . . ze} from left to right, then we add ze . . . . . zt in this order to Outerface-Stack. We repeat this step with the updated Outerface-Stack until all sets Vl . . . . . Vr are added. Notice that when rightvertex Cr of some set V~ of the canonical ordering is on top of Outerface-Stack, then all other incoming edges of Vk are left from cr on the current outerface, i.e., Vk can be added to the ordering. Hence every vertex set Vk will be added once to the ordering. This

implies that every vertex will be added once and deleted once from Outerface-Stack. Since the vertices are added from right to left to Outerface-Stack the vertex sets Vk are

added in a leftmost order.

THEOREM 3.3. Given a canonical ordering, an lmc-ordering can be computed in 1inear time.

PROOF. The correctness is shown above. Regarding the time complexity, every vertex v is added to once and deleted once from Outerface-Stack. Testing whether vertex cr on top of Outerface-Stack is the rightmost vertex of some set V~ (not added yet) requires

constant time, which completes the proof. []

In Figure 2 an example of the lmc-ordering is given which will serve as an example for almost all drawing algorithms presented in this paper.

In the drawing algorithms we distinguish the insertcoordinates of vk (when we insert vk by the lmc-ordering) and the endcoordinates of vk (in the complete drawing). We introduce a boolean variable correct(v), denoting whether x(v), with v c Ck, has been recalculated. We also introduce a counter for each vertex v, called shift(v), shift(cr) denotes the value which must be added to all x(ck), with r < k < q, where cl . . . . . Cq is the current outerface Ck. When a vertex v is added by the lmc-ordering, we set correct(v) = .false and shift(v) = 0. Inspect step k. Let cr be the rightvertex of Vk.

Page 8: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 11

15 15

2 5 2 i i

Fig. 2. From a canonical ordering of the graph in Figure I to an lmc-ordering.

We walk along the outerface from cr toward Cl until we find the first true marked correct(ca). Then we walk back from c,~ to Cr. When visiting ct~ (or < /3 < r) we add Y'~<i<~ shift(ci) to x(c~) and set correct(c~) to true, because x(c~) is recalculated. We add ~-~'~,~<i<~ shift(ci) to shift(c~). This approach is correct since the following two lemmas hold in step k.

LEMMA 3.4. All vertices ct~, ot < [3 < r, have correct(ctj) =false.

PROOF. Suppose not. Inspect the first time that a vertex cy on the outerface is encoun-

tered for which correct(cy) = false and correct(cy+l) = true. correct(cy+l) = true means that in a step k' < k, x(Cr+l ) and correct(cy+l ) are recomputed, due to the inser- tion of a vertex set Vk' with leftvertex cr, and l ' >_ y + 1. However, correct(cy) =false means that in step k we add V, with rightvertex c v. This contradicts the definition of the lmc-ordering. []

LEMMA 3.5. r > ct holds for rightvertex c,..

PROOF. Suppose not. correct(cc~) = true means that in a step k' < k we updated x(c,,), due to the insertion of Vk, with leftvertex ct,, l ' > or. Adding Vk with rightvertex Cr in step k implies l ' > r. Since k' < k, this contradicts the definition of the lmc-ordering. []

LEMMA 3.6. The total time for visiting the vertices marked false and updating shift(v), x(v) , and correct(v).for all vertices v is O(n).

PROOF. When we insert Vk in step k with leftvertex ct and rightvertex Cr, extra timc is required for walking toward ct to find the first true marked correct(ca). All correct- values of the vertices c . . . . . . c r - i are marked true after visiting them. If, in a step k' > k, correct(c~) becomes false again (with ~ < /3 < r - i), then a vertex set Vk, with rightvertex c~, = c~ is added, with k' < I. This contradicts the lmc-ordering, hence every correct(cl~) becomes false once and becomes true after visiting ct~ again. Updating requires constant time, hence the total time for visiting the vertices marked .false and updating shift(v), x(v) , and correct(v) for all vertices is O(n). []

Page 9: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

12 G. Kant

These three lemmas show that in any step k we can compute the up-to-date x- coordinates of the vertices Cl . . . . . cr of Ck_l when adding Vk, where cr is the rightvertex of Vk. Le t P ( v ) = (xin~.e,(v), yinse,~(V)) be the coordinates of v at the time of insert- ing v.

However, how can we compute the final x-coordinates of the vertices? To this end we have to traverse the vertices of Vk in decreasing order, i.e., from Vr to Vz, and set initially shi f t (v) = 0 for all v ~ V. When considering the vertices of Vk = {Zl . . . . . z~}, we set shift(el) = shift(z l), with l < i < r, and ct and c~ the left- and rightvertex, respectively, of Vk, and Cl . . . . . Cq the outerface Ck-l of Gk-~. shif t(ct) is not updated (because ct

is not shifted when adding V~ initially). Since Cr is also part of some outerface C~,-I, k' > k, shift(c~) could already be greater than zero at the moment of visiting Vk. The question arises whether this value was also added to the vertices of Vk or not. If this was the case, then this shift-value should not be added to shift(c~) again. How can we solve this problem?

The solution is as follows: to compute the right shift of c~ we distinguish the shifts added to ct+l . . . . . Cr-l and to Cr, by introducing a new variable, rshif t (v) . When con- sidering Vk for computing the final x-coordinates, c~ must be shifted a value x ' more to the right than c~_ l, then we add rshi f t ( z l ) + x ' to rshift(Cr). The final coordinates of the vertices zi . . . . . zt of Vk is now given by x i~ ,~ ( z i ) + shift(zi) + rshift(zi), 1 < i < ~.

The precise values for shift and rshift are given in the next sections, when we present the applications for several graph-drawing representations. We call this method the shift-

method.

4. Convex Drawings. The lmc-ordering is a generalization of the canonical ordering of de Fraysseix et al. [ 18]. We can apply the lmc-ordering and the shift-method to get a linear implementation of the straight-line grid-drawing algorithm of triangulated planar graphs [18]. (In [7] another linear implementation of [18] is described, assuming that the input graph is triangulated.) Moreover, we show that this algorithm can be mod- ified such that we can draw every triconnected planar graph with convex faces on a grid.

The algorithm of [18] is as follows: it maintains a straight-line embedding during every step k of the line-ordering such that:

1. v~ is at (0, 0), v2 is at (2k - 4, 0). 2. If ol = cl , c2 . . . . . Cq = 02 is the outerface of Gk in step k, then X(CI) "< X(C2) <

�9 . . < X(Cq).

3. The edges (ci, ci+l) have slopes + 1 or - 1.

Assume first that G is triangulated, in which case we can add a vertex vk in every step k of the lmc-ordering [18]. Let L (v) be a set of vertices. The idea of the algorithm is the following: when we add vertex vk with leftvertex ct and rightvertex cr then all vertices Ct+l . . . . . Cr-l are shifted one to the right, and the vertices cr, . . . , Cq are shifted two to the right (and, of course, several interior vertices of Gk-i have to be shifted to the right as well). The crossing point of the line with slope +1 from c/ and the line with slope - 1 from Cr denotes the place for vertex vk. We denote this by/z(ct , c~). All vertices ct . . . . . cr are visible from this point. See Figure 3 for the corresponding picture. Let

Page 10: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 13

/~(cl, r

C I + I ) ~ " ' .

c< . . . . . . , , , .

Ok

c t -:~:-, I C.

I) 1 : C 1 U 2 : C, 1 I,ll : C 1 7) 2 ----" Cq

Fig. 3. Idea of the straight-line drawing algorithm.

CI . . . . . Cq be the outerface in each step k. The algorithm becomes now as follows:

Let a canonical ordering Vl . . . . . vn be given

P(vl) := (0, 0); L(vt) : = {Vl};

P(v2) : = (2, 0); L(V2) := {v2}; P(V3) : = (1, 1); L(V3) := {v3}; fork := 4 t o n do

r - I for v ~ [-Ji=t+l L(ci)do x(v) := x ( v ) + 1 rof;

for v E [,-Jq=r L(ci) do x(v) : : x(v) + 2 rof; P(vk) := l~((x(cl), y(c~)), (x(cr), y(c , ) ) ) ;

r - i L(Vk) : : {'Ok} I._J [--Ji:,'+l L(ci)

rof

The correctness of this algorithm is proved in [18]. Using the variables shift(v) and rshift(v), the complete algorithm can be implemented as follows:

LINEARSTRAIGHT-LINEDRAW (G);

Let an lmc-ordering vl . . . . . v,, be given

P(Vl) := P(v2) := (0, 0); fork : = 3 t o n do

update x(cl) and shift(or); shift(Cr) := shift(c~) "4- 2; P(vk) := U((x(ct), y(ct)), (x(cr) + shifi(c~), y(Cr)))

rof; shift(v) : = rshift(v) := 0 for all v c V; for k := n downto 2 do

for every interior neighbor vi of vk do shift(vi) : = shift(vk) + rshift(vk) + lrof; rshift(Cr) : : rshift(Cr) + rshift(vk) + 2; X(Vk) := Xi,,ser,(Vg) + shift(vk) + rshift(v~)

rof; END LINEARSTRAIGHT-LINEDRAW

Moreover, using the line-ordering it is already sufficient that the planar graph is tricon- nected, because when adding Vk --- {zl . . . . . ze}, we can draw z~ . . . . . ze on a horizontal line with distance 2 in between. This yields that edge (el, zl) has a slope +1, edges

(Zl, z2) . . . . . (ze-l, ze) have slope 0 and length 2, and edge (z~, Cr) has a slope - I. It is easy to see that this still gives a correct straight-line drawing on a (2n - 4) x (n - 2) grid.

Page 11: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

14 G. Kant

In the remaining part of this section we modify this new algorithm a little such that all interior faces are convex.

Let Vk be {z l}, and let ci . . . . . . ci, be the vertices on Ck_ i, adjacent to Z l. (il =- l and i~ = r.) Let F s. (1 _< j < s) be the face formed by the edges (Zl, cis), (z l , ci,_,) and the path B/between ci~ and cir,,.

LEMMA 4.1. Each path Bj has the fo l lowing pattern:

�9 From c , / to some vertex cc~, a sequence D j, I Dj I > l, o f vertices with strictly decreasing y-coordinate.

�9 Two vertices c~,, c/jj with the same y-coordinate. �9 From c~j to c#+,, a sequence Uj o f vertices with strictly increasing y-coordinate.

PROOF. By definition of the lmc-ordering, every vertex v ~ Vk has a neighbor w c Vk,, with k' > k. By definition of the algorithm LINEARSTRAIGHT-LINEDRAW it follows that y ( w ) > y (v ) . In step k the vertices c6+l . . . . . %+,-1 have higher-placed neighbors. Let c% be the lowest-placed vertex, with i9 _< or/ < i/+~ and % minimal. If there is a vertex c,~; 4: c~ with y ( c ~ ) = y(c,, ,) , then fl; = c~j + 1, because otherwise there would be a vertex c 7, eej < F < fij, which does not have a higher-placed neighbor. From % to c% the vertices have strictly decreasing y-coordinate and from c~,,+l to c~., the vertices have strictly increasing y-coordinate. []

Notice that all edges on C~_l have slope +1, 0, and - 1 before adding V~. When adding z l, we shift ca, . . . . . c/~_, to the right by one, and shift c~,_, +l . . . . . ci~ to the right by two. As explained above, we draw Zl at point I2(ci,, c~).

When Vk = {Zl . . . . . z~ }, we add only one face/"1. Let B1 be the path of Ck-1 between Q and cr. B~ also has the pattern of Lemma 4.1. We shift c,,~ and c~ to the right by one, and c~+1 . . . . . cr to the right by 2 . g. zl . . . . . ze are placed as explained above. This yields the following slopes after adding Vk:

�9 The slope of edge (ca,-~, ca, ) is in the range [ - 1,0). �9 The slope of edge (ct~,_ , , c~_,+1) is in the range (0, +1). �9 All other slopes on Ck-l are not changed. �9 The slopes of the incident edges of Vk are in the range ( - ~ , - 1 ] U [+1, ~ ) .

This implies that the faces Fl . . . . . F.~-l are convex when inserting Vk at step k. To preserve convexity during the other steps k' > k, we add edges from cij to c~j . . . . . % - 2 (1 < j < s). This does not destroy planarity and implies that ifci, is shifted to the right in some step k' > k, then c~,+l . . . . . c#_ I is also shifted to the right with the same value. The modified graph is still called G. Now we can prove the following lemma.

LEMMA 4.2. 1he faces remain convex during the algorithm.

PROOF. AssumeVk = { z l l , and let ci, (l < j < s ) , c , , ; , c ~ j , a n d F i j ( l < j < s ) beas defined above. (The proof is analogous when [Vkl > 1.) Consider a step k' > k. If ci~ is shifted to the right, then, by the added dummy edges, c~,_ ,+j, ci~-j are also shifted to the right with the same value, thereby preserving planarity in the only relevant face, F~- 1- If

Page 12: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 15

zl is shifted to the right, then the vertices ci~ . . . . . ci, are shifted to the right as well, and if ci, is shifted, then ct%,+~ . . . . . c,_~ and %+~, c~j~_~ are shifted to the fight with the same value. This yields planarity in the faces F1 . . . . . F.,.-l. It also has the consequence that if c~ is shifted to the right (il < i < is), then cv, i < i ' < i~ is shifted to the right with at least the same value.

We use this observation for the case that c~. is shifted to the right in some later step k. Then z~ is also shifted to the right by at least the same value. Hence the vertices Cfl, ~ 1 . . . . . Ci2 are shifted to the right by at least the value of the shift of ci, . . . . . ct~ , . This preserves the planarity in Fl and completes the proof. []

Finally we remove the added dummy edges from cij to ct~ j , c~j + l . . . . . cij-2 ( 1 <__ j _< s).

THEOREM 4.3. There is a linear-time-and-space algorithm to construct a planar straight-line convex drawing o f a triconnected planar graph with n vertices on a (2n - 4) • 01 - 2) grid.

Our algorithm not only outperforms the algorithms of [48] and [5], but is also much easier to implement than the algorithm of [5]. However, a drawback of the algorithm is that the drawings are not strictly convex, compared with those of [48] and [5]. On the positive side, this algorithm gives a new proof that every triconnected planar graph admits a planar drawing, in which every interior face is convex. The outerface is a triangle. With respect to the tightness of the grid size we note that every strictly convex drawing of a cycle with n vertices requires a (-)(n 3) grid 135]. On the positive side, Chrobak and Kant [6] improved the algorithm above such that the required grid is (n - 2) • (n - 2). In Figure 4 the straight-line convex drawing of the graph in Figure 2 is given.

3 4 5 i _ - ~ _ 2

Step 3

13

7 I I2

2

7 s Step 9

I 2

Step 5

4 ~ 13 6 9 I0

I _2 I 2

Step 7 Step 11

Fig. 4. Convex drawing of the graph of Figure 2.

Page 13: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

16 G. Kant

1 L I I

(a) (b)

Fig. 5. l.ower bound of ~ (n - 1) + 2 bends. (a) The graph G5 and (b) the graph G~.

5. Orthogonal Drawings.

5.1. 4-Planar Graphs. In this section we consider the problem of drawing a planar graph G on a rectilinear grid with orthogonal edges, i.e., the edges are polygonal chains of horizontal and vertical segments. The vertices are represented by points.

THEOREM 5. I. There are embedded triconnected 4-planar graphs Gk with 3k + 1 vertices and 6k + 1 edges, for which an), layout requires at least 4k + 2 bends, for any k > l .

PROOF. Consider the triconnected plane graph Gk with 3k + 1 vertices, and its layout in Figure 5(a), which has 4k + 3 bends. Notice that there are no bends in the edges between two white vertices. We delete these edges from the graph. The vertices, which had degree 4 initially, have degree 2 now, and are deleted, while connecting the two incident edges. This leads to a biconnected planar graph G~ with 2k + 2 vertices (see Figure 5(b)). It is shown in Corollary 4 in [45] that the layout in Figure 5(b) of G~ is best possible with respect to the minimum number of bends, which is 4k + 2. If there was a layout for Gk with fewer than 4k + 2 bends, then there was a better layout of G~ with fewer than 4k + 2 bends, which contradicts Corollary 4 of [451, []

Let G be a triconnected 4-planar graph. Let a canonical ordering of G be given. It is not necessary to compute the lmc-ordering of G, since we do not use the shift-method. We introduce a variable mark(v) for each vertex v, which is important when adding Vk = {v} to Gk-i . v has at most two outgoing edges, say to u l and u2 (from left to right). If v is the rightvenex of u l, and v is not the leftvertex of u2, then we set mark(v) = left, otherwise we set mark(v) = right.

There are four directions to connect an edge at v, namely at left(v), right(v), up(v), and down(v). A direction is called free if there is no edge connected in that direction of v yet. The idea for the algorithm is as follows: we add v to Gk-I such that down(v) is not free in Gk. Let c /and cr be the left- and rightvertex of v. We connect (ct, v) at right(ct), if it is free, otherwise at up(or), if it is free, otherwise at left(or). The opposite direction is followed for cr. We want to add v such that when mark(v) = left then left(v) is free

Page 14: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 17

after addition. Since v is the rightvertex of Ul, we can use left(v) for the edge (v, Ul) to the left. When right(u1) is used for (v, ul), then no bends occur in (v, u]), otherwise up(u i) is used, yielding one bend. Similarly for mark(v) = right.

Let v 6 Vk. Recall from Section 3 that in(v) denotes the number of incident edges of v, belonging to sets Vk,, k' < k. out(v) is defined similarly. The algorithm can be described in a more elaborate way as follows:

4-ORTHOGONAL(G); Let a canonical ordering VI . . . . . Vk of G be given; edge (vl, v2) via down(vl) and down(v2); for k := 2 to K - 1 do

Let Vk = {z] . . . . . ze}; �9 if/? = 1 and in(zl) = {ct, ci, cr} then

(ct, zl) via left(zl); (ci, z]) via down(zl); (cr, za) via right(zl );

�9 i fe = 1 and in(zl) = {cl, Cr} then if mark(z l) = left or (lefl(Cr) free and right(Q) not free) then

(zl, ct) via down(zl) and (z], c~) via right(Zl) else

(zl, cD via left(z]) and (zl, Cr) via down(zl); �9 otherwise (g > 1)

if right(Q) is free then (zl, ct) via left(z]) else via down(zl); for / := 2 t o e do

if down (zi- l) is free then (zi- j, zi) via down (zi_ 1) else via right(zi_ ~ ); if mark(zi) = left then (zi- l , zi) via down(zi) else via left(zi);

rof; If left(c~) is free then ( z t - l , z~) via down(z~); (zt, cr) via right(zt) else

(Ze-l, ze) via left(zD; (zt, Cr) via down(zD rof; let cl, ca, ctj, and cr be the neighbors of v.; edges from ct, ca, cp, Cr to V. via left(v.), down(v.) , right(v.), and up(v.) , resp.;

END 4-ORTHOGONAL

See Figure 6 for an illustration of the different cases. There are several ways of computing the coordinates. Here we briefly describe the

method given by Biedl and Kant [2]: Note that the y-coordinate of a vertex is never changed later, so we only have to worry about the x-coordinates. The crucial observation is that we need not know the values of the x-coordinates of the incoming edges of vi when adding vi. We can use the following strategy: throughout the algorithm maintain a list Columns. Every embedded vertex v contains a pointer x(v) to one element of Columns. Whenever we want to add a column, we add a new element in Columns. By storing a list as a sequence of pointers we can do so without changing any of the x-values of vertices already visited. The final x-coordinates are computed by traversing Columns and assigning ascending values to each element. Every vertex and bend then checks the value of the element it points to and stores it as its x-coordinate. This yields a planar orthogonal drawing.

Page 15: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

18 G, Kant

T vl T v2

Starting with (vl, v2).

c l Z 1

I

C i C r I---

Adding zl with in(za)= {ct,ci,c,.}.

ct -'I iz' c~

leJ~ o - - - C r r i g h t

7 c,; l --r c

Adding zl with i n ( z t )= {cl,cr}.

�9 t~ __teyt

left t e ' ~ 4g~ t 3 t e ~ -*~z5 *' z6 O - - - - 2 . . . . 4 i I zj . I Cr i

~?1 f - - . . . . Q . . . .

" , - I

i

c t =v!

cl3 ~ c r - -

Adding z l , . . . , ze. Adding vn.

Fig. 6. Adding vertices and faces to obtain an orthogonal drawing.

LEMMA 5.2. The number of bends is at most r3n] + 3. One edge has at most three bends, all other edges have at truest two bends.

PROOE Let Vk = {zl . . . . . Ze}.Assumefirste > 1. For every vertex zi, down(zi) and either left(zi) o r right(zi) are used. The edge to down(zi) always requires one bend, the others do not. If mark(zl) = right, and right(zl) is used by (zl, z2), then later a bend is required for the outgoing edge via left(z1). A similar condition holds for z~ when mark(zD = left. Hence this implies at most s bends.

l fg = 1, then we have at most two bends if in(z1) = 3, so assume in(zl) = 2. The incoming edge, using down(zl) , gets no bends, the other edge gets one more bend. If right(ct) and up(cr) are both free, then both edges (ct, z l) and (cr, z i) are straight lines (using left(z l) and down(zl ), resp). However, if mark(zj ) = left, then a bend is required for the outgoing edge of z l, using right(zj ). We assign this bend to step k. Similarly when mark(Zl) = right, hence in all cases at most one bend is introduced when in(zl ) = 2.

A similar assignment also follows for edge (vl, v2): we assign the bends, where the

Page 16: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 19

edges use the connect ions left(l) 1 ) or r ight(v2) , to step 1. Summar iz ing this leads to the

fol lowing table:

Number of Number of Number of Step vertices edges bends

1. adding (vl. v2) 2 1 4 k , s I , i n ( z l ) = 2 1 2 1 k,s = 1, in(zj) = 3 1 3 2 k, zl . . . . . zt e g+ 1 e K, adding vn 1 4 4

Consider the steps 2 . . . . . K - 1 in which n - 3 vertices and at most 2n - 5 edges arc

added (since m _< 2n). Adding Vt = {z I } with in(z l) = 3 occurs at most I n /2 ] - 2 times, because then at most 13/2n] - 6 edges are added, and at most [n /2J + 1 edges are added

by at most Ln/21 - 1 vertices. This yields at most 2 ( [n /21 - 2) + Ln/2J - 1 + 8 = [3n] + 3 bends. The edge using up(v, ,) has at most three bends, all other edges have at most two

bends. []

LEMMA 5.3. The gr ids ize is at mos t n x n.

PROOF. The increase in height in step k, 1 < k < K, is at most f., where Vk =

{zl . . . . . ze}. In step i the increase in height is at most one, and in step K two, which proves the total height of n.

For the total width, we consider the different cases for step k, 1 < k < K. Let

Vk : {Zl . . . . . ze}.I fg. > I , t h e n x ( z i ) - x ( z i - I ) = 1(1 < i < s > 1, then there is no increase in width at all in this step, since then X(Cr) - x ( c i ) > s - 1. If (ct, Zl) is horizontal, then this means an increase of one in width. If (ct, z l) is vertical

and m a r k ( z l ) = right, then one outgoing edge of zl has to go via l e f t ( z l ) , hence this also means an increase of one in width later. We assign this increase to step k. A similar

condi t ion holds for (z~, cr). Since X(Cr) > X(CD + i in step k - 1, it follows that the increase in width is at most s in step k.

l f e = 1 and i n ( z l ) = 2, then the width increases by one, due to the fact that an extra co lumn might be necessary for the outgoing edge ofzt via le f t (z l ) when m a r k ( z l) = right

(similarly when m a r k ( z l ) = left). If e = 1 and i n ( z l ) > 3, then the width does not in- crease.

For (v~, v~) we assign the extra columns, required by the outgoing edges via l e f t ( v l )

and r ight(v2) to step 1, y ie lding a starting width of three units. This gives the fol lowing table:

Step Number of vertices Increase in width

1, adding (vl. v2) 2 3 k, g -- 1 and in(zl) = 2 1 1 k , e = landin(7..l)=3 1 0 k , e > l ~ g K, adding v,~ 1 0

This leads to a total width of at most n []

Page 17: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

20 G. Kant

I q l c

~g

14

12 II

I

r

I1

d �9

(a) (b)

12 I I

13

k I m

P

Fig. 7. Orthogonal drawing of the 4-planar graph of Figure 2. (a) Orthogonal drawing and (b) at most 2 bends in every edge.

Indeed, in our solution, the edge using up(vn) has at most three bends, all other edges have at most two bends. How can we avoid the edge with three bends? Even and Granot proved that any orthogonaI drawing of the 4-planar triangulated planar graph on six vertices (octahedron) requires at least one edge with at least three bends [14]. In our case, if there is a vertex v with deg(v) = 3, then we can set v,, = v. Otherwise let n > 6. Then there is a face with at least four vertices, which we choose to be the outerface. Let ct, c,~, c~, cr be the neighbors of v,, from left to right. If edge (v,,, c,.) uses right(or),

then we change the four directions of Cr such that up(c~) is used for (c~, v~). Since mark(c~) = right (by definition), it follows that at most one extra bend is introduced. Moreover, since c~ ~ v2 it follows that all other edges still have at most two bends. This completes the following theorem.

THEOREM 5.4. There is a linear-time-and-space algorithm to construct a planar or-

thogonal grid drawing o f every triconnected 4-planar graph G with n vertices on an

area o f size at most n x n and at most [3n] + 4 bends, such that every edge has at most

two bends and length O(n) i f n > 6.

In Figure 7 thc orthogonal drawing of the graph of Figure 2 is given. In particular, in Figure 7(b) it is shown how to change cr such that all edges have at most two bends. The previous bound on the number of bends was 2n + 4, given by Tamassia and Tollis [43]. Hence our algorithm improves this result considerably for triconnected planar graphs. In the algorithm of Tamassia and Tollis, cvery edge gets at most four bends, hence we also improve this bound. Very recently, Biedl and Kant [21 presented a linear-time algorithm for constructing an orthogonal repesentation of a connected planar graph on an n • n grid, having at most 2n + 2 bends, and every edge is bent at most twice. Notice that at most two bends in every edge is best possible, because if the planar graph contains a separating triangle on the vertices vi, vj, vk, then at least one edge of the separating triangle has at least two bends in any orthogonal drawing.

5.2. Triconnected 3-Planar Graphs. In this section we present a linear-time-and-space algorithm to draw every 3-planar graph with at most Ln/2J + 1 bends on an Ln/2J • Ln/2J

Page 18: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 21

grid. This improves all previous bounds (from [41] and [43]) and matches the worst-case

lower bounds and, hence, is best possible. An interesting side-effect is that there is a

spanning tree using n - 1 straight-line edges. All m - n + 1 < Ln/2J + 1 nontree edges

have at most one bend. 3 Assume first that G is triconnected. By Euler's formula, n is even, m = i n , and

f = n/2 + 2. Let an line-ordering of G be given. Similarly as in Section 5.1 there are

four directions to connect an edge at v, namely at left(v), up(v), right(v), and down(v). Every vertex v (except v~, v2, and v,,) has one outgoing edge, and we connect this edge

via up(v) at v. We start with placing Vl and v2 at (0, 1) and (1, 1). Edge (vl, v2) goes

via down(vl) and down(v2), hence via (0, 0) and (1,0). In step 2 the vertices zl . . . . . z~

of V2 are placed on the horizontal linc between vl and ve, i.e., via right(vl) and left(v2). In every step k, 3 < k < K, we place zj . . . . . zt: also on a horizontal line of height 1 + max{y(ct), y(cr)}, with ct and c~ the left- and rightvertex of Vk. If ~ > 1, then we shift

the drawing such thatX(Zl) = x(ct) andx(ze) = X(Cr). Since in(Vk) = 2 for2 < k < K and in(v,,) = 3, it follows that K = f , with f the number of faces in G. Notice that f = n /2 + 2 (n is even). The complete algorithm can now be described as follows (recall

the definitions of P(vi) and Xi,,.~e~t(Vi) from Section 3.2):

3-ORTHOGONAL Let an lmc-ordering Vj . . . . . VK of G be given.

P(vl) := (0, 1); P(v2) := (I, 1);

f o r k : = 2 t o K - l d o

assume we add z~ . . . . . ze (e > 1), from c/ to Cr ; y(z l) : . . . . := y(ze) := 1 + max{y(c/), y(cr)}; update x(ct) and shift(or); x(zi) : = x(ct) ;

f o r l : = 2 t o g - l d o x ( z / ) : = x ( z l ) + l - l r o f ;

i fg > I then x(zD := max{x(zl) + e - 1, x(cr)+ shift(Cr)}; shift(Cr) := max{shift(Or), x(ze) - x(cr)}

rof;

Let in(v,) = {ct, c~, c~}, P(v,,) := (x(c~), I + max{y(ct), y(c~), y(cD}); for k := K downto 2 do

assume we added z~ . . . . . z~ from ct to c,.;

f o r / := 1 to g do x(zi) := xi,~.ert(zi) + Y~l<j<i shift(z)) rof;

i fe = 1 thenshift(c~) := shift(zl) elseshift(cr) :-- x(ze) - xi,,.,.e,~(cr) to f;

END 3-ORTHOGONAL

LEMMA 5.5. The number of bends is at most n /2 + 2.

3 PROOF. Since m = 7n, we add at most n/2 - 2 times a vertex v with in(v) = 2, each one introduces one bend. The edge (vl, v2) introduces two bends, as well as adding vn. []

LEMMA 5.6. The gridsize is at most n /2 x n/2.

Page 19: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

22 G. Kant

't

20 19

5 8

6

(a)

20

19

18

I3

10

2

I S .

16 17 I ~-' ]

15 - - 1 1 4 113 ')f • _ l

(b) (c)

Fig. 8. Orthogonal drawing of a triconnected 3-planar graph.

PROOF. Edge (1)], v2) gives 1 unit in the X- and Y-direction. Then we add n / 2 - 1

times a face with ~ _> I vertices, increasing the X-direction with at most e - t units and the Y-direction (except the first time) by 1 unit. Adding v~ increases the Y-direction by 1 unit. Counting this together leads to at most n /2 units in X-direction and n /2 units in Y-direction. []

In Figure 8(b) an example is given of a triconnected 3-planar graph. We can change the drawing as follows, such that there is one bend less, and there is a

spanning tree, using only straight-line edges (ifn > 4). Let the vertices of the first drawn face be numbered v~, vi, v i - j . . . . . v3, Vz. We place v~, vi, ui .1 . . . . . 1) 3 on a horizontal line, and place v2 on (x(v3), y(v3) - 1). Let F ' be the other face, to which (v2, v3) belongs. Let vj . . . . . Vk be the other vertices of F ' . We draw vj . . . . . vk on a horizontal line on height y ( v 3 ) , as shown in Figure 8(c). The remaining faces are drawn similarly as before. Notice that using this strategy, every triconnected planar graph G with n vertices can be drawn orthogonally on a grid of size at most n /2 x (n/2 - 1 ), with at most n /2 + 1 bends (n is even), in which there is a spanning tree, using only straight-line horizontal and vertical edges. All nontree edges have at most one bend ( ifn > 4).

We notice that better bounds can be obtained if the dual graph G* of G is a 4-connected planar graph in which all interior faces are triangles. Bhasker and Sahni [ i ] showed that in this case G admits a planar orthogonal drawing with at most four bends on an n x n grid. Their algorithm works in linear time.

5.3. C o n n e c t e d 3 - P l a n a r G r a p h s . To apply the algorithm toconnected 3-planargraphs, we have to split up the graph into its biconnected and triconnected components.

The triconnected components of a biconnected graph G are defined as follows: If G is triconnected itself it is the unique triconnected component. Otherwise let {u, v} be a separation pair of G. Wc partition G into two subgraphs G1 and G2 which have only vertices u and v in common. We continue the decomposition process recursively on G' l = GI + (u, 1)) and G~ = G2 Jr (u, v) until no decomposition is possible. The added

Page 20: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 23

13

16

18 i ~ ~ ~ $ ~ 11

4 (a)

: N !

f 6 - - % _ _

/15,,,~ \ /99~...8 \ " / " \ \ ', ! " ~ 7 )

', 1 ~ 5 ' --

\.2fJ (b)

Fig. 9. Example of a biconnectcd 3-planar graph (a) and its SPQR-tree (b).

edges are called virtual edges. The resulting graphs are each either a triconnected simple graph, or a set of three multiple edges (triple bond), or a cycle of length 3 (triangle). The triconnected components of G are obtained from such graphs by merging the triple bonds into maximal sets of multiple edges (bonds), and the triangles into maximal simple cycles (polygons). The triconnected components are unique.

Next we need the SPQR-tree, a versatile data structure that represents the decompo- sition of a biconnected graph into its triconnected components [ 11 ]. The SPQR-tree T is defined as follows: for every triconnected component we create an R-node, for every polygon an S-node, for every bond a P-node, and for every edge a Q-node. The edges in T are defined as follows: Let u, v be nodes in T. If u is a Q-node, then there is an edge between u and v if the edge represented by u belongs to the triconnected component represented by v. Otherwise there is an edge between u and v if and only if they contain the same virtual edgc added in the same step of the decomposition process. In Figure 9 an example is given of a biconnected graph and the corresponding SPQR-tree.

Let the triconnected component of node bi in T be defined by Bi, and let si and t i be the two vertices of Bi, called the poles, also shared by the triconnected component of parent(bi). Since the maximum degree of G is 3, it follows that the neighbors of a P-node are not R-nodes. Root T at an arbitrary S-node b,., and let bi, and bi2 be the two children of a P-node bi in T. We merge B~, and Bi2 as described above, yielding a cycle. We represent the resulting cycle by an S'-node. In this way we remove all P-nodes from T. We also remove all leaves (which are Q-nodes) from T. Notice that since the maximum degree is 3, the neighbors of an R-node and the parent of an S'-node are S-nodes. The neighbors of an S-node and the children of an S'-node are R- or S'-nodes.

The algorithm for drawing a biconnected 3-planar graph G draws the triconnected components of G in order of visiting the corresponding nodes in the SPQR-tree bottom- up. Let si and ti be the poles of a leaf bi in T:

Page 21: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

24 G. Kant

bi is an R-node. B~ is drawn by the algorithm 3-ORTHOGONAI. with ~q = s~ and 02 ~ ti.

bi is an S'-node. We draw Bi as a rectangle such that s~ and ti are the lower-left and lower-right corners. If one path between si and ti in B~ contains at least two other vertices, then vertices are placed in the other two comer points.

bi is an S-node. Let (si, s;) and (ti, t~) ~ B~, s~ r tl and t{ # s~. Let B; be B~ - {s~, t~ }. Draw B{ as a rectangle with s~ as the lower-left corner, t; as a right comer, and with the other vertices of B; (if any) placed in the other comers. We draw si one below s~ and ti one fight of t{.

Let IBil = n'. It follows that the used area of the described drawings is at most [n' /2J x (Ln'/2J - 1). Let x(bi) = x(ti) - x(si) and y(bi) = y(ti) - y(si).

The idea now is to draw a triconnected component Bj, after all descendants of bj in T are already drawn. Let bi be a child of by. We want to stretch the drawing of Bj such that the edge (si, ti) has width x(bi) and height y(bi), and that Bi can be placed inside without crossing edges.

If hi is an S'- or R-node, then bj is an S-node. We can draw Bj such that (si, ti) is a straight line, and since Bi c a n be drawn such that si and ti have the same y-coordinate, the problem is easily solved. Hence we now assume that bj is an R-node, thus Bj is a triconnected graph and b i is an S-node. We now place B i inside Bj as shown by the templates in Figure 10. By a tedious but rather easy case analysis, the following lemma can be proved:

LEMMA 5.7. After replacing a virtual edge (si, ti) by the corresponding orthogonal drawing o f Bi in an orthogonal drawing of Bj, the total required grid size is at most

L(IBil + IBjl - 2)/2] x (L(IBi[ + I B j l - 2)/2J - 1).

This means that after replacing all virtual edges of Bj by the triconnected compo- nents, we obtain an orthogonal drawing of size Ln'/2J x ([n ' /2J - !), where n' is the number of nodes of the subgraph of G, corresponding to the subtree of T, rooted at bj. We continue this approach until we are at root br of T. If G is not triconnccted, then T contains an S-node, and we assumed that br is an S-node. It is easily observed that no bends are introduced, when we consider an S- or S'-node. Hence the following theorem is obtained:

THEOREM 5.8. There is a linear-time-and-space algorithm to construct a planar or- thogonal drawing of a biconnected 3-planar graph with n vertices on a grid o f size at most Ln/2J • Ln/2J, with at most {_n/2J + 1 bends, and the property that there is a spanning tree of n - 1 straight-line edges, while all nontree edges have at most one bend

( i fn > 4).

In Figure 11 the orthogonal drawing of the graph in Figure 9 is given. We extend the algorithm 3-ORTHOGONAL to draw arbitrary 3-planar graphs orthog-

onally. Assume all biconnected components B~ of G are drawn orthogonally, with the cutvertcx, say vi, in the upper-left comer. (Since vi has degree 2 in Bi and the root of the corresponding SPQR-tree was assumed to be an S-node, this can be reached in

Page 22: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 25

(a) t i

S i

(b)

s; !si

N (c) ~ = ~ (d)

t i t i

l+

sit- ~ ,i

s~

, t~

~ s i t~ ]

, ~ t

(g) (h) - 4 J, ti

Fig. 10. Replacing virtual edges by triconnected components.

(a)

13

12

14 15

17_....

2 1

4 18

3 5

6

9 8 i 7

11 10

(b)

16

Fig. 11. Orthogonal drawing of a biconnected 3-planar graph. (a) Drawing the triconneCted components and (b) the complete drawing.

Page 23: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

26 G. Kant

9

-I I

r

I T! "-r

- - - FT

L

Fig. 12. Orthogonal drawing of the blocks.

every step.) We draw the blocks recursively, and merge it into one drawing, as shown in Figure 12.

No extra bends are introduced in the drawing. Also the required area for drawing blocks B1 and Bj is at most [(IBil + IBjl)/2J x [(Inil + IBjl)/2], which completes the following theorem:

THEOREM 5.9. There is a linear-time-and-space algorithm to construct a planar or- thogonal drawing of a connected 3-planar graph on an Ln/2] x [n/2] grid with at most [;7/21 + 1 bends, and the property that there is a spanning tree o f n - 1 straight-line edges, while all nontree edges have at most one bend (/fn > 4).

In [331 Liu et al. independently proved the same result for biconnected 3-planar graphs, and presented an O(n)-time algorithm for this. In [34] theoretical results are given for planar graphs, which can be embedded with at most one bend per edge.

6. The Mixed Model, In this section we use the drawing framework, introduced in Section 3. l, to draw any triconnected d-planar graph G on a (2n - 6) x (3n - 9) grid such that there arc at most 5n - 15 bends and the minimum angle is at least 2/d radians. All. vertices and bend coordinates will be placed on grid points only. Every edge will have at most three bends and length (D(n).

To this end we define, for each vertex, inpoints and outpoints. The idea is that an edge, say (u, v) goes from u to an outpoint of u, say uo~t, from Uo,t in the vertical direction to a point, say w. From w it goes in the horizontal direction to an inpoint of v, say vi~, and from vin to v. Important question for this are the coordinates of the in- and outpoints.

Recall the definition of in(v) and out(v) of Section 3.2. Let outl (v) = [(out(v) - I ) /2 j and OUtr(V) = [(out(v) - 1)/2]. Similarly for in(v) we define int(v) = [(in(v) - 3)/2.1 and inr(v) = [(in(v) - 3) /2] . The idea is to place the outpoints of v on the following places: the diagonal lines from (x(v) - outz(v), l) to (x(v) - l, y(v) + outl(v)), and from (x(v) Jr-OUtr(V), 1) to (X(V) Jr 1, y(v) + outr(v)), and using (x(v) , y (v) +outt(v)) . For the inpoints it is defined similarly: the diagonal lines from (x(v) - inl(v), - I ) to ( x ( v ) - l, y ( v ) -ou t l ( v ) ) , and from (x(v)+out~(v) , - I) to (x (v )+ 1, y(v)-OUtr(V)), and the three points ( x ( v ) - o u t t ( v ) , y(v)), (x (v), y(v) -ou t z (v ) ) and (x (v )+outr (v ) , y(v)) . See Figure 13 for some examples and the corresponding bounding boxes.

Page 24: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 27

I I I I I I ~ 1 I I

I I I I I

I

Fig. 13. Examples of bounding boxes.

The width of the bounding box is max{out(v) - 1, in(v) - 3}, the height is int (v) + outt (v). The idea is to insert the vertices of the canonical ordering such that the bounding boxes do not intersect or touch. Also, outgoing edges may not cross or overlap, i.e., this means that, for every pair of consecutive vertices ci, Ci+l on the outerface, x(ci+O > x (ci) + OUtr (ci) + outt (ci+1) must hold. We can now explain the different adding steps as follows:

Adding a Vertex v. For the y-direction we simply set y(v) = 1 + max{y(ct) + outl(Cl), y(Cr) + OUtl(Cr)}. In the x-direction the problem is a little more difficult: let u~ . . . . . uin(~) be neighbors of v, corresponding to the left-to-right order of incom- ing edges of v. Let u = uint(v), then we want to have x(v) = x(u), or, in other words, we want to place x(v) right above the most central incoming edge. For the outcoming edges, we want to have x(v) > x(ct) + outr(cl) + ouh(v). Hence we set x(v) = max{x(u), x(c~) + OUtr(Cl) + OUtlO))}, and shift Uinz(v) . . . . . Uin(v)_ 1 to the right (if x(cL) + out~(cl) + outl(v) > x(u)). For the rightvertex Cr we set X(Cr) = max{x(cr), x(v) + out~(v) + OUtl(C~) + 1}.

Adding Zl . . . . . ze, s > 1. Now every vertex zl . . . . . ze has precisely two incoming edges, hence they are placed on a horizontal line at height max{y(ct) + out1(ct), y(cr) + outt (Cr)} + 1. In the x-direction we do not have to deal with the incoming edges, hence we set x(zl) = x(cl) + OUtr(Ct) + outl(Zl) + 1, we set x(zi) = x(zi-1) + outr(Zi_l) + OUtl(Zi) -t- 1 (1 < i < p), and we set x(c~) = max{x(Cr), x(zs +OUtr (ze) -t-OUtl(Cr) q- 1}. Figure 14 makes this more precise.

Analysis of the Algorithm. Using the lmc-ordering and the shift-technique, explained in Section 3.2, it is not difficult to obtain a linear-time-and-space algorithm, satisfying the constraints with respect to width and height, as given in the two relevant steps. Therefore we now consider in detail the number of bends, the size of the minimum angle, and the total grid size.

LEMMA 6.1. The size of the minimum angle is 2/d, where d is the maximum degree of G.

Page 25: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

28

/ ' - \ / 1:1 \

(a) (b)

G. Kant r ~

Fig. 14. Adding vertices in the mixed model. (a) Adding one vertex zl and (b) adding {zl . . . . . ze}.

PROOF. Let v have maximum degree d. The minimum angle, say a , is reached at an outpoint which is neighbored to a horizontal line. If d < 6, then it is easily proved, hence assume d > 6. The size of the angle is arctan(1/out~ (v)) > arc tan( /2 / (d - 2)J). Using the potence series of the arctan we know that, for Ixl < 1, arctan(x) = x - I 3 I 5 i 7 i 3 Since L2/(d 2)J > 2 / ( d 1), we ob ta in tha t ~x + -~x - ~x + . . . > x - ~x . - _ -

a > 2 / ( d - 1) - .~(2/(d - 1)) 3 > 2 /d , which completes the proof. []

LEMMA 6.2. The gridsize is at most (2n - 6) • (3n - 6).

PROOF. For the width notice t ha tx (c i+ l ) = x (c i ) +OUtr(Ci) +outl(Ci+l) holds in every

step on the outerface if y(c ,+l ) ~ y(ci) and x(c i+l ) = x ( c i ) + out~(ci) + outt(ci+l) otherwise. If y(c i+l ) = y(c t ) , then (ci, ci+l) is not an outgoing edge of any vertex. We call (ct, ci+l) in this case unmarked. Counting leads to a horizontal distance of at

most ~ 1_<i <n outt (vi) + out~ (vi) +number of unmarked edges = ~ l_<i <n (out(v i ) - 1) =

2n - 6. Adding one vertex vk requires a larger increase in height per vertex than adding

a face, hence assume we add a vertex Ok in every step. Let the incoming edges of

vertex vk come from vertices ul . . . . . Up, then y (vk ) > maxlsi<_p{y(ui)} + max{1 + inr(V),out~(ul),OUtr(Ur)}. The increase for every vertex ok during the insertions is at most 1 + inr(Vl<) + OUtr(Vk). Summarizing this for all vertices leads to a total distance

in the Y-direction of at most 3n - 6 units. []

LEMMA 6.3. There are at most 5n - 15 bends. Every edge has at mos t three bends and

length (,9(n).

PROOF. All outgoing edges of vertex v, except the one going straight upward, requires one bend in the worst case to go in a vertical direction. We assign these bends to the insertion step of v. Adding a face requires less bends per vertex than adding one vertex, so assume we only add vertices Ok. If in(vk) = 2 and y(c t ) >_ y(cr) , then there will be at most one bend in (cl, vk) and two bends in (Cr, Ok). (A similar situation holds when y(c t ) < y (cr ) . ) In each edge one bend was already assigned to the insertion step o fc t and Cr, hence adding ok with in(ok) = 2 requires at most one bend for the incoming edges. If in(v~) >_ 3, then at most 2 - in(vk) -- 4 extra bends are required for the incoming edges.

Page 26: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 29

15

\ 14

12

S ~ 11

6 7 8 9

13 4 5 / / - -,,

13 /

X Fig. 15. Drawing the graph of Figure 2 with bends.

Edge (vl, v2) requires no bends. Counting this leads to at most a total of 5n - 15 bends. Every edge goes at most once vertically and at most once horizontally, hence requiring three bends in the worst case and, by Lemma 6.2, has length O(n). []

THEOREM 6.4. There is a linear-time-and-space algorithm to construct a planar poly- line grid drawing of a triconnected planar graph with n vertices and maximum degree d ona (2n - 6 ) x (3n - 9 ) grid with at most 5n - 15 bends and minimum angle > 1 / ( d - 2 ) , in which ever3' edge has at most three bends and length O(n).

In Figure 15 the drawing of the graph of Figure 2 is given. Notice that Kant [291 proved that every graph G can be augmented by adding edges

to a triconnected planar graph G' such that d' < [23-d] § 3, with d and d' the maximum degree of G and G', respectively.

THEOREM 6.5. There is a linear-time-and-space algorithm to construct a planar poly- line grid drawing of a planar graph with n vertices and maximum degree d on a (2n - 6) x (3n - 9) grid with at most 5n - 15 bends and minimum angle > 4/(3d + 1), in which every" edge has at most three bends and length O(n).

7. Final Remarks and Open Problems. In this paper a new ordering of the vertices and faces of a triconnected planar graph is introduced. This ordering leads to various algorithms for drawing a planar graph on a grid. In some cases considerable improve- ments on existing results are obtained, in other cases new bounds are achieved. All the algorithms can be implemented by straightforward techniques to run in linear time and space. Instead of using the shift-method, explained in Section 2, we could also use the sophisticated technique of Chrobak and Paync. They build a tree on the vertices, where the edges contain the amount of shift for every edge. When applying this techique for our canonical ordering, there is no reason to compute a lefimost canonical ordering. This is described in more detail in [6]. In this paper the line-ordering is required in all algorithms, except the algorithm 4-ORTHOGONAL, where a canonical ordering is already sufficient.

Page 27: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

30 G. Kant

: 4

21 , : Z

Fig. 16. The visibility representation of the graph of Figure 2.

Since every canonical ordering is also an st-ordering, wc can use the canonical order- ing in various drawing applications, where the st-ordering is used. As an example, con- sider the visibility representations. In a visibility representation every vertex is mapped to a horizontal segment, and every edge is mapped to a vertical line, only touching the two vertex segments of its endpoints. See [38] and [44] for linear-time algorithms of this and Figure 16 for an example. By using the lmc-ordering with shift-values on the edges we are able to obtain a linear-time framework as well. The description of the complete algorithm is not significantly different from the other algorithms, described in this paper, and is left to the reader. (Independently, Nummenmaa [37] also presented a visibility presentation algorithm, based on the canonical ordering of triangular planar graphs.) As in the other algorithms for visibility representations (e.g., see [26], [37], [38], and [44]) the grid size is at most (2n - 5) x (n - 1).

If, for every vertex vi, OUt(•'i) >_ 2 holds, then our algorithm leads to a visibility representation on a grid of size at most (n - 1) • (n - 1). Kant and He [31 ] proved that such a canonical ordering is possible for 4-connected triangular planar graphs. Moreover, using this result, Kant [30] proved that a visibility representation of a general planar graph can be constructed on a grid of size at most (L-~nJ - 3) • (n - 1).

We conclude the paper by mentioning some open problems and directions for further research.

�9 Decrease some of the bounds with respect to the grid size, number of bends, or minimum angle given in this paper. As an example, very recently Chrobak and Kant [6] improved the grid bound for convex drawing of triconnected planar graphs to (n - 2) • (n - 2). New bounds on the grid size and the number of bends for orthogonal drawings are given by Biedl and Kant [2].

�9 Is it possible to use the canonical ordering in other drawing representations as well, to obtain better results in planar graph drawings on a grid?

�9 Inspect the more combinatorial aspects of the canonical ordering. It is not very hard to prove that a canonical ordering for G also directly defines a canonical ordering of the dual graph, but maybe other combinatorial observations can be made.

�9 Can an arbitrary planar graph be drawn planar with straight lines such that the minimum angle is > ~ ( 1 / d ) ? (See also [36], [13], and [20] for research in this question.)

�9 Devise dynamic algorithms for the sequential algorithms of this paper. In [8] a dynamic framework for graph-drawing problems is described, but this approach seems not to work here. Very recently, He and Kao [23] presented a parallel implementation for

Page 28: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

Drawing Planar Graphs Using the Canonical Ordering 3 I

finding a canonical ordering, and comput ing the convex drawing in (Q(log 4 n) time,

requiring O ( n 2) processors.

A c k n o w l e d g m e n t s . The author wishes to thank Hans Bodlaender, Jan van Leeuwen,

Therese Biedl, and the anonymous referees for g iv ing a lot o f helpful comments .

References

[ 11 Bhasker, J., and S. Sahni, A linear algorithm to find a rectangular dual of a planar triangulated graph, Algorithmica 3 (1988), 147-178.

[2] Biedl, T., and G. Kant, A better heuristic for planar orthogonal drawings, in Proc. 2nd European Symp. on Algorithms (ESA '94), Lecture Notes in Computer Science, Vol. 855, Springer-Verlag, Berlin. 1994, pp. 24-36.

[3] Booth, K. S., and G. S. Lueker, Testing for the consecutive ones property, interval graphs and graph planarity testing using PQ-tree algorithms, J. Comput. System Sci. 13 (1976), 335-379.

[4] Chiba, N., T. Nishizeki, S. Abe, and T. Ozawa, A linear algorithm for embedding planar graphs using PQ-trees, J. Comput. System Sci. 30 (1985), 54-76.

[5] Chiba, N., K. Onoguchi, and T. Nishizeki, Drawing planar graphs nicely, Acta Inform. 22 (19851, 187-201.

[6] Chrobak, M., and G. Kant, Convex Grid Drawings of 3-Connected Planar Graphs, Tech. Rep. RUU- CS-93-45, Dept. of Computer Science, Utrecht University, 1993.

[7] Chrobak, M., and T. H. Payne, A Linear Time Algorithm tbr Drawing Planar Graphs on the Grid, Tech. Rep. UCR-CS-90-2, Dept. of Mathematics and Computer Science, University of California at Riverside, 1990.

18] Cohen, R. F., G. Di Battista, R. Tamassia, I. G. Tollis, and P. Bertolazzi, A framework for dynamic graph drawing, in Proc. 8th Annual ACM Syrnp. on Computational Geometr3', 1992, pp. 261-270.

[9] G. Di Battista, P. Eades, R. Tamassia, and I. G. Tollis, Algorithms for automatic graph drawing: an annotated bibliography, Comput. Geom. Theory Appl. 4 (1994), 235-282.

[ 10] Di Battista, G., G. Liotta, and E Vargiu, Spirality of orthogonal representations and optimal drawings of series-parallel graphs and 3-planar graphs, in Proc. Workshop on Algorithms and Data Structures (WADS '93), Lecture Notes in Computer Science, Vol. 709, Springer-Verlag, 1993, Berlin, pp. 151-162.

I I l J Di Battista, G., and R. Tamassia, Incremental planarity testing, in Proc. 30th Annual 1EEl+" Symp. on Foundations of Computer Science (FOCS '89), 1989, pp. 436--441.

I 12] Di Battista, G., R. Tamassia, and I. G. Tollis, Area requirement and symmetry display in drawing graphs, Discrete Comput. Geom. 7 (1992), 381-401.

[13] Di Battista, G., and L. Vismara, Angles of planar triangular graphs, extended abstract in Proc. 25th Annual ACM Symp. on Theory of Computing, 1993, pp. 431-437.

114] Even, S., and G. Granot, Rectilinear Planar Drawings with Few Bends in Each Edge, Manuscript, Faculty of Computer Science, The Technion, Haifa, 1993.

115] Even, S., and R. E. Tarjan, Computing an st-numbering, Theoret. Comp. Sci. 2 (1976), 436-441. 116] F~u'y, I., On straight line representations of planar graphs, Acta Sci. Math. Szeged, 11 (1948), 229-233. 1171 Formann, M., T. Hagerup, J. Haralambides, M. Kaufmann, E T. Leighton, A. Simvonis, E. Welzl,

and G. Woeginger, Drawing graphs in the plane with high resolution, SlAM J. Comput. 22 (1993), 1035-1(152.

[18J Fraysseix, H. de, J. Pach, and R. Pollack, How to draw a planar graph on a grid, Combinatorica 10 (1990), 41-51.

119] Garg, A., and R. Tamassia, On the computational complexity of upward and rectilinear planarity testing, in Proc. Graph Drawing '94, Lecture Notes in Computer Science, Springer-Verlag, Berlin, 1994, to appear.

[20] Garg, A., and R. Tamassia, Planar drawings and angular resolution: algorithms and bounds, in Proc. 2nd European Symp. on Algorithms (ESA '94), Lecture Notes in Computer Science, Vol. 855, Springer- Verlag, Berlin, 1994, pp. 12-23.

Page 29: Drawing planar graphs using the canonical ordering · 2005-08-15 · Drawing Planar Graphs Using the Canonical Ordering 5 of vertices, f2 (n 2) is also a lower bound for the area

32 G. Kant

1211 Haandel, E van, Straight Line Embeddings on the Grid, M.Sc. Thesis, No. INF/SCR-91-19, Dept. of Computer Science, Utrecht University, 1991.

[22] He, X., On finding the rectangular duals of planar triangulated graphs, SIAM J. Comput., 1993, to appear. [23J He, X., and M.-Y. Kao, Parallel construction of canonical ordering and convex drawing of triconnected

planar graphs, in Proc. 4th Syrup. on Algorithms and Computation (ISAAC '93), Lecture Notes in Computer Science, Vol. 762, 1993, pp. 303-312.

124] Hopcroft, J., and R. E. Tarjan, Dividing a graph into triconnected components, SIAM J. Comput. 2 (1973), 135-158.

[25] Hopcroft, J., and R. E. Tarjan, Efficient planarity testing, J. Assoc. Comput. Mach. 21 (1974), 549-568. [26} Jayakumar, R., K. Thulasiraman, and M. N. S. Swamy, Planar embedding: linear-time algorithms for

vertex placement and edge ordering, IEEE Trans. Circuits and Systems 35 (1988), 334-344. [27] Kant, G., Hexagonal grid drawings, in Proc. 18th International Workshop on Graph-Theoretic Concepts

in Computer Science (WG '92), Lecture Notes in Computer Science, Vol. 657, Springer-Verlag, Berlin, 1992,263-276.

[28} Kant, G., Algorithms for Drawing Planar Graphs, Ph.D. thesis, Dept. of Computer Science, Utrecht University, 1993.

[29] Kant, G., The planar triconnectivity augmentation problem, submitted to Theoret. Comput. Sci., 1993. {30] Kant, G., A more compact visibility repre~ntation, in Proc. 19th International Workshop on Graph-

Theoretic Concepts in Computer Science (WG '93), Lecture Notes in Computer Science, Vol. 790, Springer-Verlag, Berlin, 1994, 411--424.

[31] Kant, G., and X. He, Two algorithms for finding rectangular duals of planar graphs, in Proc. 19th International Workshop on Graph-Theoretic Concepts in Computer Science (WG '93), Lecture Notes in Computer Science, Vol. 790, Springer-Verlag, 1994, pp. 396-410.

[32] Lempel, A., S. Even, and I. Cederbaum, An algorithm for planarity testing of graphs, Theoo' of Graphs, International Syrup., Rome, 1966, pp. 215-232.

[33] Liu, Y., P. Marchioro, and R. Petreschi, At most single-bend embeddings of cubic graphs, Appl. Math., 1994, to appear.

134] Liu, Y., P. Marchioro, R. Petreschi, and B. Simeone, Theoretical Results on at Most 1-Bend Embed- dability of Graphs, Tech. Rep., Dept. of Statistics, University "La Sapienza" Roma, 1990.

135] Lin, Y.-L., and S. S. Skiena, Complexity Aspects of Visibility Graphs, Rep. 92-08, Dept. of Computer Science, State University of New York, Stony Brook, NY, 1992.

[36J Malitz, S., and A. Papakostas, On the angular resolution of planar graphs, SlAM J. Discrete Math. 7 (1994), 172-183.

[37] Nummenmaa, J., Constructing compact rectilinear planar layouts using canonical representation of planar graphs, Theoret. Comput. Sci. 99 (1992), 213-230.

138] Rosenstiehl, P., and R. E. Tarjan, Rectilinear planar layouts and bipolar orientations of planar graphs, Discrete Comput. Geom. 1 (1986), 343-353.

[39] Schnyder, W., Embedding planar graphs on the grid, in Proc. 1st AnnualACM-SIAM Syrup. on Discrete Algebra (SODA '90), 1990, pp. 138-147.

[40] Stein, S. K., Convex maps, Proc. Amer Math. Soc. 2 ( 1951 ), 464--466. [41] Storer, J. A., On minimal node-cost planar embeddings, Networks 14 (1984), 181-212. 142] Tamassia, R., On embedding a graph in the grid with the minimum number of bends, SlAM J. Comput.

16 (1987), 421-444. [431 Tamassia, R., and I. G. Tollis, Planar grid embedding in linear time, IEEE Trans. Circuits and Systems,

36 (1989), 1230-1234. [441 Tamassia, R., and I. G. Tollis, A unified approach to visibility representations of planar graphs, Discrete

and Comput. Geom. 1 (1986), 321-341. [45} Tamassia, R., I. G. Tollis, and J. S. Vitter, Lower bounds for planar orthogonal drawings of graphs,

Inform. Process. Lett. 39 (1991), 35--40. [46] Thomassen, C., Planarity and duality of finite and infinite planar graphs, J. Combin. Theory Ser. B 29

(1980), 244-271. [471 Tutte, W. T., Convex representations of graphs, Proc. London Math. Soc. 10 (1960), 302-320. [48] Tutte, W. T., How to draw a graph, Proc. London Math. Soc. 13 (1963), 743-768. [49] Wagner, K., Bemerkungen zum vierfarbenproblem, Jahresber. Deutsch. Math.-Verein. 46 (1936), 26-

32.