• 沒有找到結果。

Orderly Spanning Trees with Applications

N/A
N/A
Protected

Academic year: 2021

Share "Orderly Spanning Trees with Applications"

Copied!
22
0
0

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

全文

(1)

ORDERLY SPANNING TREES WITH APPLICATIONS YI-TING CHIANG, CHING-CHI LIN,AND HSUEH-I LU

Abstract. We introduce and study orderly spanning trees of plane graphs. This algorithmic

tool generalizes canonical orderings, which exist only for triconnected plane graphs. Although not every plane graph admits an orderly spanning tree, we provide an algorithm to compute an orderly

pair for any connected planar graph G, consisting of an embedded planar graph H isomorphic to G,

and an orderly spanning tree of H. We also present several applications of orderly spanning trees: (1) a new constructive proof for Schnyder’s realizer theorem, (2) the first algorithm for computing an area-optimal 2-visibility drawing of a planar graph, and (3) the most compact known encoding of a planar graph with O(1)-time query support. All algorithms in this paper run in linear time.

Key words. planar graph algorithm, graph drawing, realizer, visibility representation, canonical

ordering, orderly spanning tree, graph encoding, triangulation, unit-cost RAM model, succinct data structure, data compression

AMS subject classifications. 05C62, 05C85, 68P05, 68W35, 68U05, 68R10, 94C15

DOI. 10.1137/S0097539702411381

1. Introduction. A plane graph is a planar graph equipped with a plane em-bedding. Canonical orderings of triconnected plane graphs [11, 19, 27, 28] are crucial in several graph-drawing and graph-encoding algorithms [7, 8, 9, 16, 20, 22]. This paper introduces the orderly spanning tree as an algorithmic tool that generalizes the concept of canonical orderings for plane graphs that are not required to be tricon-nected. The concept of orderly spanning trees of plane graphs originates from that of canonical spanning trees of triconnected plane graphs [9], but the former is more general even for triconnected plane graphs (see section 2.1 and Figure 2.1(b)).

We say that (H, T ) is an orderly pair of G if (1) T is an orderly spanning tree of plane graph H, and (2) G and H, ignoring their embeddings, are isomorphic planar graphs. Although not every connected plane graph admits an orderly spanning tree (see section 2.1 and Figure 2.2(a)), we provide a linear-time algorithm (see section 2.2) to compute an orderly pair for any connected planar or plane graph. We also present three applications of orderly spanning trees in the paper.

Application 1: Realizers of planar graphs. A graph is simple if it contains no

multiple edges. For the first application of orderly spanning trees, we present a new linear-time algorithm to compute a realizer for any plane triangulation (i.e., simple triangulated plane graph with at least three nodes). Schnyder [38] gave the first known linear-time algorithm that computes a realizer for any plane triangulation, thereby settling the open question on the dimension [42, 14] of planar graphs. This celebrated result also yields the best known straight-line drawing of planar graphs on

Received by the editors July 13, 2002; accepted for publication (in revised form) October 29,

2004; published electronically May 12, 2005. A preliminary version appeared in Proceedings of the 12th Annual ACM–SIAM Symposium on Discrete Algorithms, Washington, D.C., 2001, pp. 506– 515. This research is supported in part by NSC grants 89-2213-E-001-034, 89-2218-E-001-014, and 93-2213-E-001-002.

http://www.siam.org/journals/sicomp/34-4/41138.html

Institute of Information Science, Academia Sinica, 128 Academia Road, Section 2, Taipei 115,

Taiwan, Republic of China.

Department of Computer Science and Information Engineering, National Taiwan

Univer-sity, 1 Roosevelt Road, Section 4, Taipei 106, Taiwan, Republic of China (hil@csie.ntu.edu.tw, http://www.csie.ntu.edu.tw/hil/).

(2)

simple plane triangulation, is quite simple.

Application 2: Optimal 2-visibility drawings of planar graphs. For the second

application of orderly spanning trees, we give an O(n)-time algorithm that produces a 2-visibility drawing of area at most (n− 1) ×2n+1

3 

for any n-node simple plane graph H with n≥ 3. Let v1, v2, . . . , vn be the nodes of H. A 2-visibility drawing [16] of H consists of n nonoverlapping rectangles b1, b2, . . . , bn such that if vi and vj are adjacent in H, then biand bjare visible to each other either horizontally or vertically.1 For example, the picture in Figure 1.1(b) is a 2-visibility drawing of the plane graph in Figure 1.1(a). F¨oßmeier, Kant, and Kaufmann [16] gave an O(n)-time algorithm to compute an x× y 2-visibility drawing for H with x + y ≤ 2n and conjectured that it is “not trivial” to improve their upper bound. Moreover, they showed an n-node plane triangulation whose x× y 2-visibility drawing requires x + y ≥ n − 1 +2n+13  and min{x, y} ≥2n+1

3 

.2 According to their lower bounds, the 2-visibility drawing produced by our algorithm is worst-case optimal.

In order to take advantage of the wonderful properties of canonical orderings, many drawing algorithms work on triangulated versions of input plane graphs. As pointed out in [19], the initial triangulation tends to ruin the original plane graph’s structure. Our orderly pair algorithm appears as a promising tool for drawing graphs neatly and compactly, without first triangulating the given plane graphs. The concept of an orderly pair is more general than that of a canonical ordering, since all known canonical orderings are only defined for triconnected plane graphs. The technique of orderly pairs is potentially more powerful, since it exploits the flexibility of planar graphs whose planar embeddings are not predetermined.

Application 3: Convenient encodings of planar graphs. For the third application of

orderly spanning trees, we investigate the problem of encoding a graph G into a binary string S with the requirement that S can be decoded to reconstruct G. This problem has been extensively studied with three objectives: (1) minimizing the length of S, (2) minimizing the time required to compute and decode S, and (3) supporting queries efficiently. As these objectives are often conflicting, a number of coding schemes with different trade-offs have been proposed in the literature. The widely useful adjacency-list encoding of an n-node m-edge graph G requires 2mlog2n bits. See [9, 22, 23,

29, 34, 37, 43] for O(n)-bit encodings of n-node planar graphs without efficient query supports.

Under the model of unit-cost RAM [5, 10, 17, 40, 41, 45], where operations such as read, write, and add on O(log n) consecutive bits take O(1) time, an encoding S of G is weakly convenient [9] if it takes (i) O(m + n) time to encode G and decode

S, (ii) O(1) time to determine from S the adjacency of any two nodes in G, and

(iii) O(d) time to determine from S the neighbors of a degree-d node in G. If the degree of a node can be determined from a weakly convenient encoding S in O(1) time, then S is convenient [9]. For a planar graph G having multiple edges but no self-loops, Munro and Raman [35] gave the first nontrivial convenient encoding of G with 2m + 8n + o(m + n) bits. Their result is based on the four-page decomposition of planar graphs [46] and auxiliary strings, encoding an involved three-level data

1A closely related rectangle-visibility drawing [13, 12, 25, 3] of H requires that v

i and vj are

adjacent in H if and only if biand bjare visible to each other. 2The lower bounds stated in [16] are x + y 5n

3 and min{x, y} ≥ 2n

3 . Based on the given

sketch of proof, however, it is not hard to see that their lower bound should be corrected as x + y≥

(3)

(b) 10 2 4 3 5 6 7 8 11 9 12 1 4 3 6 7 1 10 11 12 8 9 5 4 2 3 6 7 1 10 11 12 (a) (c) 8 9 5 2

Fig. 1.1. (a) A plane graph H with an orderly spanning tree of H rooted at node 1 represented

by the thick edges. (b) A 2-visibility drawing of H. (c) A realizer (T1, T2, T12) of H, where T1

(respectively, T2 and T12) consists of the thick (respectively, dashed and thin) edges.

structure for any string of parentheses. For a planar graph G that has (respectively, has no) multiple edges, Chuang, Garg, He, Kao, and Lu [9] improved the bit count to 2m +5 + 1kn + o(m + n) (respectively, 53m +5 + 1kn + o(n)) for any positive

constant k. They also provided a weakly convenient encoding of 2m +143n + o(m + n)

(respectively, 43m + 5n + o(n)) bits for a planar graph G that has (respectively, has

no) multiple edges. Based on our orderly pair algorithm, in this paper we present the best known convenient encodings for a planar graph G: If G may (respectively, does not) contain multiple edges, then the bit count of our encoding is 2m + 3n + o(m + n) (respectively, 2m + 2n + o(n)), which is even less than that of the weakly convenient encodings of Chuang et al. [9]. The bit counts are very close to Tutte’s information-theoretical lower bound of roughly 3.58m bits for encoding connected plane graphs without any query support [44]. The bit count of our encoding for a planar graph

G without multiple edges matches that of the best known convenient encoding for

an outerplanar graph [35]. Besides relying on the orderly pair algorithm, our results are also based on an improved auxiliary string for a folklore encoding [9, 21, 35] of a rooted tree T . With the auxiliary strings of Munro and Raman [35], computing the degree of a degree-d node in T requires Θ(d) time. In this paper, we present a nontrivial auxiliary string, in Lemma 5.3, to support the degree query in O(1) time.

Recent applications. Besides the applications presented in the present paper, our

orderly pair algorithm also yields the following recent results:

• Improved compact distributed routing tables for any n-node distributed

pla-nar network [33], improving the best previously known design of Gavoille and Hanusse [18] by reducing the worst-case table size count from 8n + o(n) bits to 7.181n + o(n) bits, without increasing the time complexity of preprocessing and query.

• A linear-time algorithm for compact floor-plans of plane triangulations [30,

31], which is not only much simpler than the previous methods in the litera-ture [20, 47] but also provides the first known nontrivial upper bound on the floor-plan’s area.

• Compact Podevs drawings for plane graphs and an alternative proof for the

sufficient and necessary condition for a planar graph to admit a rectangular dual [6].

• Improved upper bounds on the number of planar graphs via so-called well orderly spanning trees, which are orderly spanning trees with additional

(4)

prop-(b) (c) 2 P (vi) U<(vi) U>(vi) D(vi) vi 7 2 3 4 6 5 1 (a) 7 6 3 4 5 9 8 11 10 12

Fig. 2.1. (a) The tree rooted at node 1, consisting of the thick edges, is not an orderly spanning

tree of the plane graph. (b) A triconnected plane graph H, where the thick edges form an orderly spanning tree T , rooted at node 1, of H. The counterclockwise preordering of T is not a canonical ordering of H. (c) Illustration for the orderly pattern of vi.

erties [2].

Organization of the paper. The rest of the paper is organized as follows.

Sec-tion 2 gives the linear-time algorithm for computing an orderly pair of any given planar graph. Applications are given in sections 3–5. Section 3 gives the linear-time algorithm for computing a realizer of any given plane triangulation. Section 4 shows the linear-time algorithm for obtaining an area-optimal 2-visibility drawing of any given plane graph. Section 5 presents the best known convenient encodings for planar graphs.

2. Orderly spanning trees for plane graphs.

2.1. Basics. Unless stated otherwise, all graphs in sections 2–4 are simple. Let H be a plane graph. The outer boundary of H is the boundary of the external face

of H. The nodes and edges on the outer boundary of H are external in H; and the other nodes and edges are internal in H.

Let T be a rooted spanning tree of a connected plane graph H. Two distinct nodes of H are unrelated with respect to T if neither of them is an ancestor of the other in T . An edge e of H is unrelated with respect to T if the endpoints of e are unrelated with respect to T . Let v1, v2, . . . , vn be the counterclockwise preordering of the nodes in T . A node vi is orderly in H with respect to T if the neighbors of vi in H form the following four blocks of H with respect to T in counterclockwise order around vi, where each block could be empty.

• P (vi): the parent of vi in T ;

• U<(vi): the nodes vj with j < i that are unrelated to vi with respect to T ;

• D(vi): the children of vi in T ; and

• U>(vi): the nodes vj with j > i that are unrelated to vi with respect to T . (See Figure 2.1(c).) T is an orderly spanning tree of H if (i) v1 is on the outer boundary of H and (ii) each node vi is orderly in H with respect to T . If T is an orderly spanning tree of H, then each incident edge of v1 in H belongs to T . An example of an orderly spanning tree is given in Figure 1.1(a). Figure 2.1(a) provides a negative example of an orderly spanning tree, where nodes 1, 3, 8, and 10 are not orderly in H with respect to T .

Not every connected plane graph admits an orderly spanning tree. However, as to be shown in this section, there always exists a planar embedding for any given planar graph that admits an orderly spanning tree. For example, consider the plane graph

(5)

(b) 2 2 3 1 4 5 6 1 3 4 5 6 (a)

Fig. 2.2. (a) A plane graph H that has no orderly spanning trees. (b) A different planar

embedding of H that admits an orderly spanning tree rooted at node 1, consisting of the thick edges.

H in Figure 2.2(a). Assume for a contradiction that H admits an orderly spanning

tree T rooted at node 1. Observe that the thick edges must be in T , and thus the thin edges cannot be in T . Now, T contains exactly one of the dashed edges. In either case, however, the parent of node 6 in T is not orderly in H with respect to

T , thereby contradicting the assumption that T is an orderly spanning tree rooted at

node 1. Since H is rotationally symmetric, H admits no orderly spanning trees. If we change the planar embedding of H by moving edge (2, 5) to the interior of H, as shown in Figure 2.2(b), then the new plane graph has an orderly spanning tree rooted at node 1 consisting of the thick edges.

The concept of orderly spanning trees of plane graphs originates from those of canonical orderings and canonical spanning trees of triconnected plane graphs. Let

H be a triconnected plane graph. A canonical ordering of H is a certain ordering of

the vertices in H, first introduced by de Fraysseix, Pach, and Pollack [11] for plane triangulations, and extended to triconnected plane graphs by Kant [27]. Specifically, let v1, v2, . . . , vn be an ordering of the nodes of H. Let Hi be the subgraph of H induced by v1, v2, . . . , vi. Let Bi be the outer boundary of Hi. This ordering is

canonical if the interval [3, n] can be partitioned into I1, . . . , IK with the following properties for each Ij. Suppose Ij = [k, k + q]. Let Cj be the path vk, vk+1, . . . , vk+q.

• Hk+q is biconnected. Bk+q contains the edge (v1, v2) and Cj. Cj has no chord in H.

• If q = 0, vk has at least two neighbors in Hk−1, all on Bk−1. If q > 0, Cj has exactly two neighbors in Hk−1, both on Bk−1, where the left neighbor is incident to Cj only at vk and the right neighbor only at vk+q.

• For each vi with k ≤ i ≤ k + q, if i < n, vi has at least one neighbor in

H− Hk+q.

Chuang et al. [9] defined a canonical spanning tree T of H as a way to find parents in T for all except one node of H according to any given canonical ordering of H. Specifically, for the given canonical ordering of H, the canonical spanning tree T of

H rooted at v1 is the one formed by the edge (v1, v2) together with the paths Cj and the edges (v, vk) over all Ij, where v is the leftmost neighbor of Cj on Bk−1. By the triconnectivity of H, it is implicit in [9] that (a) any canonical spanning tree T of H has to be an orderly spanning tree of H, and (b) the counterclockwise preorder-ing of T is the given canonical orderpreorder-ing of H. As shown in Figure 2.1(b), however, the counterclockwise preordering of an orderly spanning tree for a triconnected plane graph H may not be a canonical ordering of H. Therefore, the concept of orderly spanning trees is more general than that of canonical spanning trees even for tricon-nected plane graphs. The counterclockwise preordering of any orderly spanning tree of a plane triangulation Δ has to be a canonical ordering of Δ, though.

(6)

H prev(H, v) cw(H, r, v) next(H, v) ccw(H, r, v) v

Fig. 2.3. Illustration of the definitions of prev(H, v), next(H, v), cw(H, r, v), and ccw(H, r, v).

2.2. The orderly pair algorithm. For plane graphs H and G, H ∼ G denotes

that H and G (ignoring their plane embeddings) are isomorphic planar graphs. We say that (H, T ) is an orderly pair of a connected planar graph G with respect to r if (i) H ∼ G and (ii) T rooted at r is an orderly spanning tree of H. This subsection shows how to compute an orderly pair for any planar graph in linear time. Without loss of generality, we may assume that the input planar graph is already equipped with a planar embedding represented by an adjacency list, where each node v keeps a doubly linked list, storing its neighbors in counterclockwise order around v. Moreover, the two copies of each edge are cross-linked to each other. Such a representation can be obtained as a by-product by running the linear-time planarity-testing algorithm of Hopcroft and Tarjan [24] or that of Boyer and Myrvold [4]. Based upon this representation, deleting an edge takes O(1) time. Moreover, moving an edge e to the interior of a face F can be conducted in O(1) time, as long as an edge on the boundary of F incident to each endpoint of e is provided. (Our algorithm moves an edge e to the interior of F only when it traverses the boundary of F .)

To describe the algorithm, we need some definitions for a 2-connected plane graph

H. If v is an external node in H, then let nextH, v (respectively, prevH, v) denote

the external node of H that immediately succeeds (respectively, precedes) v in coun-terclockwise order around the outer boundary of H. For any two distinct external nodes r and v of H, let ccw(H, r, v) (respectively, cw(H, r, v)) denote the sequence of the external nodes of H from r to v in counterclockwise (respectively, clockwise) order around the outer boundary of H. Observe that prev(H, v)∈ ccw(H, r, v) and next(H, v)∈ cw(H, r, v). Define boundary(H, r) = ccw(H, r, prev(H, r)), i.e., the se-quence of the external nodes of H from r to prev(H, r) in counterclockwise order around the outer boundary of H. See Figure 2.3 for an illustration. For example, if H is the plane graph shown in Figure 2.2(b), then we have that next(H, 2) = 6, prev(H, 2) = 1, ccw(H, 1, 6) = (1, 2, 6), cw(H, 1, 6) = (1, 5, 6), and boundary(H, 1) = (1, 2, 6, 5).

The key component of our orderly pair algorithm is the recursive subroutine block(G, r, v) shown below. Given any 2-connected plane graph G and two distinct external nodes r and v of G, the subroutine block(G, r, v) computes an orderly pair (H, T ) of G with respect to r. Let us emphasize that v can be any external node of G other than r. The high-level strategy of block(G, r, v) is to identify a neighbor p of v in G that can be the parent of v in T . The subroutine then deletes v and its incident edges and recursively works on each 2-connected component of the remaining graph. The difficulty lies in efficiently choosing an appropriate parent of v with possible modification to the plane embedding of G. More precisely, we want the subroutine to alter the embedding of G into H and find a neighbor p of v such that (1) the required time is linear in the total size of the internal faces of G that contains v and (2) the

(7)

following property Π holds for H and p:

For each neighbor x of v in H other than p, if x and prev(H, v) (respectively, next(H, v)) are on the same side of (v, p) in H, then (v, x) is on the first (respectively, last) internal face of H containing

v and x in counterclockwise order around v starting from the one

containing (v, next(H, v)).

(See Figure 2.5(b) for an illustration of property Π.) It turns out that a two-phase process serves the purpose: We say that an edge of G is movable if the embedding of G can be changed by moving the edge into a face of G. For example, edges (1, 2), (2, 5), and (5, 1) are the movable edges in the plane graph shown in Figure 2.2(a). Imagine that node v is at the “bottom” of G. The first phase flips each movable incident edge of v to the leftmost possible face. At the end of the first phase, the node p is exactly the neighbor of v on cw(G, r, v) that is closest to r. After determining p, the second phase flips each movable incident edge of v that is to the left of edge (p, v) to the rightmost possible face.

When recursively taking care of each 2-connected component Gi of G, the sub-routine has to choose two distinct nodes riand vi on the outer boundary of Gi for the recursive subroutine call block(Gi, ri, vi). For any choice of ri and vi, the subroutine call will return an orderly pair (Hi, Ti) of Gi with respect to ri. However, to ensure that gluing all returned orderly pairs together yields an orderly pair of G, we have to be careful about the choice of each vi.

The detailed description of block(G, r, v) is as follows. Subroutine block(G, r, v).

Step 1. If G consists of a single edge (r, v), then return (G, G); otherwise, perform

steps 2–7.

Step 2. Perform step 2.1 for each internal face F incident to node v in G in clockwise

order around v starting from the one containing (v, prev(G, v)).

Step 2.1. For any node x in F such that (v, x) is an edge of G succeeding F in

clockwise order around v starting from (v, next(G, v)), update the planar embedding of G by flipping (v, x) into the interior of F .

Remark. For instance, if v and F are as shown in Figure 2.4, then

(v, x1) and (v, x2) will be flipped into the interior of F by step 2.1.

Step 3. Let p be the neighbor of v in G closest to r in cw(G, r, v).

Step 4. Perform step 4.1 for each internal face F of G that succeeds (v, p) in

counter-clockwise order around v starting from the face containing (v, p):

Step 4.1. For any node x in F such that (v, x) is an edge of G succeeding F in counterclockwise order around v starting from (v, next(G, v)),

update the planar embedding of G by flipping (v, x) into the interior of F .

Remark. For instance, if v and F are as shown in Figure 2.4, then

(v, x3) and (v, x4) will be flipped into the interior of F by step 4.1.

Step 5. Let G be the graph obtained by deleting all the incident edges of v in G, except for (v, p). Compute the 2-connected components of G by traversing the segment of the outer boundary of G from prev(G, v) to next(G, v) in counterclockwise order around the outer boundary of G.

Remark. Since G is 2-connected, we know that all 2-connected components

of G are external to one another. Therefore, the above traversal of part of the outer boundary will suffice. Also, by the definitions of G and p, one of the 2-connected components of G consists of the single edge (v, p).

(8)

x1 prev(G, v) next(G, v) v x3 x4 x2 F

Fig. 2.4. F is an internal face of G containing nodes v and xi, but not edge (v, xi) for each

i∈ {1, 2, 3, 4}.

Step 6. Compute (Hi, Ti) = block(Gi, ri, vi) for each 2-connected component Gi of

G, where ri is the node of Gi closest to r in G, and vi is defined as follows:

Case 1. Gi= (v, p). Let vi= v.

Case 2. Giand prev(G, v) are on the same side of (v, p) in G. Let S consist of the nodes in both ccw(Gi, next(Gi, ri), prev(Gi, ri)) and ccw(G, r, v). If S is empty, then let vi = next(Gi, ri). Otherwise, let vi be the last node of S in counterclockwise order around the outer boundary of

Gi.

Case 3. Giand next(G, v) are on the same side of (v, p) in G. Let S consist of the nodes in both ccw(Gi, next(Gi, ri), prev(Gi, ri)) and cw(G, r, v). If S is empty, then let vi= prev(Gi, ri). Otherwise, let vibe the first node of S in counterclockwise order around the outer boundary of

Gi.

Step 7. Return (H, T ), where H is obtained from G by replacing each Gi with Hi, and T is the union of all Ti.

An illustration of block(G, r, v) is given in Figure 2.5. Let G be the 2-connected plane graph shown in Figure 2.5(a). At the completion of step 4, the resulting em-bedding of G and p are as shown in Figure 2.5(b), where the gray ellipse with label

i is the ith 2-connected component Gi of G. Note that (v, p) is also a 2-connected component of G. One can verify that after step 6 we have that r1 = r, r2 = r6,

r8 = r9, r11 = r12 = p, and v11 = v. For the 2-connected components lying on the same side of (v, p) with prev(G, v), we have v1= r2, v2= r3, v3= r4, v4= prev(G, v), and that vi = next(Gi, ri) holds for each i∈ {5, 6, . . . , 10}. For the 2-connected com-ponents lying on the same side of (v, p) with next(G, v), we have v12= r13, v13= r15,

v14= prev(G14, r14), and v15= next(G, v).

Lemma 2.1. If r and v are two distinct external nodes of a 2-connected plane

graph G, then block(G, r, v) outputs an orderly pair of G with respect to r.

Proof. Let (H, T ) be the output of block(G, r, v). We prove the following

proper-ties of (G, H, T, r, v) by induction on the number of edges in G:

1. Each external node of G remains external in H. Moreover, boundary(G, r) is a subsequence of boundary(H, r).

2. (Property Π.) For each neighbor x of v in H other than p, if x and prev(H, v) (respectively, next(H, v)) are on the same side of (v, p) in H, then (v, x) is on the first (respectively, last) internal face of H containing v and x in counter-clockwise order around v starting from the one containing (v, next(H, v)). 3. T rooted at r is a spanning tree of H such that exactly one of the following

(9)

p (b) r v 7 10 12 8 3 4 5 2 6 1 13 14 15 r v 9 11 (a)

Fig. 2.5. (a) A 2-connected plane graph G, where each gray ellipse is a 2-connected component

of G− {v}. (b) The plane graph G at the completion of performing steps 1–4 of block(G, r, v). Observe that all edges incident to v, especially those dashed (i.e., movable) edges, satisfy property

Π.

conditions holds for each node u in ccw(H, r, v) (respectively, cw(H, r, v)): (i) u is a leaf of T ; or (ii) next(H, u) (respectively, prev(H, u)) is the lowest-indexed (respectively, highest-lowest-indexed) child of u in T .

4. H∼ G.

5. T rooted at r is an orderly spanning tree of H.

Properties 4 and 5 suffice, but we need the other properties to enable the induction step. When G consists of a single edge (r, v), by step 1 we have H = T = G. It is not difficult to see the inductive basis of each property holds. Suppose that G consists of k 2-connected components. By step 6, we have ri = vi for each i. It follows from the inductive hypothesis that properties 1–5 of (Gi, Hi, Ti, ri, vi) hold for each i∈ {1, 2, . . . , k}. The rest of the proof shows the induction step. For brevity, for each j = 1, 2, . . . , 5, we abbreviate “property j of (Gi, Hi, Ti, ri, vi)” to “property j of

Gi” and use “property j (of G)” to stand for “property j of (G, H, T, r, v).”

Property 1. Observe that throughout the execution of block(G, r, v), without

ac-counting for its subsequent subroutine calls to block, the embedding of G changes only by flipping edges into the interior of internal faces of G in steps 2 and 4. Thus, based on how H is obtained from G in step 7, it follows from property 1 of Gi for each i∈ {1, 2, . . . , k} that the property holds.

Property 2. Let property 2 stand for the property obtained from property 2 by replacing each H with a G. From steps 2 and 4, one can verify that the plane graph G at the completion of performing step 4 satisfies property 2. From property 2 and how

H is obtained from G in step 7, we know that the relative order among the incident

edges of v and the faces containing v remains the same in G and H. Therefore the property follows from property 2.

Property 3. For each i ∈ {1, 2, . . . , k}, property 3 of Gi implies that Ti is a spanning tree of Hi. Since H1, H2, . . . , Hk are edge disjoint, and each node of H belongs to some Hi, we know that T , the union of all Ti, is a spanning tree of H. Since v is a leaf of T , the required property holds for v. Let x be an external node of

H other than v. If (x, v) is not an external edge of H belonging to H− T , then the

(10)

next(H, v). Let Hj be the 2-connected component of H containing x. We have that

vj = x. By property 3 of Gj, x is a leaf of Tj. Since (x, v)∈ T , x is also a leaf of T and property 3 holds for x.

Property 4. Observe that steps 2 and 4 flip an edge (v, x) into the interior of F only if F contains both v and x. Therefore, the resulting embedding of G at

the completion of step 4 is still planar. According to how H is obtained from G in step 7, the property follows from property 1 of G and properties 4 of Gifor all indices

i∈ {1, 2, . . . , k}.

Property 5. Each neighbor of r in H is a child of r in T ; hence r is orderly in H with respect to T . The rest of the proof shows that each node x other than r is

orderly in H with respect to T . Let Hbe the graph obtained from H by deleting each incident edge of v in H− T . Observe that H∼ Gand that each Hi is a 2-connected component of H. Let Ixconsist of the indices i with x∈ Hi. As x= r, one can verify that there is an index j in Ixsuch that x= rj and x = rifor each index i∈ Ix− {j}. We first show that if (v, x) is an edge of H− H, then (v, x) is unrelated with respect to T . If the index of x is higher than that of v, then by the fact that v is a leaf in T , we know that (v, x) is unrelated. As for the case with the index of x lower than that of v, let us assume for a contradiction that x is an ancestor of v in T . Since (v, x)∈ H − T and p is the parent of v in T , we know that x is also an ancestor of p in T . Let P be the path of T between r and p. Thus, x∈ P . Let y be the node of Hj closest to p in P . It is not difficult to see that y ∈ cw(H, r, p) and y ∈ cw(Hj, rj, x). Since (v, p) ∈ T , (v, x) ∈ H − T , and y ∈ cw(H, r, p), we know y = x. Otherwise,

x would have been a neighbor of v in H closer to r than p in cw(H, r, v), thereby

contradicting the choice of p in step 3. As y= x, x is not a leaf of Tj. By step 6(2),

x∈ cw(Hj, rj, vj). Let z = prev(Hj, x). By property 3 of Gj, node z has to be the largest-indexed child of x in Tj. Since x = rj and y ∈ cw(Hj, rj, x), we know that

y and z are on different sides of the path of Tj between rj and x in Hj, thereby contradicting the fact that z is the highest-indexed child of x in Tj.

We then show that x is orderly in H with respect to T . If |Ix| = 1, then the orderly pattern of x in Hwith respect to T follows immediately from that in Hjwith respect to Tj, which is ensured by property 5 of Gj. When|Ix| ≥ 2, by properties 5 of Gi for all i∈ Ix− {j}, each neighbor of x in



i∈Ix−{j}Hi is a child of x in T . It

follows from property 3 of Gj that all children of x in T are consecutive in H around

x. Since x is orderly in Hj with respect to Tj, one can see that x is orderly in H with respect to T .

Since v is a leaf of T , we know that v is orderly in H with respect to T . It remains to show that each neighbor x of v in H− H is orderly in H with respect to T . Let

z1 (respectively, z2) be the neighbor of x that precedes (respectively, succeeds) v in counterclockwise order around x. It suffices to show that if the index of x is lower (respectively, higher) than that of v, then z2 (respectively, z1) belongs to P (x) or

D(x) (respectively, P (x) or U<(x)) of H with respect to T as follows: If the index of x is lower than that of v, then z2= next(Hj, x) by property 2. By step 6, one can

verify that x belongs to cw(Hj, rj, vj). By property 3, we have that z2 belongs to either P (x) or D(x) of H with respect to T . If the index of x is higher than that of

v, then we know z1= prev(Hj, x) from property 2. By step 6, one can verify that x belongs to ccw(Hj, rj, vj). From property 3, we have that z1 belongs to either P (x) or U<(x) of H with respect to T .

(11)

plane graph G, then block(G, r, v) runs in O(n) time.

Proof. The execution of block(G, r, v) consists of a sequence of subroutine calls

to block. One can see that each node of G can be the parameter v for no more than two subroutine calls to block—one with G= (r, v) and the other with G = (r, v). If

G = (r, v), then the subroutine call block(G, r, v) runs in O(1) time. Let  be the

number of subroutine calls to block(G, r, v) with G= (r, v). For each j ∈ {1, 2, . . . , }, let block(Gj, rj, vj) be the jth subroutine call to block with Gj= (rj, vj) throughout the execution of block(G, r, v), where G1 = G, r1 = r and v1= v. Clearly, vj = vj holds for any two distinct indices j and j, thereby implying that  ≤ n. Let Ej consist of the edges of G belonging to the boundaries of the internal faces of Gj that contain vj. Let tj be the time required by block(Gj, rj, vj), without accounting for that required by its subsequent subroutine calls to block. Observe that tj = O(|Ej|) holds for each j. It is not difficult to implement the algorithm block such that the running time of block(G, r, v) is dominated byj=1tj =



j=1O(|Ej|). Since G has

O(n) edges, it suffices to show as follows that any edge (x, y) of G belongs to no more

than two of the sets E1, E2, . . . , E: Let j1be the smallest index j with (x, y)∈ Ej. If

vj1∈ {x, y}, then j

1is also the largest index j with (x, y)∈ Ej. It remains to consider the case vj1 ∈ {x, y}. Let j/

2be the smallest index j with j > j1and (x, y)∈ Ej. From the definition of block, edge (x, y) has to be on the outer boundary of Gj2, implying

vj2∈ {x, y}. Therefore, j

2 is the largest index j with (x, y)∈ Ej. Finally, we have the next theorem.

Theorem 2.3. It takes O(n) time to compute an orderly pair for an n-node

connected planar graph.

3. Realizers for plane triangulations. This section provides a new linear-time algorithm for computing a realizer for any n-node plane triangulation Δ. As defined by Schnyder [39, 38], (T1, T2, Tn) is a realizer of Δ if

• the internal edges of Δ are partitioned into three edge-disjoint trees T1, T2, and Tn, each rooted at a distinct external node of Δ; and

• the neighbors of each internal node v of Δ form six blocks U1, Dn, U2, D1,

Un, and D2in counterclockwise order around v, where for each j∈ {1, 2, n},

Uj (respectively, Dj) consists of the parent (respectively, children) of v in Tj. A realizer of the plane triangulation in Figure 1.1(a) is shown in Figure 1.1(c).

Lemma 3.1. Given an orderly spanning tree of Δ, a realizer of Δ is computable

in O(n) time.

Proof. Let T be the given orderly spanning tree of Δ rooted at v1. Let v1, . . . , vn be the counterclockwise preordering of T , where v1, v2, and vn are the external nodes of Δ in counterclockwise order. Note that (v1, v2) and (v1, vn) must be in T . Since Δ is a plane triangulation and the edges of Δ− T are unrelated with respect to T , both

U<(vi) and U>(vi) are nonempty for each 3≤ i ≤ n − 1. (To see this, one can verify that if U<(vi) or U>(vi) were empty, then the edge between vi and the parent of vi in T would belong to a face of Δ consisting of at least four edges, contradicting the assumption that Δ is a plane triangulation.) Let pi (respectively, qi) be the index of the last (respectively, first) node in U<(vi) (respectively, U>(vi)) in counterclockwise order around vi. Let T1 be obtained from T by deleting (v1, v2) and (v1, vn). Let

T2 = {(vi, vpi) | 3 ≤ i ≤ n − 1} and Tn = {(vi, vqi) | 3 ≤ i ≤ n − 1}. An example

is shown in Figure 1.1(c). Observe that pi < i < qi holds for each 3 ≤ i ≤ n − 1, implying that both T2 and Tn are acyclic. It can be proved as follows that exactly one of the equalities i = pj and j = qiholds for each edge (vi, vj)∈ Δ − T with i < j.

(12)

neighbor of vi immediately succeeding vj in clockwise order around

vi and (ii) the neighbor of vj immediately preceding vi in clockwise order around vj. Clearly, i < j < k implies i = pj and j = qi; and

k < i < j implies j = qi and i= pi. As for the remaining case that

i < j < k, one can verify that vi has to be the parent of vk in T , thereby implying j = qi and i= pj.

It follows that each internal edge of Δ belongs to exactly one of T1, T2, and Tn. By the definitions of pi and qi, one can verify that the neighbors of each internal node

vi of Δ indeed form the required pattern for (T1, T2, Tn) as a realizer of Δ. Since it takes O(n) time to determine all pi and qi, the lemma is proved.

Theorem 3.2 (see also [39, 38]). A realizer of any plane triangulation is derivable

in linear time.

Proof. The proof is straightforward by Theorem 2.3 and Lemma 3.1.

4. 2-visibility drawings for plane graphs. This section shows how to obtain in O(n) time an (n−1)×2n+13 2-visibility drawing for any n-node plane graph G. For calculating the area of a 2-visibility drawing, we follow the convention of [16], stating that the corner coordinates of each rectangle are integers, and that each rectangle is no smaller than 1× 1. For example, the area of the 2-visibility drawing shown in Figure 1.1(b) is 9× 8. Let Δ be a plane triangulation obtained by triangulating G. Since any 2-visibility drawing of Δ is also a 2-visibility drawing of G, the rest of the section assumes that the input is the plane triangulation Δ.

Let T be an orderly spanning tree of Δ. Let v1, v2, . . . , vnbe the counterclockwise preordering of the nodes in T . Our algorithm draw(Δ, T ) consists of n iterations, where the ith iteration performs the following steps:

Step 1. If i = 1 and vi is not the first child of its parent in T , then lengthen each ancestor of vi in T to the right by one unit.

Step 2. Draw vi as a unit square beneath the parent of vi in T such that vi and all ancestors of vi in T align along the right boundary. Now, vi is vertically visible to its parent in T .

Step 3. Lengthen downward viand each neighbor vjof viin Δ with j < i, if necessary, so that vi and vj are horizontally visible to each other.

If Δ and T are as shown in Figure 4.1(a), then the intermediate (respectively, re-sulting) drawing obtained by draw(Δ, T ) is shown in Figure 4.1 (respectively, Fig-ure 4.1(b)).

Lemma 4.1. The algorithm draw(Δ, T ) obtains an h× w 2-visibility drawing of Δ with h≤ n − 1 and such that w equals the number of leaves in T .

Proof. Since T is a spanning tree of Δ, draw(Δ, T ) is well defined. Also, the

output of draw(Δ, T ) is indeed a 2-visibility drawing of Δ with width equal to the number of leaves in T . The rest of the proof shows that the height of the output of draw(Δ, T ) is at most n− 1. For any two distinct edges e and e in Δ− T , we say that e encloses e if e is in the interior of the cycle consisting of e and the path of

T between the endpoints of e. By the planarity of Δ, the above “enclosing” relation

defines a nesting structure among the edges of Δ− T . Let (e) denote the “level” of edge e in the nesting structure:

If e does not enclose any other edge in Δ− T , then let (e) = 1; otherwise, let (e) be one plus the maximum of (e) over all the edges e in Δ− T that are enclosed by e.

(13)

(b) 2 1 7 2 4 3 5 6 4 3 5 2 4 3 5 6 1 4 3 6 9 1 7 8 2 5 4 3 5 6 9 2 1 7 8 4 3 5 6 7 8 11 10 9 2 1 1 1 2 1 (8) (9) (10) (11) (1) (2) (3) (5) (6) (7) 10 1 2 4 3 5 6 7 8 11 10 9 12 (4) 7 8 2 4 3 5 6 1 2 1 1 3 2 3 4 8 5 4 2 3 6 7 1 10 11 12 (a) 9

Fig. 4.1. An illustration of the intermediate steps of draw(Δ, T ), where Δ and T are as shown

in (a) and the final drawing is as shown in (b).

representing nodes u and v without intersecting other rectangles or line segments, then 1 + (e) is the minimum possible (vertical) distance between the line segment representing e and the rectangle representing the lowest common ancestor of u and v in T . Let edge ˆe be (v2, vn), which encloses all the other edges in Δ− T . The height of the output of draw(Δ, T ) is exactly 1 + (ˆe). It remains to show (ˆe)≤ n − 2 as

follows: Assume for the sake of contradiction that e1, e2, . . . , en−1 is a sequence of edges in Δ− T such that eiencloses e1, e2, . . . , ei−1 for each i∈ {2, 3, . . . , n − 1}. For each i ∈ {1, 2, . . . , n − 1}, let Xi consist of the endpoints of ei, ei+1, . . . , en−1. For each i∈ {1, 2, . . . , n − 2}, there must be an endpoint of eithat is not in Xi+1. (To see this, assume for the sake of contradiction that j and k with i < j < k≤ n − 1 are two indices such that ej and ek are incident to the endpoints u and v of ei, respectively. Let C be the cycle consisting of ej and the path of T that connects the endpoints of

ej. Since ei is in the interior of C and ek is outside of C, the assumption that ek is incident to v violates the orderly property of v.) Therefore, X1 contains at least n distinct nodes. Since T is an orderly spanning tree of Δ, v1 is not incident to any edges of Δ− T . Therefore, v1∈ X/ 1, which contradicts that Δ has n nodes.

(14)

3

Proof. Let v1, v2, and vn be the external nodes of Δ in counterclockwise order around the outer boundary of Δ. By Theorem 3.2, a realizer (T1, T2, Tn) of Δ, where each Ti is rooted at vi, can be obtained in O(n) time. Let I ={1, 2, n}. For each

i ∈ I, let Ti = Ti∪ {(vi, vi1), (vi, vi2)}, where {i1, i2} = I − {i}. Observe that T1,

T2, and Tn are three spanning trees of Δ with T1∪ T2∪ Tn = Δ. We first show that each Ti is an orderly spanning tree of Δ. Since the relation between T1, T2, and Tn is rotationally symmetric, it suffices to verify that each node is orderly with respect to T1. Let v1, v2, . . . , vn be the counterclockwise preordering of T1. For each i ∈ I and j ∈ {1, 2, . . . , n}, let Qi,j be the path of Ti between vi and vj. Note that Q1,j,

Q2,j, and Qn,j are three edge-disjoint paths of Δ that intersect only at vj. If vj is not a leaf of T1, then the children of vj in T1are consecutive in Δ in counterclockwise order around vj. Therefore, to ensure that each node is orderly with respect to T1, it suffices to prove that each edge of Δ− T1is unrelated with respect to T1: If vj were an ancestor of vj, that is, also a neighbor of vj in Δ− T1, then vj and vj would be on different sides of Q2,j∪ Qn,j in Δ, where vj is the parent of vj in T1, thereby

contradicting the planarity of Δ.

It remains to show that T1, T2, or Tn has at most 2n+13 leaves. For each i∈ I, let leaf(Ti) consist of the leaves of Ti. Since the number of leaves in Ti is precisely 2 +|leaf(Ti)|, it suffices to show thati∈I|leaf(Ti)| ≤ 2n − 5. Let v be a node in leaf(Ti). Observe that v is internal in Δ. For each i∈ I, let pi(v) denote the parent of v in Ti. Let i1 and i2 be the indices in I− {i}. Since (T1, T2, Tn) is a realizer of Δ, there is a unique internal face Fi(v) of Δ containing v, pi1(v), and pi2(v). We have that pi1(v) /∈ leaf(Ti1) and pi2(v) /∈ leaf(Ti2). It follows that Fi(v)= Fi1(u1) for any

node u1 in leaf(Ti1) and that Fi(v)= Fi2(u2) for any node u2 in leaf(Ti2). Therefore,



i∈I|leaf(Ti)| is no more than the number of internal faces of Δ, which is precisely 2n− 5 by Euler’s formula.

Theorem 4.3. An (n− 1) ×2n+1 3



2-visibility drawing of any n-node planar

graph is computable in O(n) time.

Proof. A naive implementation of algorithm draw runs in O(n2) time, since one stretching of a node’s rectangle affects the horizontal spans of all its descendants. However, it is not difficult to implement the algorithm to run in O(n) time. The width of the rectangle representing a node v is exactly the number of leaves in the subtree of T rooted at v. Therefore, one can easily calculate the x-coordinates of all rectangles in linear time. Also, the y-coordinates of all rectangles can be computed in linear time via the values (e) for all edges e in G− T . (See, e.g., Figure 3.2 of [32] for related implementation techniques.) Therefore, the theorem follows from Lemmas 4.1 and 4.2.

5. Convenient encodings for planar graphs. This section gives the best known convenient encoding for an n-node m-edge planar graph as an application of our orderly pair algorithm. We need some notation to describe the data structures required by our convenient encodings. Let |S| denote the length of a string S, i.e., the number of symbols in S. Unless clearly stated otherwise, all strings in this section have length O(m + n). A string S consisting of t distinct symbols can be encoded in |S|log2t bits. For example, if S consists of parentheses and brackets, including

open and closed ones, then S can be encoded in 2|S| bits. S is binary if it consists of two distinct symbols. For each 1≤ i ≤ j ≤ |S|, let S[i, j] be the length-(j − i + 1) substring of S from the ith position to the jth position. If i > j, then let S[i, j] be the empty string. Define S[i] = S[i, i]. S[k] is enclosed by S[i] and S[j] in S if i < k < j.

(15)

Let select(S, i,2) be the position of the ith 2 in S. Let rank(S, k, 2) be the number of2’s before or at the kth position of S. If k = select(S, i, 2), then i = rank(S, k, 2). An auxiliary string χ of S is a binary string with|χ| = o(|S|) which is obtainable from S in O(|S|) time.

Fact 5.1 (see [1, 15]). For any strings S1, S2, . . . , Sk with k = O(1), there is an

auxiliary string χ0 such that, given the concatenation of χ0, S1, S2, . . . , Sk as input,

the index of the first symbol of any given Si in the concatenation is computable in

O(1) time.

Let S1◦ S2◦ · · · ◦ Sk denote the concatenation of χ0, S1, S2, . . . , Sk as in Fact 5.1. Suppose that S is a string of multiple types of parentheses. Let reverse(S) be the string R such that R[i] is the opposite parenthesis of the same type as S[|S|+1−i]. For example, reverse(“)()])[”) = “]([()(.” For an open parenthesis S[i] and a closed one S[j] of the same type with i < j, the two match in S if every parenthesis of the same type that is enclosed by them matches one enclosed by them. S is balanced in

type k if every parenthesis of type k in S belongs to a matching parenthesis pair. S is balanced if S is empty or is balanced in all types of parentheses. Here are some queries

defined for a balanced string S. Let match(S, i) be the position of the parenthesis in

S that matches S[i]. Let enclosek(S, i1, i2) be the position pair (j1, j2) of the closest matching parenthesis pair of the kth type that encloses S[i1] and S[i2].

Fact 5.2 (see [35, 9]). For any balanced string S of O(1) types of

parenthe-ses, there is an auxiliary string χ1(S) such that each of rankS, i,2, select(S, i, 2),

match(S, i), and enclosek(S, i, j) can be determined from S◦ χ1(S) in O(1) time. For a string S of parentheses that may be unbalanced, we define wrapped(S, i) as follows. For the case that S[i] is an open parenthesis of type k, let S be a string obtained from S by appending some closed parentheses of type k, if necessary, such that S[i] is matched in S. Define wrapped(S, i) to be the number of indices j satisfy-ing i < j≤ |S|, enclosek(S, j, match(S, j)) = (i, match(S, i)), and S[j] is of type k.

For the case that S[i] is closed, let wrapped(S, i) = wrapped(reverse(S),|S| + 1 − i). Therefore, if

S = (()[[[[[(](])[(]])[[)[[(])[[[(](](]]])[(]]])[[(])[)[)[(]]]]])),

(5.1)

122...3.4.4.5..5..3..6.6...7.8.9...9.A...A..B.B.8.7.C...C1

then we have wrapped(S, 1) = 10 and wrapped(S, 6) = 4. If S is balanced, then wrapped(S, i) is an even number for each i, i.e., twice the number of parenthesis pairs that are enclosed by the parenthesis pair in question. The next lemma extends the set of queries supported in Fact 5.2.

Lemma 5.3. For any balanced string S of O(1) types of parentheses, there is an

auxiliary string χ2(S) such that wrapped(S, i) can be computed from S◦χ2(S) in O(1)

time.

Proof. Define width(i, j) =|i − j| + 1. We say that parentheses of the same type

with property π are d-disjoint if

• width(i, match(S, i)) > d holds for any parenthesis S[i] with property π; and • any two property-π parentheses S[i] and S[j] with S[i] = S[j] satisfy at least

one of width(i, j) > d and width(match(S, i), match(S, j)) > d.

Intuitively, d-disjoint parentheses have to be sparse: Suppose that parentheses with property π are d-disjoint. Then, for any property-π open parenthesis S[i], either

S[i] is the only property-π open parenthesis in S[i− d + 1, i] or S[match(S, i)] is the

only property-π closed parenthesis in S[match(S, i), match(S, i) + d− 1]. As a result, suppose that we partition S into segments of length d. For each segment, let us mark (a) the property-π open parenthesis with the smallest index in the segment and

(16)

for each parenthesis S[i] with property π, at least one of S[i] and S[match(S, i)] is marked. Therefore, there are only O(s/d) parentheses with property π.

Let s =|S|. For a carefully chosen number  = Θ(log s), we say that

• parenthesis S[i] is narrow if width(i, match(S, i)) ≤ ; • parenthesis S[i] is wide if wrapped(S, i) > 22; and

• parenthesis S[i] is medium if it is neither narrow nor wide.

We apply the commonly used preprocessing technique (see, e.g., [10, 35]) in the unit-cost RAM model which allows the query wrapped(S, i) for any narrow S[i] to be answered in O(1) time from the linear-time precomputable o(s)-bit table (i.e., the table M1◦ M2 to be described later). It is not difficult to see that wide parentheses are 2-disjoint. Therefore, we can afford to encode (i, wrapped(S, i)) for all wide parentheses S[i] using o(s) bits. Although medium parentheses are not necessarily

-disjoint, we identify special parentheses, which are medium parentheses that have

to be -disjoint, and encode (i, wrapped(S, i)) for all special medium parentheses S[i] using o(s) bits. As for medium parentheses that are not special, we will show that two queries to the o(s)-bit precomputed table suffice. The details are as follows.

Let t be the number of distinct types of parentheses in S. Let b be the smallest integer with 2t≤ 2b. Each symbol of S can be encoded in b bits. As t = O(1), we have b = O(1). Let  =1

2log2bs



. Any substring S[i, j] with j ≤ i +  − 1 has O(√s)

possible distinct values. Define tables M1and M2for S by letting M1[S[i, i + −1]] = wrapped(S[i, i + − 1], 1) and M2[S[i, j]] = wrapped(reverse(S[i, j]), 1) for any i, j with 1≤ i ≤ j ≤ i +  − 1. One can easily come up with an o(s)-bit string χ2 from which each entry of M1 and M2 can be obtained in O(1) time.

For each k ∈ {1, 2, . . . , t}, define tables Mk

3 and M4k as follows. For each i = 1, 2, . . . ,s

2

,

• let Mk

3[i] = (j, wrapped(S, j)), where index j is the smallest index, if any, with (i− 1)2 < j≤ i2 such that S[j] is a wide open parenthesis of type k; and

• let Mk

4[i] = (j, wrapped(S, j)), where index j is the largest index, if any, with (i− 1)2< j≤ i2such that S[j] is a wide close parenthesis of type k. Since each entry of M3kand M4kcan be encoded in O(log s) bits, one can easily obtain an o(s)-bit string χ2 from which each entry of M3k and M4k can be determined in O(1) time.

A medium open parenthesis S[i] is special if at least one of the inequalities width(i, j) >  and width(match(S, i), match(S, j)) >  holds for each index j with i <

j < match(S, i) and S[j] = S[i]. A closed parenthesis S[i] is special if S[match(S, i)]

is special. One can verify that special parentheses are -disjoint. For each k

{1, 2, . . . , t}, define tables Mk 5 and M

k

6 as follows. For each i∈ {1, 2, . . . , s



}, • let Mk

5[i] = (j, wrapped(S, j)), where j is the smallest index, if any, with (i− 1) < j ≤ i such that S[j] is a special open parenthesis of type k; and

• let Mk

6[i] = (j, wrapped(S, j)), where j is the largest index, if any, with (i− 1) < j ≤ i such that S[j] is a special close parenthesis of type k. Observe that Mk

5[i] = (j, c) or M6k[i] = (j, c) implies 0≤ i − j ≤  and 0 ≤ c ≤ 22. Therefore, each entry of Mk

5 and M6k can be encoded in O(log ) = O(log log s) bits. As a result, one can easily come up with an o(s)-bit string χ2 from which each entry of Mk

5 and M6k can be determined in O(1) time. Let χ2(S) = χ2◦ χ2 ◦ χ2. The

o(s)-bit string χ2(S) can be derived from S in O(s) time.

(17)

function wrapped(S, i){

Step 1. let k, with 1≤ k ≤ t, be the type of S[i]; Step 2. let i1= min{i, match(S, i)};

Step 3. let i2= match(S, i1);

Step 4. let (j, c) = Mk 3



i1/2 

; if j = i1, then return c;

Step 5. let (j, c) = Mk 4



i2/2 

; if j = i2, then return c;

Step 6. let (j, c) = Mk

5 [i1/]; if j = i1, then return c;

Step 7. let (j, c) = M6k[i2/]; if j = i2, then return c;

Step 8. if width(i1, i2)≤ , then return M1[S[i1, i2]];

Step 9. if width(i1, i2)≤ 2, then return M1[S[i1, i1+ − 1]] + M2[S[i1+ , i2]];

Step 10. return M1[S[i1, i1+ − 1]] + M2[S[i2−  + 1, i2]];

}

Fig. 5.1. An O(1)-time algorithm that computes wrapped(S,i).

the algorithm shown in Figure 5.1, which clearly runs in O(1) time. If a value c is returned from steps 4–9, we have c = wrapped(S, i). The rest of the proof assumes that step 10 is executed. Since wide parentheses are 2-disjoint and special parentheses are -disjoint, parentheses S[i1] and S[i2] at step 10 satisfy width(i1, i2) > 2 and form a matching pair of medium parentheses that are not special. By definition of special parentheses, there are indices j1 and j2 with i1 < j1 < j2 = match(S, j1) < i2 and

S[i1] = S[j1] (thus S[j2] = S[i2]) such that width(i1, j1)≤  and width(j2, i2) ≤ . Since width(i1, i2) > 2, we have wrapped(S, i1) = M1[S[i1, i1+ − 1]] + M2[S[i2

 + 1, i2]]. Therefore, step 10 correctly returns wrapped(S, i).

A folklore encoding [22, 35, 9] S of an n-node simple rooted tree T is a balanced string of 2n parentheses representing a counterclockwise depth-first traversal of T . Initially, an open (respectively, closed) parenthesis denotes a descending (respectively, ascending) edge traversal. Then, this string is enclosed by an additional matching parenthesis pair. For example, the string in (5.2) is the folklore encoding for the tree

T in Figure 1.1(a). Let vibe the ith node in the counterclockwise depth-first traversal. Let (i be the ith open parenthesis in S. Let )i be the closed parenthesis of S that matches (iin S. Node vicorresponds to (i and )iin that viis the parent of vj in T if and only if (iand )iform the closest pair of matching parentheses that encloses (jand )j. Also, the number of children of vi in T is precisely wrapped(S, select(S, i, ())/2, which is also equal to wrapped(S, match(S, select(S, i, ()))/2.

Let H be an n-node connected plane graph that may have multiple edges but no self-loops. Let T be a spanning tree of H rooted at v1. Let v1v2· · · vn be the counterclockwise preordering of T . Let degree(i) be the number of edges incident to vi in H. Let children(i) be the number of children of vi in T . Let above(i) (respectively, below(i)) be the number of edges (vi, vj) of H such that vjis the parent (respectively, a child) of vi in T . Let low(i) (respectively, high(i)) be the number of edges (vi, vj) of H such that j < i (respectively, j > i) and vj is neither the parent nor a child of viin T . Now, degree(i) = above(i) + below(i) + low(i) + high(i). If H has no multiple edges, then below(i) = children(i). If H and T are as shown in Figure 1.1(a), for instance, then above(3) = 1, below(3) = children(3) = 2, low(3) = 1, high(3) = 2, and degree(3) = 6.

The T -code of H is a triple (S1, S2, S3) of the binary strings S1, S2, S3, where δi≥2 equals 1 if i≥ 2 and 0 otherwise.

(18)

in which low(i) copies of 0 immediately succeed the pith 1, and high(i) copies of 0 immediately succeed the qith 1.

• S3 has exactly n copies of 1, where above(i) + below(i)− children(i) − δi≥2 copies of 0 immediately succeed the ith 1.

For example, if H and T are as shown in Figure 1.1(a), then

S1= (()(()())()((()()()))()); (5.2) S2= 11100000101010100100100101000101010001010001001010101010000011; S3= 111111111111. We have that |S1| = 2n; |S2| = 2n + n i=1 (low(i) + high(i)) ; |S3| = 1 + n i=1

(above(i) + below(i)− children(i)) .

Therefore, |S1| + |S2| + |S3| = 2m + 3n + 2. Moreover, if H has no multiple edges, then|S3| = n, and thus |S1| + |S2| = 2m + 2n + 2.

The next theorem describes our convenient encoding. The techniques in the proof are mostly adapted from [9]. (Their encoding needs initial augmentation to the input graph to ensure that the resulting graph admits a canonical spanning tree. As a result, their encoding requires an additional number of bits to tell which edges are original.) Theorem 5.4. Let G be an input n-node m-edge planar graph having no

self-loops. If G has (respectively, has no) multiple edges, then G has a convenient encoding, obtainable in O(m + n) time, with 2m + 3n + o(m + n) (respectively, 2m + 2n + o(n)) bits.

Proof. We focus on the case that G is connected. As sketched at the end of the

proof, it is not difficult to remove this restriction. By Theorem 2.3, an orderly pair (H, T ) of G can be derived in O(m + n) time. Let (S1, S2, S3) be the T -code of H. We prove that there exists an o(m + n)-bit string χ, obtainable in O(m + n) time, such that S1◦ S2◦ S3◦ χ is a convenient encoding of G. If G has no multiple edges, then S3 consists of n copies of 1, and thus S1◦ S2◦ χ will suffice.

To support degree queries, let pi = select(S1, i, () and qi = match(S1, pi). Since

S[pi] and S[qi] are a matching parenthesis pair, we have that low(i) = select(S2, pi+ 1, 1)− select(S2, pi, 1)− 1, high(i) = select(S2, qi+ 1, 1)− select(S2, qi, 1)− 1.

Observe that children(i) = wrapped(S1, pi)/2. From the definition of S3, we know above(i) + below(i)− children(i) = select(S3, i + 1, 1)− select(S3, i, 1)− 1 + δi≥2. Let

χ = χ1(S1)◦χ1(S2)◦χ1(S3)◦χ2(S1). From degree(i) = above(i)+below(i)+low(i)+ high(i), Fact 5.2, and Lemma 5.3, we determine that degree(i) is computable from

S1◦ S2◦ S3◦ χ in O(1) time.

To support adjacency queries and listing of all neighbors, we introduce a string

S of two types of parentheses derived from S1 and S2 as follows. Although S is only implicitly represented in our convenient encoding, any O(log n) consecutive parenthe-ses of S can be obtained from S1, S2, and some auxiliary string in O(1) time. Let (

(19)

and ) be of type 1, and let [ and ] be of type 2. Initially, for each i = 1, 2, . . . , 2n, replace the ith 1 of S2 with S1[i]. Then, replace each 0 of S2with a bracket such that the bracket is open if and only if the last parenthesis in S preceding this 0 is closed. More precisely, for each i = 1, 2, . . . ,|S2|, let

S[i] =

⎧ ⎨ ⎩

S1[j1] if S2[i] = 1,

] if S2[i] = 0 and S1[ji] = (, [ if S2[i] = 0 and S1[ji] = ),

where ji= rank(S2, i, 1). For example, if H and T are as given in Figure 1.1(a), then S is as in (5.1). There exists an auxiliary string χ3such that any O(log n) consecutive symbols of S are obtainable from S1◦S2◦χ3in O(1) time: Let  =

1 8log2n



. Observe that the content of S[i, i + − 1] can be uniquely determined from the concatenation

S of S2[i, i + − 1] and S1[j, j + − 1] with j = rank(S2, i, 1). Also, S is obtainable from S1◦S2◦χ1(S2) in O(1) time. Since Shas 4distinct values, we can precompute in O(n) time an o(n)-bit table M such that the content of S[i, i + − 1] is obtainable from S and M in O(1) time. Hence, it suffices to let χ3= M◦ χ1(S2).

With the help of S and its auxiliary strings, adjacency queries can be supported as follows. For any two integers a and b, let [a, b] consist of the integers a, a + 1, . . . , b. For each i∈ {1, 2, . . . , n}, let

Li= [i+ 1, select(S2, rank(S2, i, 1) + 1, 1)− 1],

Ri= [hi+ 1, select(S2, rank(S2, hi, 1) + 1, 1)− 1],

where i= select(S, i, () and hi = match(S, i). Let (vi, vj) and (vi, vj), with i < j and i < j, be two unrelated edges of H with respect to T . Since T is an orderly spanning tree of H, one can see that if (vi, vj) is enclosed by the cycle of H determined by T and (vi, vj), then hi < hi < j < j. One can prove that

vi and vj, with i < j, are adjacent in H−T if and only if there exists an index ∈ Ri with match(S, )∈ Lj

by the following induction on the number b of matching bracket pairs in S: The above statement clearly holds when b = 0. To show the induction step for any b≥ 1, let e = (vx, vy) be an edge in H− T . We know that T is also an orderly spanning tree of H− {e}. Let ˆS, ˆRi, and

ˆ

Li be the corresponding notation for H − {e} with respect to T . Observe that ˆS can be obtained from S by deleting an open bracket

in a position in Rx and deleting a closed bracket in a position in

Ly. Since vx and vy are not adjacent in H− {e}, it follows from the inductive hypothesis that match( ˆS, ) /∈ ˆLy holds for any index  in

ˆ

Rx; and match( ˆS, ) /∈ ˆRx holds for any index  in ˆLy. Therefore, there is a position in ˆRxand a position in ˆLysuch that if we insert an open bracket in the first position and a closed bracket in the second position, then the brackets will match each other in the resulting string, which is exactly S. Thus, the above statement is proved.

Thus, one can determine whether (vi, vj) is an unrelated edge of H with respect to

T , by checking whether i∈ Ri and j∈ Lj hold, where

(i, j) = enclose2(S, select(S, rank(S2, hi, 1) + 1, (), j).

Therefore, the answer to each adjacency query is derivable from S2◦S ◦χ1(S2)◦χ1(S) in O(1) time.

(20)

vi is not the root of T , then the parent of vi is vj, where j is computable by letting (j1, j2) = enclose(S, select(S, i, (), match(S, select(S, i, ()));

j = rank(S, j1, ().

If vi is not a leaf of T , then vi+1 is the first child of vi in T . If vj is the tth child of

vi in T , then the (t + 1)st child of vi in T is vk, where

k = rank(S, 1 + match(S, select(S, j, ()), ().

If t ≤ |U<(vi)|, the tth neighbor of vi in U<(v) with respect to T is vj, where j is computable by

j1= match(S, t + select(S, i, ());

j2= select(S, rank(S, j1, )), ));

j = rank(S, match(S, j2), ().

If t≤ |D(vi)|, then the tth neighbor of vi in D(v) with respect to T is vj, where j is computable by j1= match(S, select(S, i, ()) and j = rank(S, match(S, j1+ t), ().

It is not difficult to verify that G can be reconstructed from S and S3in O(m +

n) time. Therefore, the theorem for connected planar graphs is proved by letting χ = χ◦ χ3◦ χ1(S). As for the case that G has k ≥ 2 connected components, by Theorem 2.3, an orderly pair (Hi, Ti) of the ith connected component Gi of G can be derived in overall O(m + n) time. Let (Si

1, S2i, S3i) be the Ti-code of Hi. For each

j = 1, 2, 3, let Sj be the concatenation of Sj1, Sj2, . . . , Sjk. The theorem can then be proved similarly using S1, S2, and S3.

Acknowledgments. We are grateful to the anonymous reviewers for their help-ful suggestions which significantly improved the paper. We thank Xin He for helphelp-ful comments. We thank Hsu-Chun Yen and Ho-Lin Chen for bringing [16] to our atten-tion. We also thank Richie Chih-Nan Chuang, Yuan-Jiunn Wang, and Kai-Ju Liu for discussions.

REFERENCES

[1] T. C. Bell, J. G. Cleary, and I. H. Witten, Text Compression, Prentice–Hall, Englewood Cliffs, NJ, 1990.

[2] N. Bonichon, C. Gavoille, and N. Hanusse, An information-theoretic upper bound of planar

graphs using triangulation, in Proceedings of the 20th Annual Symposium on Theoretical

Aspects of Computer Science, Lecture Notes in Comput. Sci. 2607, Springer-Verlag, Berlin, 2003, pp. 499–510.

[3] P. Bose, A. M. Dean, and J. P. Hutchinson, On rectangle visibility graphs, in Proceedings of the 4th International Symposium on Graph Drawing, Lecture Notes in Comput. Sci. 1190, Springer-Verlag, Berlin, 1996, pp. 25–44.

[4] J. Boyer and W. Myrvold, Stop minding your p’s and q’s: A simplified O(n) planar

em-bedding algorithm, in Proceedings of the 10th Annual ACM-SIAM Symposium on Discrete

Algorithms, ACM, New York, SIAM, Philadelphia, 1999, pp. 140–146.

[5] A. Brodnik and J. I. Munro, Membership in constant time and almost-minimum space, SIAM J. Comput., 28 (1999), pp. 1627–1640.

[6] H.-L. Chen, C.-C. Liao, H.-I. Lu, and H.-C. Yen, Some applications of orderly spanning trees

in graph drawing, in Proceedings of the 10th International Symposium on Graph Drawing,

Lecture Notes in Comput. Sci. 2528, Springer-Verlag, Berlin, 2002, pp. 332–343.

[7] M. Chrobak and S.-I. Nakano, Minimum-width grid drawings of plane graphs, Comput. Geom., 11 (1998), pp. 29–54.

數據

Fig. 1.1 . (a) A plane graph H with an orderly spanning tree of H rooted at node 1 represented by the thick edges
Fig. 2.1 . (a) The tree rooted at node 1, consisting of the thick edges, is not an orderly spanning tree of the plane graph
Fig. 2.2 . (a) A plane graph H that has no orderly spanning trees. (b) A different planar embedding of H that admits an orderly spanning tree rooted at node 1, consisting of the thick edges.
Fig. 2.3 . Illustration of the definitions of prev(H, v), next(H, v), cw(H, r, v), and ccw(H, r, v).
+3

參考文獻

相關文件

Primal-dual approach for the mixed domination problem in trees Although we have presented Algorithm 3 for finding a minimum mixed dominating set in a tree, it is still desire to

In particular, we present a linear-time algorithm for the k-tuple total domination problem for graphs in which each block is a clique, a cycle or a complete bipartite graph,

Wang, Unique continuation for the elasticity sys- tem and a counterexample for second order elliptic systems, Harmonic Analysis, Partial Differential Equations, Complex Analysis,

This paper presents (i) a review of item selection algorithms from Robbins–Monro to Fred Lord; (ii) the establishment of a large sample foundation for Fred Lord’s maximum

For the proposed algorithm, we establish a global convergence estimate in terms of the objective value, and moreover present a dual application to the standard SCLP, which leads to

For the proposed algorithm, we establish its convergence properties, and also present a dual application to the SCLP, leading to an exponential multiplier method which is shown

Given an undirected graph with nonnegative edge lengths and nonnegative vertex weights, the routing requirement of a pair of vertices is assumed to be the product of their weights.

Given a graph and a set of p sources, the problem of finding the minimum routing cost spanning tree (MRCT) is NP-hard for any constant p &gt; 1 [9].. When p = 1, i.e., there is only