ELSEVIER Theoretical Computer Science 172 ( 1997) 175-l 93
Computer
Science
Regular edge labeling of 4-connected plane graphs and its applications in graph drawing problems
’Goos Kant a, Xin He b,*
a
Department of Computer Science, Utrecht University, Padualaan 14, The Netherlands3584 CH Utrecht.
bDepartment of Computer Science, State University of New York at Buffalo, Buffalo, NY 14260, USA
Received May 1995; revised November 1995 Communicated by O.H. Ibarra
Abstract
In this paper we extend the concept of the regular edge labeling for general plane graphs and for ticonnected triangulated plane graphs to 4-connected triangulated plane graphs. We present two different linear time algorithms for constructing such a labeling. By using regular edge labeling, we present a new linear time algorithm for constructing rectangular dual of planar graphs. Our algorithm is simpler than previously known algorithms. The coordinates of the rectangular dual constructed by our algorithm are integers, while the one constructed by known algorithms are real numbers.
Our second regular edge labeling algorithm is based on canonical ordering of 4-connected triangulated plane graphs. By using this technique, we present a new algorithm for constructing visibility representation of 4-connected planar graphs. Our algorithm reduces the size of the representation by a factor of 2 for such graphs.
1. Introduction
The problem of “nicely” drawing a graph G on the plane has received increasing attention [4]. Typically, we want to draw the edges and the vertices of G so that certain aesthetic quality conditions and/or optimization measures are met. Such drawings are very useful in visualizing planar graphs and find applications in fields such as computer graphics, VLSI layout, algorithm animation, visual languages and so on.
A powerful method, regular edge labeling, was used successfully in solving several planar graph drawing problems. Roughly speaking, for a given plane graph G = (V,E),
* Corresponding author. E-mail: [email protected].
’ The work of the first author was supported by the ESPRIT Basic Research Actions program of the EC under contract No. 7141 (project ALCOM II). The work of the second author was partially supported by National Science Foundation, grant CCR-9205982.
0304-3975/97/$17.00 @ 1997-Elsevier Science B.V. All rights reserved SSDZ 0304-3975(95)00257-X
176 G. Kant, X. Hel Theoretical Computer Science 172 (1997) 175-193
a regular edge labeling of G partitions and orients the edges of G such that the edges around every vertex v show certain regular patterns. The drawing of G is then produced by using the combinatorial structures resulting from the labeling. For an example, it was shown in [ 171 that the edges of every plane graph G can be oriented so that the edges incident to each vertex v are partitioned into two contiguous nonempty subsets around v:
the edges in the first subset are leaving v; the edges in the second subset are entering v.
(It is commonly called an s-t orientation of G). An elegant algorithm for solving the visibility representation problem was obtained by using this labeling [17]. For another example, it was shown in [ 181 that the edges of every triconnected triangulated plane graph G can be oriented and partitioned into three sets T,, Tz, T3 such that the edges incident to each vertex v display the following pattern in counterclockwise order around v: an edge in T, leaving v; a set (maybe empty) of edges in T3 entering v; an edge in T2 leaving v; a set (maybe empty) of edges in T, entering v; an edge in T3 leaving v; a set (maybe empty) of edges in T2 entering T2 entering v. (It is called a realizer in [18].) By using this labeling, Schnyder found a beautiful algorithm that computes a straight line embedding of G on an (n - 2) x (n - 2) grid [19].
In this paper, we extend the regular edge labeling (REL) concept to 4-connected triangulated plane graphs. We present two linear time algorithms for finding an REL for such a graph G. The two algorithms use totally different approaches and both are of independent interests. The first algorithm is based on the edge contraction technique.
A similar method was used in solving other planar graph problems (for examples, see [6,19]). The second algorithm is based on the concept of canonical ordering for 4-connected triangulated plane graphs. This concept was first defined for triangulated plane graphs [5] and triconnected plane graphs [12]. We extend this concept to 4- connected triangulated plane graphs. We show that the canonical ordering and the REL are closely related and a canonical ordering algorithm leads to an REL algorithm.
As applications, we show that the regular edge labeling can be used to solve the rectangular dual problem and the canonical ordering can be used to solve the visibility representation problem for 4-connected plane graphs. In the following, we discuss these two problems in more details.
In design of floor planning of electronic chips and in architectural design, it is com- mon to represent a graph G by a rectangular dual defined as follows. A rectangular subdivision system of a rectangle R is a partition of R into a set r = (RI, R2,. . . , R,}
of nonoverlapping rectangles such that no four rectangles in r meet at the same point.
A rectangular dual of a plane graph G = (I’, E) is a rectangular subdivision system r and a one-to-one correspondence f : V + r such that two vertices u and v are adjacent in G if and only if their corresponding rectangles f(u) and f(v) share a common boundary. In applications of this representation, the vertices of G represent circuit modules and the edges represent module adjacencies [lo, 161. A rectangular dual provides a placement of circuit modules that preserves the required adjacencies. Fig. 1 shows an example of a plane graph and its rectangular dual.
The rectangular dual problem has been studied in [l, 2,14,15]. Bhasker and Sahni gave an algorithm for solving the problem [2]. Although it runs in linear time, their
“n
“e
“s (1) G
“n
(3) q
0 1234567
(2) A rectangular dual of G
“e
(4) 5
Fig. 1. A 4TP graph, its rectangular dual, and the St-graphs GI and G2.
algorithm is fairly complicated. Moreover, the coordinates of the rectangular dual constructed by the algorithm in [2] are real numbers and bear no clear relationship to the structure of the graph. This algorithm consists of two major steps: (1) construct- ing a so-called
path directed graph
for G; and (2) constructing the rectangular dual using the path directed graph. A simplification of step (2) is given in [7]. (A parallel implementation of this algorithm, working in O(log2n) time with O(n) processors, is given in [S]). However, the step (1) still relies on the complicated algorithm in [2].We will show that the path directed graph can easily be obtained from an REL of G. Combine our REL algorithms and the result in [7], we obtain a simple rectangular dual algorithm. The coordinates of the rectangular dual constructed by our algorithm are integers and carry clear combinatorial meaning.
The second graph drawing problem we consider is the
visibility representation.
Given a planar graph G, the representation maps each vertex of G into a horizontal line segment and each edge into a vertical line segment that only touches the two horizontal line segments representing its end vertices [17,20]. This gives a nice and readable drawing of G. This representation has been applied in several industrial applications for representing electrical diagrams and schemes [20]. Linear time algorithms for solving this problem has been independently discovered by Rosenstiehl and Tarjan [ 171 and Tamassia and Tollis [20]. The size of the drawing is (2n - 5) x (n - 2) for both algorithms. Our visibility representation algorithm uses the same ideas as in [17,20].178 G. Kant, X. Hel Theoretical Computer Science 172 (1997) 175-193
However, we show that, by using the canonical ordering, the size of the drawing can be reduced to (n - 1) x (n - 1) for 4-connected planar graphs. Using this result, Kant recently proved that a visibility representation of a general planar graph can be drawn on a grid of size at most (LznJ - 3) x (n - 1) [13].
Although linear time algorithms for solving both problems are previously known, the techniques used in our algorithms are completely different. The simplicity of our approach is a significant factor for applications. The regular edge labeling can also be used to solve other graph drawing problems. For example, it is recently shown in [9], by using this method, that every 4-connected plane graph has a straight line embedding on a W+H grid with W+H<n;WB(n+3)/2 andHf2(n- 1)/3.
The present paper is organized as follows. Section 2 presents the definition of the regular edge labeling of 4-connected plane graphs and describes the algorithm in [7]
that computes a rectangular dual from an REL. In Section 3, we present the edge contraction based algorithm for computing an REL. In Section 4, we present the second REL algorithm based on the canonical ordering. Section 5 discusses the algorithm for the visibility representation. Section 6 concludes the paper.
2. Regular edge labeling of 4-connected plane graphs
Let G = ( V, E) be a planar graph with n vertices and m edges. We use N(o) to denote the set of neighbors of u. Let deg(u) = IN(u We assume G is equipped with a fixed plane embedding. The unbounded face is the exterior face. Other faces are interior faces. The vertices and the edges on the boundary of the exterior face are called exterior vertices and exterior edges. Other vertices and edges are interior vertices and interior edges. In this paper, the terms path and cycle always mean simple path and simple cycle (i.e. the vertices of path and cycle are distinct). A triangle is a cycle of 3 edges. A quadrangle is a cycle of 4 edges. A cycle C of G divides the plane into its interior and exterior regions. If C contains at least one vertex in its interior and exterior. C is called a separating cycle.
We assume the embedding information of G is given by the following data structure.
For each u E V, there is a doubly linked circular list Adj(u) containing all vertices of N(u) in counterclockwise order. The two copies of an edge (u, u) are cross-linked to each other. This representation can be constructed as a by-product by using a planarity testing algorithm in linear time (e.g. [ll]).
A triangulated plane graph is a plane graph all of whose interior faces are triangles.
Consider an interior vertex u of such a graph G. If N(u) = (~1,. . . , uk} are in coun- terclockwise order around u in the embedding, then the edges (ui, ZQ), . . . , (Q-I, uk), (uk, ~1) form a cycle, which will be denoted by Cycle(u). The star at u, denoted by Star(u), is the set of the edges {(u, ui) ) 1 di Gk}. Consider a graph G satisfying the following conditions:
(1) every interior face of G is a triangle and the exterior face is a quadrangle;
(2) G is 4-connected.
Remark 1. The first condition can easily be checked in linear time using the embedding information of G. If G satisfies condition 1, condition 2 is equivalent to that G contains no separating triangles. To test condition 2, we first enumerate all triangles of G by using the linear time algorithm in [3]. Then for each triangle C of G listed, we check if C is a separating triangle or not. This takes 0( 1) time per triangle. So the total time needed is O(n).
A graph G satisfying above two conditions will be called a 4TP graph. Note condition (2) implies that G has no separating triangles. Since G has no separating triangles, the degree of any interior vertex u of G is at least 4. (If deg(u) = 3 for some u, then deleting the three neighbors of v would disconnect G. This contradicts the assumption that G is 4-connected).
Definition 2.1. A regular edge labeling of a 4TP graph G is a partition and an orien- tation of the interior edges of G into two subsets Ti, T2 of directed edges such that:
1. For each interior vertex v, the edges incident to v appear in counterclockwise order around u as follows: a set of edges in T, leaving v; a set of edges in T2 entering v; a set of edges in TI entering v; a set of edges in T2 leaving v.
2. Let VN, uw, vs,uE be the four exterior vertices in counterclockwise order. All in- terior edges incident to UN are in TI and entering VN. All interior edges incident to vw are in T2 and leaving vw. All interior edges incident to vs are in TI and leaving vs.
All interior edges incident to vr are in T2 and entering vn.
In the next two sections, we will show that every 4TP graph has an REL and that REL can be constructed in linear time. In the following, we briefly describe the algorithm in [7] that constructs a rectangular dual from an REL.
Consider a plane graph H = (V,E). Let ~0, ~1, ~2,243 be four vertices on the exterior face in counterclockwise order. Let Pi (i = 0,1,2,3) be the path on the exterior face consisting of the vertices between u, and Ui+i (addition is mod 4). We seek a rectangular dual RH of H such that us, ur,z42,243 correspond to the four comer rectangles of RH and the vertices on PO (PI, Pz,Ps, respectively) correspond to the rectangles located on the north (west, south, east, respectively) boundary of RH. In order to simplify the problem, we modify H as follows: Add four new vertices ~~,vw,vs,vE.
Connect UN (VW, vs, UE, respectively) to every vertex on PO (PI, P2, P3, respectively) and add four new edges (vs,vw),(vw, UN),(UN, vE),(vn, us). Let G be the resulting graph.
It is easy to see that H has a rectangular dual R H if and only if G has a rectangular dual RG with exactly four rectangles on the boundary of RG (see Fig. l( 1) and (2)).
The following theorem was proved in [l, 141.
Theorem 2.1. A plane graph G has a rectangular dual R with four rectangles on the boundary of R if and only if G is u 4TP graph.
The regular edge labeling is closely related to planar St-graphs. A planar St-graph G is a directed plane graph with exactly one source (in-degree 0) vertex s and exactly
180 G. Kant, X. Hel Theoretical Computer Science 172 (1997) 175-193
low(F)
Fig. 2. Properties of planar St-graphs
one sink (out-degree 0) vertex t such that both s and t are on the exterior face and are adjacent. Let G be a planar St-graph. For each vertex v, the incoming edges of u appear consecutively around o, and so do the outgoing edges of v. The boundary of every face F of G consists of two directed paths with a common origin, called low(F), and a common destination, called high(F). The face on the left (right, respectively) side of an edge e is denoted by left(e) (right(e), respectively) (see Fig. 2).
Let G be a 4TP graph and {Tr, Tz} be an REL of G. From { Tl, Tz}, we can construct two planar St-graphs as follows. Let Gt be the graph consisting of the edges of Tl plus the four exterior edges (directed as us + VW,VW -+ ~,vs,uE + UN), and a new edge (us, L+J). Gr inherits a plane embedding from G. Then Gr is a planar st-graph with source us and sink UN. For each vertex a, the face of Gt that separates the incoming edges of v from the outgoing edges of v in clockwise direction is denoted by left(u).
The face of Gr that separates the incoming and the outgoing edges of v is denoted by right(u) (see Fig. 2).
Let G2 be the graph consisting of the edges of T2 plus the four exterior edges (directed as VW --+ vs,vs + I&, VW -+ UN, @J + un), and a new edge (UW,VE). G2 inherits a plane embedding from G. Then G2 is a planar St-graph with source VW and sink un. For each vertex a, the face of G2 that separates the incoming edges of u from the outgoing edges of v in clockwise direction is denoted by above(v). The face of G2 that separates the incoming and the outgoing edges of u is denoted by below(u) (See Fig. 2).
The dual graph CT of Cl is defined as follows. Every face Fk of Gt is a node u4 in CT and there exists an edge (UF,, VF, ) in CT if and only if Fi and Fk share a common edge in Cr. The edges of G: are directed as follows: if Fl and F, are the left and the right face of an edge (u, w) of Gr, direct the dual edge from Fl to F, if (u,w) # (vs,z$~) and from F, to FI if (&IV) = (vs,uN). G: is a planar st- graph whose source and sink are the right face (denoted by IV*) and the left face (denoted by e**) of (us, Q.J), respectively. For each node F of G: let dl(F) denote the length of the longest path from w* to F. Let Dt = dr(e*). For each interior vertex u,
define: xleft(u) = dl(leR(u)), and .+J,~(v) = dl(right(v)). For the four exterior vertices, define: XkfdUW) = O;%ight(uW) = l;&fi(uE) = D1 - l;%ight(UE) = Dl; XlefdUS) =
&ft(ON) = l;-%ight(US) = &ight(~N) = DI - 1.
The dual graph G2* of GZ is defined similarly. For each node F of G?, let dz(F) denote the length of the longest path from the source node of G2* to F. Let 02 be the length of the longest path from the source node to the sink node of G;. For each interior vertex u, define: ylow(v) = dz(beZow(u)), and Bib(U) =
dz(above(u)).
For the fOUr exterior Vertices, define: YIOw(Uw) = Yl,&UE) = 0; yhigh(vW) = yhigh(vE) = D2; .YIow(%) = 0; yhigh(kj) = 1; Ylow(uN) =D2 - 1; yhigh(UN) =&.The following theorem was proved in [7].
Theorem 2.2.
Let G be a 4TP graph and { Tl, T2) be an REL of G. For each vertex u of G, assign v the rectanglef(v)
bounded by the four lines x = q&v), x = x,+&t(v), y = ylow(v), y = y&h(v). Then the set{f(v) / v E v} form
a rectangular dualof
G. If the REL is given, the rectangular dual can be constructed in linear rime.Fig. 1 shows an example of this construction. Fig. l(3) shows the St-graph G,. The small boxes in the figure represent the nodes of GT and the integers in the boxes are their dl values. Fig. l(4) shows the graph Gz. Fig. l(2) shows the rectangular dual constructed as in Theorem 2.2.
3.
REL algorithm based on edge contraction
In this section, we present our first algorithm for computing an REL of a 4TP graph G. The basic technique is edge contraction and edge expansion. We begin with the definition of edge contraction. Let e = (v, u) be an interior edge of G. Let Cl and C2 be the two faces with e as the common boundary. Let el and e2 be the other two edges and y the third vertex of Cl. Let e3 and e4 be the two other edges and z the third vertex of C7, (see Fig. 3). The operation of contracting e deletes e and merges u and v into a new vertex oe. The edges incident to u and v (except el,ez,e3,e4) are incident to the new vertex o, in the resulting graph. Replace el and e2 by a new edge (y,o,).
Replace e3 and e4 by a new edge (z,o,). The resulting contracted graph is denoted by G/e. The edges el,ez,eg,eq are called the surrounding edges of e. The edges (y, 0,) and (z,oe) are called the residual edges of e.
The graph G’ = G/e has a plane embedding inherited from the embedding of G.
Since G is a 4TP graph, e is not on any separating triangle. Thus G’ has no multiple edges. It is easy to see that G’ with the inherited embedding is a triangulated plane graph. If e is on a separating quadrangle of G, then G’ has a separating triangle. If e is
not
on any separating quadrangle of G, it is called a contractible edge. For any contractible edge e, G/e is a 4TP graph.182 G. Kant, X. Hel Theoretical Computer Science I72 (1997) 175-193
Y
Y
?
a b
Y
0 e 2 CFig. 3. Edge contraction.
The following equivalent definition of contractible edges is useful in our discussion.
Consider a vertex u and a neighbor u of u. Let y and z be the two neighbors of u that are consecutive with u in N(u) (see Fig. 3). The edge (u, u) is contractible if and only if for any neighbor x(x # u, y,z) of u, the only common neighbor of u and x is u. In this case, u is called a
contractible neighborof v.
Lemma 3.1.
Let G be a4TP
graph and u be an interior vertex of G. Ifdeg(u) = 4, then u has at least two contractible neighbors. If deg(u) = 5, then v has at least one contractible neighbor.Proof. Suppose
deg(u) = 4.Let UO,U~,UZ,ZJ~ be the four neighbors of u in counter- clockwise order. If uo and ~2 have no common neighbors other than u, then both of them are contractible. Suppose us and ~2 share a common neighbor w # u. If ui and ~3 share no common neighbors other than u, then both of them are contractible. Suppose ui and us share a common neighbor z # u. By the planarity of G, we have w = z and G has a separating triangle (i.e. {uo,u~, w}). This contradicts that G is a 4TP graph.
Similarly, we can show each degree-5 vertex has at least one contractible neighbor.
Let e be a contractible edge of a 4TP graph G. Suppose an REL {T{, Ti} of the contracted graph G’ = G/e has been found. Then we can
expand eand obtain an REL {Tt,T2} of G from {T,‘,Ti} as follows. Let ei,e2, e3,e4 be the surrounding edges of e. For any edge e’ of G that is not e and not a surrounding edge of e, the label of e’
with respect to { Tt, T2) is the same as its label with respect to {
Ti’, Ti}.We need to specify proper labels of e, et, e2, es, es with respect to {
Tl, T2).Depending on the labels of the edges in
Star(o,)with respect to
{T[, Ti},there are six cases (up to rotating the edges around 0,) as shown in Fig. 4. These figures shows the labels of relevant edges before and after the expansion.
We assume (o,, y) is in
T[and directed as o, --) y. Other cases are similar by rotating the edges in
Star(o,).Consider the label of (o,,z) with respect to {T,‘,
Ti}.If z -+ o, E
Ti,the situation is shown in Fig. 4(l). The case o, -+ z E
T;is shown
in Fig. 4(2). Suppose o, + z E
Ti.Let (o,,x) be the first edge in
Star(o,)following
Before expansion
+Q *
(1) (2)
w
e (3)Before
expansion Q)y’ %g xq
(4) (5)
Fig. 4. Edge expansion.
(6)
(o,, r) in clockwise order. Depending on the label of (o,,x) with respect to {Tf, T2/}, there are two cases as shown in Figs. 4(3) and (4). Suppose z -+ o, E T2/. Let (o,,x) be the first edge in Star(o,) following (oe,y) in counterclockwise order. Depending on the label of (o,,x) with respect to { Ti, T2/} there are two cases as shown in Figs.
4(5) and (6). Note that the conditions of the six cases are completely determined by the labels of at most six edges in Slur(~): the two residue edges (o,, r),(o,,z) and the four edges that are consecutive with
(oe, ~),(o~,z)
in Star(o,).The basic idea of our algorithm is as follows. Recall that the 4-connectivity of G implies the minimum degree of G is at least 4. On the other hand, the minimum degree of any planar graph is at most 5. So the minimum degree of G is either 4 or 5. We pick a degree-4 or a degree-5 vertex o and select a contractible neighbor u of v. Then contract e = (v, U) and recursively find an REL for the graph G’ = G/e. Finally, expand e to obtain an REL for G. In order to find the contractible neighbors of v, however, we need to check, for each pair u and w of v’s neighbors, if u and w share a common
184 G. Kant, X. Hel Theoretical Computer Science 172 (1997) 175-193
neighbor (other than u) or not. Since the degree of u and w can be large, this checking might be too expensive. In order to achieve linear time, we will only consider special good degree-4 and degree-5 vertices defined as follows. Let Vi = {u E V ( deg(u) = i}
and Vli,jl = {U E V
( i ddeg(u) <j}.Define ni =
(Vi(and nli,jl =
( VIi,jl[. Thevertices in Vl, 191 are called
lightvertices. The vertices in Vl20,~) are called heavy vertices. A degree-5 vertex u is
goodif u has at most one heavy neighbor. A degree-4 vertex u is
goodif either u has at most one heavy neighbor, or u has two heavy neighbors which are not consecutive in N(u).
Lemma 3.2. Any 4TP
graph G = (V, E) with at least one heavy vertex has at least 7 good vertices.Proof. Since the exterior face of G is a quadrangle and all interior faces of G are
triangles, we have (El = 3n -
7 by Euler’s formula. Hence, 4n4 +
5ns +6n[6,191 + 20n[20,CO) G CJQi
ini=CvEVdeg(u)=2(EI=6n-14 = 6(n4+ns+n[619]+n[20,~))-14.This gives: 14nl20,,) +
2% <2n4 + n5 + 2n6 -14 62n - 14. Hence,
7n[20,,) +
n6 <n - 7. (1)Let
p4 (ps,respectively) be the number of good degree-4 (degree-5 respectively) vertices. There are n4 - p4 bad degree-4 vertices and
n5 - p5bad degree-5 ver- tices. Define S = CVEVIzo m)
deg(u).Since each bad degree-5 vertex u has at least two heavy neighbors, it contributes at least 2 to S. Consider a bad degree-4 vertex u. If u has at least three heavy neighbors, then u contributes at least 3 to S. Sup- pose
v has twoheavy neighbors u and w which are consecutive in N(u). The edges (u, u) and (u, w) contribute 2 to S. The edge (u, w) also contributes 2 to S. But since (u, w) is shared with one other face, just half of the contribution can be apportioned to u. It follows that the contribution of u to S is at least 3. Thus 3(n4 - p4) + 2(n5 -
ps)<S, which gives 3n4 + 2n5 - (3~4 + 2p5)6 ‘&q20,mj deg(u).This in turn implies:
3n4 + 2n5 + (An4 + 5n5) + 6% + 7n[7,19] - (3~4 +
2~5)
63n4 + 2% + C deg(u) + C deg(u) - (3p4 + 2p5)% b4.51 UEVI6,19]
d c deg(u) = 21EJ = 6n - 14 = 6(n4 + n5 + n6 + n[7,19] + n[zo,m)) - 14.
VEV
Simplifying this inequality yields: n4 + n5 + n[7,19] - (3p4 + 2p5)<6n[20,,j - 14.
Hence,
3p4 + 2p5 an - (n6 + 7n[2,,j) + 14. (2)
From (1) and (2): 3(p4 + p5)>3p4 + 2p5 >n - (n - 7) + 14 = 21. This proves the
lemma. 0
We are now ready to present our first REL construction algorithm.
Algorithm 1. REL (Input: A 4TP graph G = ( V, E)).
1. Compute the degrees of the vertices of G.
2. Collect all good degree-4 and degree-5 interior vertices into a list L.
3. i+-n.
4. While G has more than one interior vertex do:
4.1. Remove a vertex u from L. Mark u as wi. Decrease i by 1. Record the neigh- borhood structure of u.
4.2. Find a contractible neighbor u of U. Contract the edge (u,u). (The new vertex is still denoted by u). Modify the adjacency lists and the degrees of the vertices affected by the contraction. If any of the affected vertices becomes a good vertex, put it into L.
End While (the last marked vertex is we).
5. G has only one interior vertex now. Construct the trivial REL for G.
6. For i = 6 to n do:
Expand the edge e associated with wi. Compute the REL of the graph with e expanded from the REL of the graph with e contracted.
Theorem 3.3. Algorithm 1 computes an REL of a 4TP graph in O(n) time.
Proof. The correctness of the algorithm follows from the above discussion. We only need to analyze its complexity. Step 1 clearly takes O(n + m) = O(n) time. Since good vertices have degree at most 5, each of them can be determined and put into L in 0( 1) time. By Lemma 3.2, L will never be empty during the execution of the while loop.
Since the degree of a good vertex v is at most 5, the neighborhood structure of u can be recorded in 0( 1) time. Other operations of Step 4.1 can be easily done in 0( 1) time also.
The only nontrivial part is Step 4.2. We need to find a contractile neighbor of u in 0( 1) time. Suppose deg(u) = 5 and Ui (061’64) are u’s neighbors. If u has no heavy neighbor or has one heavy neighbor (say ug), we can check, for each pair ui, U,/ (1 <i, j <4), if they share a common neighbor. Since the degrees of Us and Uj are bounded by 19, this takes 0( 1) time. If none of the Ui ( 1 <i <4) is contractible, then us is contractible by Lemma 3.1. Now suppose deg(u) = 4 with neighbors ~0, ~1, ~2, ~43.
If u has at most one heavy neighbor, the situation is the same as the degree-5 case. If v has two heavy neighbors, then they are not consecutive in N(u). Suppose they are ua and 242. We can check if ui and ~3 share a common neighbor in O(1) time. If u1 and 243 have no common neighbors, then both of them are contractible. Otherwise uo and ~42 are contractible.
After selecting a contractible neighbor u for u, the operation of contracting (u, U) affects the vertices in N(u). The adjacency lists and the degrees of these vertices are modified. Since deg(u) < 5, this can be done in 0( 1) time by using the cross-linked
186 G. Kant, X HeITheoretical Computer Science 172 (1997) 175-193
adjacency lists data structure. New good vertices can be detected and inserted into L in O(I) time.
Finally, the edge expansion only involves 5 edges adjacent to the corresponding contracted edge. This can be done in 0( 1) time by using the neighborhood structure recorded at Step 4.1. 0
4.
REL algorithm based on canonical ordering
In this section we consider 4-connected triangulated plane graphs (all of whose faces, including the exterior face, are triangles). We introduce the canonical ordering for such graphs, which is the basis of our second algorithm for finding an REL of a 4TP graph G. Note that adding an edge connecting two non-adjacent exterior vertices of G leads to a 4-connected triangulated plane graph. The applications of the canonical ordering to other classes of planar graphs have been studied in [S, 121.
4.1. Canonical ordering of 4-connected triangulated plane graphs
Definition 4.1.
Let G = (V,E) be a 4-connected triangulated plane graph with three exterior vertices u, v, w. A canonical ordering of G is a labeling of V by { 01, Q., . . . , v,}such that VI = U, v2 = v, v, = w and the following requirements are met for every 4<k<n:
1. The subgraph Gk_t of G induced by vt, 272,. . . , uk-_l is bicomrected and the bound- ary of its exterior face is a cycle C&r containing the edge (u, 0).
2. Vk is in the exterior face of C&-t, and its neighbours in Gk-t form a subinterval of the path Ck-1 - {(u,v)} consisting of at least two vertices. If k < n - 2, vk has at least two neighbours in G - Gk_ 1.
Remark 2.
For a general triangulated plane graph G (not necessarily 4connected), a similar definition of canonical ordering of G was given in [S] where, in condition (2), the vertex uk is required to have at least one neighbor in G - Gk_t. Our definition is stronger since we require that the vertex Uk has at least two neighbors in G - Gk_ 1.Theorem 4.1.
Every 4-connected triangulatedplane graph G has a canonical ordering.Proof.
The ordering v,, v,-1 , . . . , v3 are defined by reverse induction. The three exterior vertices u, v, w are numbered by VI, vz and v,,. Let G,__r be the subgraph of G after deleting v,. By the 4-connectivity of G, the exterior face C-1 of G,,_t is a cycle and G,_t satisfies the conditions in Definition 4.1. Let v,_t be the third vertex of the interior triangular face of G adjacent to the edge (v~,v,). Then v,-1 # vt is a vertex of C-1 adjacent to both v2 and v, in G. By 4-connectivity, G - {v,, v,-1 } is biconnected and, hence, Gn__2 satisfies the conditions in Definition 4.1.Let k < n - 1 be fixed and assume that vi has been defined for every i > k such that the subgraph Gi induced by V - { Vi+1 , . . . , vn} satisfies the conditions in Definition 4.1.
Let Ck denote the boundary of the exterior face of Gk. We will pick a vertex on Gk to be the next vertex Uk in the ordering. Note that vk cannot be adjacent to a cord of Ck.
(Otherwise the exterior face Ck__l of G&r would not be biconnected and this would violate condition 1 of Definition 4.1.)
Assume first that Ck has no interior chords. Suppose ~1, cl,. . , cp, v2 are the vertices of Ck in this order between 01 and 02. Then it follows by the 4-connectivity of G that
p 2
2. If all vertices cl,. . . , cp have only one edge incident with the vertices in G - Gk, then since G is a triangulated graph, they are adjacent to the same vertex Uj for some j with k <j < n. In this case we also have (vt,uj),(v2,uj) E G. But then{(~1~Vj)~(Vj~v2)~( v2,q)) would be a separating triangle. Hence at least one vertex, say ca, has at least 2 neighbors in G - Gk. Define c, to be the next vertex Uk in our ordering.
Next assume Ck has interior chords. Let (c,,cb) (b > a + 1) be a chord such that b - a is minimal. Note that q, v2 q!
{c,+r ,
. . , C&l}. If all vertices &+I,. . . , q-1 have only one edge to the vertices in G - Gk, then since G is a triangulated graph, they are adjacent to the same vertex Uj withk < j,
and we also have (c,, ai), (Cb, Uj) E G. But then {(co, Vi), (Vj,Cb), (Cb,&)} would be a separating triangle. Hence there is at least one vertex c,,a < a <b,
having at least two neighbors in G - Gk and no incident chords. Define cI to be the next vertex Uk in our ordering. 0Guided by the proof of Theorem 4.1, the following algorithm computes the canonical ordering of G. For each vertex v of G, we keep the following variables:
l
Murk(u) = true,
if v has been added to the ordering, andfalse
otherwise.l
Visited(v) =
the number of v’s neighbors u withMurk(u) = true.
l
Chords(u) =
the number of chords of the exterior face of the subgraph induced by V - {U E V (Mark(u) = true}
that is incident to v.The algorithm is as follows.
Algorithm 2. Canonical Ordering (Input: A 4-connected triangulated plane graph G = (K-0)
1. Let u = vl, v = 212 and w = v, be the vertices on the exterior face.
2. Set
Chords(x)
andVisited(x)
to 0, andmark(x) = false
for all x EV.
SetVisited =
2.3. For
k
t n down to 3 do:3.1 Pick a vertex x with
Murk(x) = false, Visited(x) >
2 andChords(x) = 0,
and x # u, u. Let Uk = x and setMark(x) := true.
3.2
Let q,,.., Cj be the neighbors of Uk (in this order around uk) withMark(cl)
= false.
3.3
For each cl (i < I <<i), increaseVisited(q)
by one; update the variableChords
for cl and the neighbors of cl.Theorem 4.2.
Algorithm 2 computes a canonical ordering of a 4-connected triangu-
lated plane graph in O(n) time.
188 G. Kant, X. Hel Theoretical Computer Science 172 (1997) 175-193
PrOOf. Let Gk = G -
{t&f,, . . . ,
v,}. By the proof of Theorem 4.1, there always ex- ists a vertex x satisfying the conditions in Step 3.1. This proves the correctness of Algorithm 2.To find the vertex x in Step 3.1, we maintain a list L containing all vertices satisfying the conditions in Step 3.1. Testing these conditions and adding or deleting a vertex from L requires 0( 1) time.
Step 3.3 is implemented as follows: If j = i + 1, then since G is a triangulated plane graph, there was a chord (ci,Cj) of the exterior face of Gk, hence we decrease
Chords(s) and Chords(cj) by one, since (ci,cj) becomes part of the exterior face Ck_i of Gk_i. If j > i+ 1, then we compute Chords(cl) for each i < I
< j.
Notice that if Visited(z) > 0, then z has a neighbor y with Mark(y) = true, hence by planarity, z E Ck. For every vertex cl (i < 1<
j) we inspect its neighbors z. If Visited(z) > 0, and z # cl-i, c/+1, then (CI,Z) is a chord of the exterior face of Gk-i, and we increase Chords(cl) and Chords(z) by one. This requires O(deg(cl)) time in total. But since this is done only once for every vertex cl, the total running time is O(n). 04.2. From a canonical ordering to an REL
To compute an REL of a 4TP graph G, we first add an edge connecting two non- adjacent exterior vertices of G. This gives a 4-connected triangulated plane graph G’.
We compute a canonical ordering of G’ and then delete the added edge. The four exterior vertices of G are now numbered as vi, 02, v,_ 1, v,, respectively. Next we show that an REL of G can be derived from the canonical ordering.
First, for each edge (Vi,uj) of G, we direct it from vi to uj if i < j. Define the basis-edge of a vertex uk to be the edge (VI, Vk) for which I < k is minimal. The
VerkX vk has incoming edges from c, ,, . . . , Cj belonging to the exterior face C&i of Gk_i, assuming in this order from left to right. We call ci the leftpoint of vk and Cj
the rightpoint of t&. Let uk , , . . . , vk, be the higher-numbered neighbors of Vk, in this order from left to right. We call (Uk, ukl ) the Zeftedge and (Vk, ok,) the rightedge.
Lemma
4.3. A basis-edge cannot be a leftedge or a rightedge.Proof.
Assume the lemma is false. Suppose the lefiedge (vk, vk, ) of Uk is the basis-edge of Ok,. Thus ok is the lowest-numbered neighbor of vk,. Since G is triangulated, there is an edge between the leftpoint of uk, say Vi, with i < k, and uk,. But this contradicts the fact that (ok, uk, ) is the basis-edge of t&, . Analog follows for the rightedge. 0Lemma 4.4.
An edge is either a leftedge, a rightedge or a basis-edge.Proof.
Fix a vertex vk (3 < i < n - 2), we will show that each incoming edge of Vk is either a leftedge, or a rightedge, or a basis-edge. Suppose that the incoming edges of uk are from ci,. . . , Cj, in this order from left to right. Let (c,, uk) be the basis-edge of uk. All vertices cl (i < I<
j) have at least two higher-numbered neighbors, one of them is t&, the other one is adjacent to uk in cl’s neighbor set N(c,). Hence it is either+I
or
c/+1. Thus for each 1 (i < I < CL), cl+1 is the rightpoint of cl. Similarly, for each I (a d I < j), CL is the leftpoint of cl+,. Hence the edges (cl, Uk) are rightedges for i d 1 < c( and leftedges for CI < 1 < j. The edge (cI, Uk) is a basis-edge. Similarly, we can show the lemma holds for the incoming edges of v,_r and v,. 0We construct an REL for G as follows: all leftedges belong to Tr, all rightedges belong to T2. The basis-edge (c,,vk) of uk belongs to: (a) Tr, if r. = j; (b) Tz if a = i;
or (c) either Tr or T2, otherwise. (The four exterior edges belong to neither T1 nor Tz).
Lemma 4.5. {T, , T2} f arms a regular edge labeling for G.
fioof. Let uk, , . . . , vkd be the outgoing edges of the vertex Uk (3 < k d n-2). It follows from Definition 4.1 that d > 2. Then (uk, vk,) is the leftedge of vk and is in TI. (vk, vk,,) is the rightedge of vk and is in T2. The edges (Vk, vk2), . . . , (uk, ukd_, ) are the basis-edges of akZ,. . . , ukd_, , respectively. Let the vertex akli (1 6 p < d) be the highest-numbered neighbor of Uk. Then all vertices from Uk, to ok0 have a monotone increasing number, as well as the vertices from vkd to q,. (Otherwise there was a vertex v,&, such that
Vk,_ , and Vk,,, are numbered higher than rk,. But this implies that Uk is the only lower- numbered neighbor of Uk,, which is a contraction with the canonical ordering of G.) Hence for every Uk,, we have kl-1 < kl < k,+l if 1 < 1 < B; or kl-1 > k, > kr+l if p < 1 < d. Thus, by the construction of Tl and T2, the edges (uk, ok,) are in T, for 1 6 1 < b, and are in T2 for b < I < d. The edge (ok, u&) is arbitrarily added to either Tr or T2. This completes the proof that the edges appear in counterclockwise order around Uk as follows: a set of edges in T, entering Ok; a set of edges in T, entering ok; a set of edges in T2 leaving Vk; a set of edges in T, leaving ok.
Let v l,‘...,Uld be the higher numbered neighbors of vr from left to right. Then a11 = v, and vrd = VZ. By the argument described above, (or, VI>), . . . , (~2, q_, ) belong to T2. Similarly, all outgoing edges of v2 belong to TI. All incoming edges of v,_]
belong to T2, and all incoming edges of v, belong to Tl. This completes the proof. 0
Since the construction of { Tl, Tz} from the canonical numbering can be easily done in O(n) time. Theorem 4.2 and Lemma 4.5 constitute our second linear time REL algorithm.
5. Algorithm for visibility representation
The visibility representation of a planar graph G maps the vertices of G to horizontal line segments and edges of G to vertical line segments such that, for each edge e = (u, v), the vertical line segment corresponding to e touches only the two horizontal line segments corresponding to u and v (see Figure 5 for an example). A visibility representation of G with size (2n - 5) x (n - 2) can be constructed in linear time [ 17,201.
In this section, we show that the canonical ordering can be used to construct a visibility
190 G. Kant, X. He! Theoretical Compuier Science 112 (1997) 175-193
Fig. 5. The canonical ordering leads to a compact visibility representation.
representation of size (n - 1) x (n - 1) for 4-connected planar graphs. Thus, our algorithm reduces the width of the visibility representation by a factor of 2 for 4-connected planar graphs.
Let G be a 4-connected plane graph. Let G’ be a plane triangulation of G. Clearly, G’
is still 4-connected. After we obtain a visibility representation of G’, we can delete the line segments corresponding to the added edges and obtain a visibility representation of G. From now on we assume, without loss of generality, that G is a 4-connected triangulated plane graph.
Suppose that the canonical ordering of G is ul,uz,. ..,v,. We direct an edge (ui,uj) of G as Vi + Uj, if i < j. G is a planar St-graph and every vertex (except vi,v2,v,_i and a,) has at least 2 incoming and 2 outgoing edges. Let d(v) denote the length of the longest path from the source vi of G to v. We construct the dual graph G* of G and direct the edges of G* as follows: if Fl and F, are the let? and the right face of some edge (v, w) of G, direct the dual edge from Fl to F, if (a, w) # (vi, v,) and from F, to F/ if (a, w) = (vi, v,). G* is a planar St-graph. For each node F of G*, let d*(F) denote the length of the longest path from the source node of G* to F. Our visibility representation algorithm is very similar to the rectangular dual algorithm.
Algorithm 3. Visibility Representation (Input: A 4-connected triangulated plane
graph G.1
1. Compute a canonical ordering 2. Construct the planar St-graphs 3. Compute d(u) for the vertices 4. For each vertex v of G do:
of G.
G and its dual G*.
of G and d*(F) for the nodes of G*.
If u # vi,v,, draw horizontal line between (d*(left(u)),d(v)) and (d*(right(u))- Ld(v)).
If v = 01 or v,, draw horizontal line between (O,d(u)) and (D,d(u)), where D is the length of the longest path between the source node and the sink node in G*.
5. For each edge (~,a) of G do:
Draw vertical line between (d*(lef(u, u)),d(u)) and (d*(Zefi(u, ~)),d(o)).
Fig. 5 shows an example of this algorithm.
Theorem 5.1. Algorithm 3 constructs, in linear time, a visibility representation of G on a grid of size at most (n -
1) x (n - 1).Proof.
Rosenstiehl and Tajan [17] and Tamassia and Tollis [20] proved that whenever we construct in step 1 an ordering of the vertices of G that indices a planar st- graph, Algorithm 3 always constructs a visibility representation. Since the canonical ordering satisfies this requirement, our algorithm is correct. Since the construction of the canonical ordering talkesO(n)
time, and all other steps takes O(n) time [17,20], Algorithm 3 runs in linear time. We need to show the size of the grid is at most(n -
1) x (n - 1). Since the length of the longest path from vi to v, is at most n - 1, the height of the representation is clearly bounded byn -
1.Let s* be the source node of G* and t* be the sink node of G*. Every vertex v of G corresponds to a face
F,
of G*. If v # VI, ~2, v,-1, v,, then v has at least 2 incoming and at least 2 outgoing edges, hence the two directed paths from low(F,) tohigh(F,)
both have length at least 2. Let G*’ be the graph obtained from G* by removing the sink node t* and its incident edges. (In Fig. 5, s* is the node represented by the square labeled by 0. t* is the node represented by the square labeled by 11.) This merges the facesF,, ,F,,
andF,”
of G* into one faceF’.
Note that for any faceF # F,,_,
of G*‘, the two directed paths ofF
betweenlow(F)
andhigh(F)
in G*’have length 3 2.
Let s*’ be the source of G*’ and let t*’ be the sink of G*‘. Notice that s*’ = s* =
low(F’)
and t*’ = leff((v2, v,)) =high(F’).
(In Fig. 5, t*’ is the node represented by the square labeled by 10.) Clearly, there are at least two edges e in G*’ with left(e) =Fun_,
and the only edge e withright(e) = Fun_,
has endpoint t*‘. Let Ptong be any longest path in G*’ from s*’ to t*‘. Then the length of any longest path from s* to t* in G* is 1 plus the length of Z&s.Claim. Plong has at most one consecutive sequence of edges in common with any face F of G*‘.
Toward a contradiction assume the claim is false. Suppose that Ptong visits some nodes of
F,
assume that wi is the last one, then I 3 1 nodes ~1,. . . , UI q?F,
then some nodes ofF
again, let wd be the first one. Let ~2,. . . , wd- 1 be the nodes, in this order, ofF,
which are not visited by Ptong (see Fig. 6). SupposeF = right((wl, ~2)).
(IfF = Zeft((w2,wz)),
the proof is similar.) LetF1 = Zeft(( ~1,
~2)). Notice that w2 =Zow(F1).
The directed path of
F,,
starting with edge ( wi, w2), has length 3 2. Hence 02 has an outgoing edge to a node ofFI,
and an outgoing edge to ws. Thus w2 = low(Fz), with F2 =feft((w2, ~3)).
Repeating this argument it follows that wd-_l =low(Fd_l),
with Fd-i =/eft((wd-1, wd)).
However it is easy to see that Wd =high(Fd_1).
This means that one of the two directed paths ofFd_1
has length 1. This contradiction proves the claim.192 G. Kant, X Hel Theoretical Computer Science 172 (1997) 175-193
low(F)
high(F) \ Fig. 6. Example of the proof of Theorem 5.1.
When traversing an edges e of &,,s, we visit either left(e) or right(e) (or both) for the first time. If the face left(e) is visited for the first time, we assign e to ZeJ?(e). If the face right(e) is visited for the first time, we assign e to right(e). If both left(e) and right(e) are visited for the first time, we arbitrarily assign e to either of the two faces.
Consider any F of G*‘. By the claim, Plong has at most one consecutive sequence PF of edges in common with F and only the first edge of PF can be assigned to F. Thus at most one edge e E Plong is assigned to F.
In summary, each edge e of PI,,,,~ is assigned to a face of G*’ and each face of G*’
is assigned at most one edge e E Plong. Since G*’ has n - 2 faces, the length of Plong is at most n - 2. Hence, the width of the visibility representation is at most n - 1. 0
6. Conclusion
We presented two linear time algorithms for constructing an REL of 4TP graphs. We also use the RIZL algorithms to solve the rectangular dual problem. Our algorithm is much simpler than the previously known ones. More importantly, the coordinates of the rectangular dual constructed by our algorithm are integers and carry clear combinatorial meanings. This allows us to consider the related optimization problems: Let w(R) and h(R) denote the width and the height of the rectangular dual R. How to find a rectangular dual R such that w(R) is minimized? w(R) + h(R) is minimized? or w(R)h(R) is minimized? These problems deserve further study.
For the visibility representation problem, our algorithm reduces the size of the rep- resentation by a factor of 2 for 4-connected planar graphs. Recently, using this result, Kant proved that every general planar graph has a visibility representation on a grid of size at most (L$nJ - 2) x (n - 1) [13].
An important tool used in our paper is the canonical ordering. Such an ordering im- plies an acyclic orientation of the graph, in which every vertex (except ui,u2, u,_t, a,) has at least 2 incoming and at least 2 outgoing edges. This extends the results for the St-ordering for biconnected plane graphs [17] (in which every vertex V,V # ul,u,, has at least 1 incoming and at least 1 outgoing edge in the acyclic orientation);
and the canonical ordering for triangulated plane graphs [12] (in which every ver- tex v, v # vi, ~2, v,,, has at least 2 incoming and at least 1 outgoing edge in the
acyclic orientation). It would be nice to obtain more applications of this canonical ordering.
References
[I ] J. Bhasker and S. Sahni, A linear algorithm to check for the existence of a rectangular dual of a planar triangulated graph, Networks 17 (1987) 307-317.
[2] J. Bhaskar and S. Sahni, A linear algorithm to find a rectanular dual of a planar triangulated graph, Algorithmica 3 (1988) 247-278.
[3] N. Chiba and N. Takao, Arbority and subgraph listing algorithms, SIAM J. Comput. 14 (1985) 210-223.
[4] G. Di Battista, P. Eades, R. Tamassia and LG. Tollis, Algorithms for drawing graphs: an annotated bibliography, Comput. Geom. Theory Appl. 4 (1994) 235-282.
[5] H. de Fraysseix, J. Path and R. Pollack, How to draw a planar graph on a grid, Combinatorics 10 (1990) 41-51.
[6] T. Hagerup, M. Chrobak and K. Diks. Optimal parallel 5-coloring of planar graphs, SIAM J. Comput.
18 (2) (1989) 288-300.
[7] X. He, On finding the rectangular duals of planar triangulated graphs, SIAM .I Comput. 22 (1993) 1218-1226.
[8] X. He, An efficient parallel algorithm for finding rectangular dual duals of planar triangular graphs, Algorithmica 13 (6) (1995) 553-572.
[9] X. He, Grid embedding of 4-connected plane graphs, in: Proc. Graph Drawing (GD’95), Lecture Notes in Comp. Science, Vol. 1027 (1995) 287-299.
[lo] W.R. Heller, G. Sorkin and K. Mailing, The planar package planner for system designers. in: Proc.
19th Ann. IEEE Design Automation Conf, New York (1982) 253-260.
[ll] J. Hopcrot? and R.E. Tarjan, Efficient planarity testing, J. ACM 21 (4) (1974) 549-568.
[12] G. Kant, Drawing planar graphs using the Imc-ordering, in Proc. 33th Ann. IEEE Symp. on Found.
of Comp. Science, Pittsburgh (1992) 101-I 10.
[13] G. Kant, A more compact visibility representation, in: Proc. 19th Intern. Workshop on Graph-Theoretic Concepts in Comp. Science (WG’93), Lecture Notes in Comp. Science, Vol. 790 (Springer, Berlin, 1993) 41 l-424.
[14] K. Koimiriski and E. Kinnen, Rectangular dual of planar graphs, Networks 15 (1985) 145-157.
[15] Y.-T. Lai and SM. Leinwand, A theory of rectangular dual graphs, Algorithmica 5 (1990) 467-483.
[16] K. Mailing, S.H. Meuller and W.R. Heller, On finding most optimal rectangular package plans. Proc.
19th Ann. IEEE Design Automation Conf, New York (1982) 263-270.
[17] P. Rosenstiehl and R.E. Tarjan, Rectilinear planar layouts and bipolar orientations of planar graphs, Discrete Comp. Geometry 1 (1986) 343-353.
[18] W. Schnyder, Planar graphs and poset dimension, Orders 5 (1989) 323-343.
[19] W. Schnyder, Embedding planar graphs on the grid, in: Proc. 1st Ann. ACM-SIAM Symp. on Discr.
Alg., San Francisco (1990) 138-147.
[20] R. Tamassia and I.G. Tollis, A unified approach to visibility representations of planar graphs, Discrete Comp. Geometry 1 (1986) 321-341.