• 沒有找到結果。

Drawing Planar Graphs Using the Canonical Ordering I

N/A
N/A
Protected

Academic year: 2022

Share "Drawing Planar Graphs Using the Canonical Ordering I "

Copied!
29
0
0

加載中.... (立即查看全文)

全文

(1)

Algorithmica

c~. 1996 Springer-Verlag New York Inc.

Drawing Planar Graphs Using the Canonical Ordering I

G. Kant 2

A b s t r a c t . 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.

goos@cs.ruu.nl.

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

(2)

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

(3)

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.

(4)

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 o f 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 f a c e 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,

(5)

otherwise the graph G - {c~, cb} is d i s c o n n e c t e d , w h i c h contradicts the triconnectivity of G. By minimality of b - a, c,, is not part o f a separation pair in Gk, hence Gk - c~ does not have a cutvertex and the outerface o f Gk - c~ is biconnected. We take Vk = {c,,}.

A s s u m e 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 b e s u c h t h a t 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 }.

A s s u m e 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 o f 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 o f 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 e m b e d d i n g o f 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 o f 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 o f F , belonging to the outerface, form a consecutive

(6)

/// " ' - \

/ / ' ~<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:

(7)

The exact coordinates o f vertices in the current drawing are only computed when they are necessary to compute the insertcoordinates o f vertices added in this step. This means that only the exact coordinates o f 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 o f 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 o f Vk are part o f 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 o f 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 o f 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 o f vk (when we insert vk by the

lmc-ordering)

and the endcoordinates o f 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 m u s t be added to all

x(ck),

with r < k < q, where cl . . .

Cq

is the current outerface Ck. W h e n 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.

(8)

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) = f a l s e means that in step k we add V, with rightvertex c v. This contradicts the definition o f 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 o f Vk, with leftvertex ct,, l' > or. A d d i n g 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 o f 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). []

(9)

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. L e 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 shift(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-~. shift(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, rshift(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 rshift(zl) + x ' to rshift(Cr). T h e 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. C o n v e x D r a w i n g s . 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 b y / z ( c t , c~). All vertices ct . . . cr are visible from this point. See Figure 3 for the corresponding picture. Let

(10)

/~(cl, r

C I + I ) ~ " ' .

c<

. . . ,,,.

O k

ct -:~:-, 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 ( v t ) : = {Vl};

P(v2) : = (2, 0); L(V2) : = {v2};

P(V3) : = (1, 1); L(V3) : = {v3};

f o r k : = 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)

d o 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);

f o r k : = 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 d o w n t o 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.

(11)

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), (zl, ci,_,) and the path B / b e t w e e n ci~ and cir,,.

LEMMA 4.1. Each path Bj has the f o l l o w i n g pattern:

9 From c,/to s o m e 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 s a m e 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 o f L e m m a 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 f a c e s 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 ) b e a s 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

(12)

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 I 0

I _2 I 2

Step 7 Step 11

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

(13)

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 / a n d 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

(14)

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 f e = 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);

f o r / : = 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

(zt-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 o f 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 o f 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.

(15)

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,.}.

-'I iz'

ct 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 o f 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 f g = 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

(16)

edges use the c o n n e c t i o n s left(l) 1 ) or right(v2), to step 1. S u m m a r i z i n g this leads to the f o l l o w i n g 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

C o n s i d e r the steps 2 . . . K - 1 in which n - 3 vertices and at most 2n - 5 edges arc added (since m _< 2n). A d d i n g Vt = {z I } with i n ( z l) = 3 occurs at most I n / 2 ] - 2 times, because then at most 1 3 / 2 n ] - 6 edges are added, and at most [ n / 2 J + 1 edges are added by at most Ln/21 - 1 vertices. This yields at most 2 ( [ n / 2 1 - 2) + Ln/2J - 1 + 8 = [ 3 n ] + 3 bends. T h e edge u s i n g up(v,,) has at most three bends, all other edges have at most two

bends. []

LEMMA 5.3. The g r i d s i z e is at m o s t n x n.

PROOF. The increase in height in step k, 1 < k < K , is at most f., w h e r e Vk = {zl . . . ze}. In step i the increase in height is at most one, and in step K two, which proves the total height o f n.

For the total width, we consider the different cases for step k, 1 < k < K. Let Vk : {Zl . . . ze}.Ifg. > 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 m e a n s an increase of o n e in width. If (ct, z l ) is vertical and m a r k ( z l ) = right, then o n e outgoing edge of zl has to go via l e f t ( z l ) , hence this also m e a n s an increase of o n e in width later. We assign this increase to step k. A similar c o n d i t i o n 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 a n d i n ( z l ) = 2, then the width increases by one, due to the fact that an extra c o l u m n might be necessary for the o u t g o i n g edge o f z t via left(zl ) w h e n m a r k ( z l) = right (similarly w h e n 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 c o l u m n s , required by the o u t g o i n g edges via l e f t ( v l ) and right(v2) to step 1, y i e l d i n g a starting width o f three units. This gives the f o l l o w i n g 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 o f at most n []

(17)

I q l c

~g 14

12 I I

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

(18)

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.

Assume first that G is triconnected. By Euler's formula, n is even, m = i n , and 3 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 / t o Cr ; y(zl) : . . . . : = y(ze) : = 1 + max{y(c/), y(cr)};

update x(ct) and shift(or);

x(zi)

: = x ( c t ) ;

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

i f g > I t h e n 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 d o w n t o 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 f e = 1 thenshift(c~) := shift(zl) elseshift(cr) :-- x(ze) - xi,,.,.e,~(cr) t o f;

END 3-ORTHOGONAL

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

PROOF. Since m = 7n, we add at most 3 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.

(19)

'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 b e 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

(20)

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:

(21)

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 a s 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 o f 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 ' / 2 J - !), 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 o f 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 o f n - 1 straight-line edges, while all nontree edges have at most one bend (ifn > 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

(22)

(a)

t i

S i

(b)

s; !si

(c) ~

= ~ N

(d)

ti t i

l+

sit- ~ ,i

s~

, t~

~si 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.

參考文獻

相關文件

• Using the remainder estimate for the Integral Test, answer this question (posed at the end of Group Exercise 2 in Section 12.2): If you had started adding up the harmonic series at

Real Schur and Hessenberg-triangular forms The doubly shifted QZ algorithm.. Above algorithm is locally

After students have had ample practice with developing characters, describing a setting and writing realistic dialogue, they will need to go back to the Short Story Writing Task

In this chapter we develop the Lanczos method, a technique that is applicable to large sparse, symmetric eigenproblems.. The method involves tridiagonalizing the given

We explicitly saw the dimensional reason for the occurrence of the magnetic catalysis on the basis of the scaling argument. However, the precise form of gap depends

Monopolies in synchronous distributed systems (Peleg 1998; Peleg

The vertex-cover problem is to find a vertex cover of minimum size in a given undirected graph. • 此問題的decision版本為NP-Complete

Without using ruler, tearing/cutting of paper or drawing any line, use the square paper provided (Appendix A) to fold the figure with the same conditions as figure 8b, but the area