Labeling weighted points with bounded sliding labels

0 downloads 0 Views 136KB Size Report
Oct 16, 2008 - points in a given set of weighted points with arbitrary sliding labels .... A1 is the set of labels l that corel = pl, i.e. size of A1 will be the same as the number .... will become pivot more than 2 times (at most once in each direction) ...
Labeling weighted points with bounded sliding labels Mohammad Ghodsi∗

Sorush Hosseini†

Vahid Liaghat†

Navid Zolghadr†

October 16, 2008

Abstract This paper presents a polynomial-time approximation algorithm for labeling some of the points in a given set of weighted points with arbitrary sliding labels of bounded height and width to maximize the weight of the labeled points. We generate a finite set of labels which contains a labeling with weight of 1 −  times of the optimum labeling, for arbitrary fixed  > 0, then we use this set as the input for the fixed position problem. Two results are established by this approach in 4-slider: the algorithm has an approximation factor of lg n when labels are bounded in height and width. If the height of every label is a constant, the approximation factor becomes 1 + . As a side result, we extend our work to general labeling when points can be inside the labels.

1

Introduction

Labeling a point set is a classical problem in the geographic information systems, where the points represent cities on a map which need to be labeled with city names. The problem of labeling points with arbitrarily oriented sliding labels is a generalization that is of interest in the case of graphical. This problems have a variety of practical applications as mentioned in the ACM Computational Geometry Impact Task Force report [Cha96]. An extensive bibliography about label placement can be found at [Wol07]. This paper is organized as follows. Section 2 defines the problem and summarizes the previous work on Map labeling problem. In section 3 we describe an approximation algorithm similar to the one in [TE08] for labeling points with rectangular labels. In section 4 we prove the correctness of the algorithm described in section 3, and in section 5 we describe a similar algorithm for rectangular region labeling with the same approximation factors.

2

Problem definition & previous work

Map labeling is the problem of placing a set of labels next to a given set of points in the plane while meeting certain conditions. Most often, the label associated with a point is of a specified rectangular shape and must be placed in the plane without rotation so that its boundary touches the point. Placed labels must not intersect. In some realistic instances, labels are restricted in width and height. Fixed-position models and slider models are two major classes of point labeling problem: In fixed-position models, for every point, there is a finite set of possible labels which each ∗

Department of Computer Engineering, Sharif University of Technology, [email protected] Department of Computer Engineering, Sharif University of Technology, hosseini,liaghat,zolghadr}@ce.sharif.edu †

{s

member of this set must contain the relevant point. It can be easily seen that an independent set of the labels, construct an acceptable labeling in these models. Slider models allow the labeled point to touch the label anywhere along a certain segment of the labels boundary. 4-Slider model allows the labeled point to touch the label anywhere along any of the label segments and 1SH model allows the labeled point to touch the label on the lower segment. Poon et al[SHP03] introduce a hierarchy of fixed-position and slider models. The problem is defined as follows. Let P be a set of n points in the Euclidian plane 0 where ma < a < Ma and width b ∈ < > 0 where mb < b < Mb (WLOG mb = ma = 1). We define M as the maximum of r Ma /ma and Mb /mb . Each point p ∈ P has a weight wp ∈ < > 0. An instance of this problem is given by the tuple I = (P, A, B, W ) c where ap ∈ A, bp ∈ B and wp ∈ W define the height, width and a p weight of any label of the point p ∈ P . A labeling of I is a family L = (cp , rp )p∈Q , indexed by the elements of Q ⊂ P , where cp ∈ [0, ap ] b and rp ∈ [0, bp ] places `p in the plane with its right edge at the xcoordinate px + rp and its upper edge at the y-coordinate py + cp (see Figure 1: A label Fig 1). For any two points p, q ∈ Q, the values of rp , cp , rq and cq must be such that `p and `q do not overlap. Points in Q are said to be labeled. Throughout this paper, such a labeling is called a general labeling. In 4S-labeling problem, we ought to place labels in a fashion that every label contains it’s corresponding point on the boundary. We define w(L) = Σp∈Qwp to be the weight of the labeling L = (cp , rp )p∈Q . A labeling of I is optimal if no labeling of I has a larger weight. We denote the optimal labeling of I by OPT. In fixed-position model, where the problem is to find a set of non-overlapping rectangles, [PKA98] introduces two approaches which we will use throughout this paper: 1. In general they give an independent set of lg n-approximation which works in O(n lg n) time. 2. When rectangles have equal height, they introduce a (1+1/t)-approximation algorithm which runs in O(n(2t−1) ). The running time of these cases will be showed by f (n) or ft (n), and the approximation factor will be showed by F or Ft . In slider model, Poon et al.[SHP03] showed that finding an optimal 1SH-labeling is NP-hard even if all points lie on a horizontal line and the weight of each point equals the width of its label. For the one-dimensional case, they give a fully polynomial-time approximation scheme, which yields an O(n2 /)-time (2 + )-approximation for the two-dimensional case. They also showed a 4 ratio between 1SH and 4S problems. They gave a polynomial-time approximation scheme (PTAS) for unit-square labels in 1SH-labeling which we will extend for 4S-labeling. Generalizations of point labeling was investigated as well in [SD97] and [BZ02]. It is not known if there exists a PTAS for rectangular labels of arbitrary width and unit height in 1SH-labeling. This is known to be the case for fixed-position models [PKA98] and for sliding labels with unit weight [MJvK99]. They also give a (3 + )dlg ne factor approximation for height bounded labels, which in this paper, the factor will be reduced to (1 + )dlg ne in cases that width is bounded too. Erlebach et al.[TE08] presented an algorithm for the problem of labeling points with arbitrary width and unit height with a 3/2 +  factor. They also gave a PTAS for 1SH in case of unit height and bounded width. In this paper, we extended the work in [TE08] and with a similar approach, we present a new approximation algorithm for 4S-labeling when maximum to minimum ratio of height and width of 2

labels is bounded by constants. If labels are unit height, our algorithm is a PTAS. We also extend all the results for general labeling, having the same approximation factors and losing running time.

3

Definitions and the algorithm

To simplify the following explanations, we consider the axis-center at the bottom-left corner of plane i.e we denote left as the direction with lower x-axis, right as the direction with higher x-axis, down as the direction with lower y-axis and finally up as the direction with higher y-axis. We also called the top-right corner of a label `, as core` . We will borrow some of notations from [TE08] but with different definitions in some cases, which we will see later. To explain the idea behind our algorithm, we need three definitions: Definition 1 The labeling-graph of a labeling L, GL , is a directed graph with a vertex for each label. For each pair of labels `1 , `2 ∈ L, we draw an edge from `1 to `2 , if one of these conditions holds: • if we move `1 left by any  > 0 (i.e. decrease r`1 ), `1 and `2 will have intersection. • if we move `1 down by any  > 0 (i.e. decrease c`1 ), `1 and `2 will have intersection. We also call the longest path in a labeling graph as its diameter. Definition 2 We call the label ` a normal label if 1. core` = p` OR 2. if we decrease x-value or y-value of core` by any  > 0, either p` will not be on the boundary of ` anymore, or ` would have intersection with another normal label. In fact, you may see the set of normal labels of a labeling, as a set of labels that cannot move to left or down, even if we remove the other (un-normal) labels. Definition 3 If all the labels of a labeling are normal, we call that a normal labeling. Now If we could prove that for every labeling L we have a normal labeling L∗ with equal weight, we only need to solve the problem for normal labelings, which are much more limited than the other labelings. In fact, we will construct a set A containing labels of all normal labelings with graphdiameter less than k2 . Then we will prove that there is a labeling with graph-diameter less than k2 and weight (1 + const/k)-times of wOPT . The algorithm is as follows: Algorithm 1 For an arbitrary positive integer k do: 1. Make k2 sets of labels A1 , A2 , · · · , Ak2 such that • A1 is the set of labels ` that core` = p` , i.e. size of A1 will be the same as the number of points • for i > 1 we put a label ` in Ai iff there is a labeling L such that ` is a normal label in L and it has an edge in GL to another label u such that u is a member of Ai−1 .

3

S 2 2. Compute A = ki=1 Ai , and let w(u) be a function that maps any member of A like u, to the weight of its point, i.e w(pu ). 3. Now find the maximum weighted independent subset of A by the algorithm introduced in [PKA98]. The output will be our chosen labels for the best labeling. We call the optimum subset of A as Ψ. Before analyzing the approximation factor of Ψ, we compute the running time of the Algorithm 1. Lemma 1 The size of Ai is less than ((2n)i ) for any i ≥ 1. Proof: We use induction on i. For i = 1, the size of A1 is n. For i > 1, for any point in P and any member of Ai−1 , we have at most two labels in Ai . By induction we know that size of Ai−1 ≤ (2n)i−1 and so the size of Ai is at most (2n)i . 2 As shown in Lemma 1, for some arbitrary constants t and k, the running time of Algorithm 1 will 2 k × F )-factor approximation. be O(ft ((2n)k )) where the produced labeling is a ( k−2M

4

Analyzing the algorithm

Theorem 1 W (Ψ) ≥ (1 − kc ) × OPT for some constant c. Before proving this theorem, we need to prove that for any labeling L, there is a normal labeling L∗ with the same weight. Lemma 2 If L is not normal, then there is a label ` ∈ L, such that for some d ∈ < and a direction dir ∈ {Lef t, Down}, these two conditions holds: • for any 0 < t ≤ d, if we move ` towards ”dir” by ”t”, our labeling remains valid. • if we move ` towards ”dir” by ”d + ” for any  > 0, either p` will not be on the boundary of ` anymore, or ` would have intersection with a normal label. Proof: First of all, we’ll eliminate all the normal labels and consider only the remaining labels. Now for any label `, if p` is on horizontal edges, we call ` a ”row ” label, otherwise we call it a ”column” label. Let u be a row label bounded vertically by the two lines r1 and r2 . (see Fig 2) Now consider Ru as the set of labels having intersection with the region bounded between r1 and r2 . We call the left most label in Ru (i.e the one with the lowest x-value for the left side) as next[u] (In case of ties, we choose the one with the lowest y-value) e.g in the Fig 2 v is next[u]. We’ll similarly define next[a] for a column label a. As c2 c1 in Fig 2, next[a] is the down most label having intersection pu a r1 with the column-like region bounded between c1 and c2 (in pa u case of ties, choose the one with the lowest x-value). For v r2 example in Fig 2, next[a] is b. To prove the lemma, we need to find a label ` such that ` = next[`]: the two conditions mentioned in the lemma will surely hold for ` (with dir = Lef t if ` is a row label, b and dir = Down otherwise). Figure 2: next − label Let t1 be an arbitrary label and for i > 1 consider ti as 4

next[ti−1 ]. We’ll prove the lemma by showing that there couldn’t be a cycle in the series of ti ’s (except, of course cycles of length 1). Let tk be the first label that had appeared before, we call this label u and we assume that the first appearance was at tj (i.e j < k and u = tj = tk ). Let r1 , r2 , c1 and c2 be the lines bounding u at down, up, left and right side. We also call the region bounded with r1 and c1 and at the same side with u, as Γ (see Fig 3). 00000000000000000000000000 11111111111111111111111111 Now consider tp as the first label after tj that 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 next[tp ] is completely in Γ. Without loss of gen00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 erality, consider tp as a row label. next[tp ] is 00000000000000000000000000 11111111111111111111111111 Γ 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 actually u; because tp is NOT completely in Γ 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 and so it has an intersection with r1 , but u is r2 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 00000000000000000000000000 11111111111111111111111111 u 00000000000000000000000000 11111111111111111111111111 surely the left-most AND the down-most label r1 te 00000000000000000000000000 11111111111111111111111111 in Γ and next[tp ] will be u. tp Now we’ll trace back from tk−1 , and let tf be c1 c2 the first column label we encounter(see Fig 3). tf For each f < i < k − 1 the row label ti will be Figure 3: N ormalizing strictly at the right of ti+1 , and will be strictly under the bottom of ti+2 (since next[ti ] is not ti+2 ) and the top of ti will be higher than bottom of ti+1 (i.e. if we project the labels tf +1 to tk on y-axis, they will cover the y-axis from the top of u to bottom of tf +1 ). Now we will continue tracing back from tf . It’s obvious that the x-value and the y-value of left-down corner of each column label is increasing and it couldn’t come higher than r1 . So consider te as the first row label we encounter after a series of column labels. Similarly every column label ti (e < i ≤ f ) will be at the top of ti+1 and at the right side of ti+2 (since the other labels are lower than ti+1 ). Now the paradox rises in the next[te ] : some of the row labels are covering all common y-values of left-sides of te and te+1 and so te+1 could not be the next of te . 2 Lemma 3 Let L be an arbitrary labeling, there is a normal labeling L∗ with the same weight. Proof: By Lemma 2, we know that if L is not normal, then we could find a label and a direction so that by moving the label in that direction, it wouldn’t stop by an un-normal label. So until our labeling is not normal, we repeatedly find such a label (we call it the pivot label), and move it in that direction as much as the labeling remains valid. We also know that none of the labels will become pivot more than 2 times (at most once in each direction) and so after finite iterations (O(n)), we would have a normal labeling L∗ with the same weight as L. 2 If L is a normal labeling with GL containing a path of length i ending at a label `, then ` is a member of Ai (introduced in Algorithm 1). Consider Qk2 as the set of normal labelings with graph S 2 diameter less than k2 . All the labels of L ∈ Qk2 are members of A = ki=1 Ai , and so Ψ will be in (1 + )-approximation of the optimum solution in Qk2 (i.e maxL∈Qk2 w(L)). To prove the Theorem 1, we will show that there is a normal labeling with the graph diameter less than k2 and the total weight of at least (1 − const/k)OPT. Theorem 2 There is a normal labeling with graph diameter less than k2 and the total weight of at least (1 − 2 M k )OPT. Proof:

5

Consider the minimum width and height of the labels of OPT as unit vectors for x-axis and y-axis of plane respectively. As before, we consider the axis-center at the bottom-left corner of plane. Now if we draw the integer grid on the plane, we call the column-like region bounded between the vertical lines at x = i and x = i + 1, as ci and similarly we call the row-like region bound between the horizontal lines at y = i and y = i + 1, as ri . For 0 ≤ i < k, we consider Ci as the set of labels of OPT having intersection with cx where i ≤ (x mod k) < i + M (in this grid, M is the maximum possible value for height and width of a label), and similarly Ri as the set of labels of OPT having intersection with rx where i ≤ (x mod k) < i + M . It’s clear that each label intersects Pk−1 P at most M continuous ci ’s or ri ’s. So i=0 u∈Ci w(u) and Pk−1 P i=0 u∈Ri w(u) will not exceed M P× OPT, and so for some 0 ≤Pi, j < k, we have u∈Ci w(u) ≤ M.OPT/k and u∈Rj w(u) ≤ M × OPT/k. Conrj sider L as the labeling obtained by removing Ci ∪Rj from the optimum solution. As shown in Fig 4, L is k−1 a composition of square-like regions with an empty area of width at least M between different regions (the regions are (k − 1) × (k − 1) squares). By definition of unit vectors, the minimum size of a label is 1 × 1, and so the maximum number of labels in k−1 each region is (k − 1)2 . ci Let L∗ be the normal labeling with the same weight Figure 4: Decomposition of plane as L. According to the empty area of width M be- (with unique − size labels and M = 1) tween the regions, there isn’t any edge in GL∗ between two labels of different regions. So L∗ will be a normal labeling with graph diameter less than k2 and total weight of at least (1 − 2 M k )OPT. 2 Since Ψ contains labels of all normal labelings with diameter less than k2 , as claimed in Theorem k × F )-factor approximation of the optimal labeling. 1, we will have a ( k−c

5

General point labeling

In this section, we will extend our work to general labeling problem. To do so, we modify theorems introduced in last two sections. In general labeling, we define a new meaning for normal labels. First we define the meaning of leaning. We say a label lp leans to lq if lp can not be moved left (leans from right) or down (leans from up) by any  > 0 and lq is an outgoing adjacent of lp . We say the label l of point p is normal in any of this four cases. • corl = pl . • If it is leaning to a normal label from right and cl = 0. • If it is leaning to a normal label from up and rl = 0. • If it is leaning to a normal label from right and another normal label from up. In the forth case, a label of p is cornered by two labels `1 and `2 . We say that l is settle(p, `1 , `2 ). If such a label can not exist, we say settle(p, `1 , `2 ) dose not exist (is null). 6

The Algorithm 1 makes normal labels of first three cases. In order to produce every possible normal label, the algorithm is modified as follows: Aside from all labels put in Ai>0 by the Algorithm 1, we add an extra set of labels to Ai : for any `1 , `2 ∈ Ai−1 and every p ∈ P , add settle(p, `1 , `2 ) to li . Since settle(p, `1 , `2 ) is unique, if not null, we can be sure that for every point we add O(|Ti−1 |2 ) labels to Ti . For each labeling A, there still exists a normal labeling A∗ with the same weight. To prove this, we modify the proof of Lemma 3: since there is no column or row label, we define a new definition. We would say a label ` is a column label, if rp = 0; otherwise it is a row label, the rest of proof is exactly the same. Since row labels can move along x axis (when chosen as pivot) and column labels can slide along y axis (when chosen as pivot), the proof of Lemma 2 is still correct. To show that the iterations are finite, we used the fact that every label is selected as pivot at most twice. Now, we can guarantee that in the process of driving labels down and left, no label crushes a normal label twice, so the number of iterations needed to make a normal labeling is still finite.

6

Conclusion

We have given a series of approximation algorithms for 4-slider and general method, when max-min ratio of height and width of labels is bounded by constant. Consider ft (g) = g(2t−1) . For 4-slider 2 model, we give a O(n(2k) ) time and (lg n + )-factor approximation. If labels are unit height, the 2 factors becomes 1 +  and the running time will be O(ft ( n(2k) ) ). In case of general labeling, (2k) 2

) ) time and gives the same results introduced for 4-slider the algorithm works in O(ft ( (2n)2 model. There are several issues that should be considered in future work: • Since we produce a fix position set, including a labeling of size (1+ ) times of wOPT , the algorithm in [PKA98] could be modified to work better for bounded height and width rectangles in order to reduce the lg n factor. • The time complexity is very pessimistic, and could be introduced as a function of ∆, the density of points. Doing so, [Cha04] can be used instead of [PKA98]. Note that closeness of points doesn’t necessarily effect the time complexity in a bad way. • Labeling some rectangular regions instead of points, is similar to the one in section 5. The only thing needed to be done is to modify algorithm in [PKA98] to get sets of labels as input and select at most one label of each set.

References [BZ02]

Zhongping Qin Binhai Zhu. New approximation algorithms for map labeling with sliding labels. Journal of Combinatorial Optimization, 6(1):99–110, 2002. [Cha96] Bernard Chazelle. The computational geometry impact task force report: An executive summary. In FCRC ’96/WACG ’96: Selected papers from the Workshop on Applied Computational Geormetry, Towards Geometric Engineering, pages 59–65, London, UK, 1996. Springer-Verlag. [Cha04] Timothy M. Chan. A note on maximum independent sets in rectangle intersection graphs. Inf. Process. Lett., 89(1):19–23, 2004. [MJvK99] Alexander Wolff Marc J. van Kreveld, Tycho Strijk. Point labeling with sliding labels. Comput. Geom., 13(1):21–47, 1999. [PKA98] Subhash Suri Pankaj K. Agarwal, Marc J. van Kreveld. Label placement by maximum independent set in rectangles. Comput. Geom., 11(3-4):209–218, 1998.

7

[SD97] [SHP03] [TE08] [Wol07]

Andy Mirzaian Bernard M. E. Moret Binhai Zhu Srinivas Doddi, Madhav V. Marathe. Map labeling and its generalizations. In SODA, pages 148–157, 1997. Tycho Strijk Takeaki Uno Alexander Wolff Sheung-Hung Poon, Chan-Su Shin. Labeling points with weights. Algorithmica, 38(2):341–362, 2003. Klaus Jansen Moritz Minzlaff Alexander Wolff Thomas Erlebach, Torben Hagerup. Trimming of graphs, with application to point labeling. In STACS, pages 265–276, 2008. Alexander Wolff. The map-labeling bibliography. 2007.

8

Suggest Documents