• 沒有找到結果。

單一直線地圖標記點數最佳化

N/A
N/A
Protected

Academic year: 2021

Share "單一直線地圖標記點數最佳化"

Copied!
55
0
0

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

全文

(1)

資訊科學與工程研究所

!

γ

!

!

Ў

!

單 一 直 線 地 圖 標 記 點 數 最 佳 化

Maximization of Points Labeling Problem on a Single Line

研 究 生:余昆霖

指導教授:李德財 教授

(2)

單一直線地圖標記點數最佳化

Maximization of Points Labeling Problem on a Single Line

研 究 生:余昆霖 Student:Kuen-Lin Yu

指導教授:李德財 Advisor:D.T. Lee

國 立 交 通 大 學

資 訊 科 學 與 工 程 研 究 所

碩 士 論 文

A Thesis

Submitted to Institute of Computer Science and Engineering College of Computer Science

National Chiao Tung University in partial Fulfillment of the Requirements

for the Degree of Master

in

Computer Science

June 2006

Hsinchu, Taiwan, Republic of China

(3)

-  D      (

*E+A,-F.G/A0E1H- I;2

J K

LMONQPSRQT UWVXOYZ\[^]D_a`cbdfegD_^hji UWk^lQmOnSoOZQpOegq_srt usv LOwcxQy{z| } ~)€ mFƒ‚H_„` U…LE†)‡‰ˆ ~Š;‹ _Gr)ŒH_=Ž† U 1d4PE‘ e ’ “ 1d4S”‘ e ’)•^– Slope4P—S˜š™› (œq› ) _De ’ƒGž hŸišt„  • Lƒzš¡ _{¢£Ÿ¤¦¥§ }

VXOL^MONOPSRƒ¨ª©«¬ ­¯®Ÿ°\±¬q²O_a³^´QµO¶S· ­¯¸Q¹º±¬(² »½¼O¾

`

Max-1d4P_se ’Qž hji UW¿Q©OÀQÁQÂ

˜ LQÃ^Ä\zS|Ÿ_smOnOrÅ¨ÇÆÈÉLÊQËOÌ ÍQΟ_s{†c¸ŸÏs {ecgÐ_jr\Ñ } VQX\©OÀ{†O‡Qx\Ò O(n log n) _fÓQÔcÕ UÖMcTŸ_ n `\m\רS_fr\Ñ }

(4)

Maximization of Points Labeling Problem on a Single Line

Student: Kuen-Lin Yu

Advisor: Prof. Der-Tsai Lee

Institute of Computer Science and Information Engineering

College of Electrical Engineering and Computer Science

National Chiao Tung University

ABSTRACT

In this paper, we consider a map labeling problem where the anchors to be labeled are restricted on a line. It is known that the 1d4P rectangle label, the 1d4S square label and the Slope4P fixed height (width) label placement problems can all be solved in linear time provided that the anchors are in sorted order [2,3]. We extend the decision version results to the maximization version: Max-1d4P label placement problem, which is to maximize the number of labels that can be placed on a given set of anchors on a horizontal line. We present an O(n log n) time algorithm solution, where n is the input size.

(5)

Acknowledgements

MQNOPSRQÙQÚSÛ{Ü UWÝÞOZOßQàD_s¾`SáâcãäQåæOçÐè\ÂOVq_aéê UWLVD_së ì\íOî ¨ªÊQïOŸð\VEñóòD_së ì\ôQõ U÷öS¢ø{†ƒÈjxOùOúûD_{üOÕ UÖýV^ÙQÚL McÒ\ë ìaþcÿ ¨Ð_ U Qß U Oà }

¼ZOßOàVq_fPŸRçŸè OçÐè U÷ßOàSá !çÐè\ÂSð " Ï$# %S_'&( QücÕ U*)VŸ_ P^R\ÙcÚ+-,^Û. }

/ ã^ZOßOàq_a`0132 465 7689 UÖL^MSáâŸ_fë ì::; ¨ªÂ(ˆsV"qÏO_ <= > ? UWöA@3BÉVx CO¥S§cë ì\íOî ¨ÇmDE^·Ð_'FFGi UH)^V^ÙOÚ6I¢ I{b^tOÆJ· KР • ]QP(hfi UÖLx

˜

Z b^ßOà89 }ML-N¼6OøcßOàPQ 89'RBS8\Mácâ{ãŸ_-@'T U*)VQMácâc  •Çí JÐÏVUqÏXW }

¸YSZOßOàVD_Z-K^ÂV[ \]q_^'_ UWýVŸ  •'` [YabAcS_cÛ{Ü^Vq_ 8ed } ¼SßSàefAf “Mgh “Mi6j “kgAl “ #Am n ¹eo nqp$r ntsXY n g6u n g v nxw-yz|{~} €-‚ ƒ6„$…Z'†‡ˆA„X‰-Š ‹*Œ Ž ‡‘ ’e„ “

(6)

Contents

Title . . . i

Chinese Abstract . . . ii

English Abstract . . . iii

Acknowledgements . . . iv

Contents . . . v

List of Figures . . . vi

1 Introduction . . . 1

2 Preliminaries . . . 4

3 Maximum Independent Set of Label Placements for Different Models . . . 9

3.1 1d2PH, 1d2PV . . . . 9

3.2 1d4P . . . 10

3.3 1d2kP . . . 19

4 Conclusion Remarks . . . 20

Bibliography . . . 21

Appendix I : Example of R-map . . . 24

(7)

List of Figures

1.1 Illustration of 2PV, 2PH, 4P, and 4S models. . . 2

2.1 Example of maximizing the number of labeled points. . . 4

2.2 Example of the R-map. . . 7

3.1 (a) Example of incomparability between realizations resulting from plac-ing labels 1 and 3. (b) Example of undecidable situation as to whether we should choose to include label 1 or not. . . 11

3.2 Illustration of Lemma 3.2.4. . . 13

3.3 Proof for Lemma 3.2.8 (b). . . 18

I.1 Illustration of the growing incomparable points number (1) . . . 24

I.2 Illustration of the growing incomparable points number (2) . . . 25

I.3 Illustration of the growing incomparable points number (3) . . . 25

I.4 Illustration of the growing incomparable points number (4) . . . 26

I.5 Illustration of the growing incomparable points number (5) . . . 26

I.6 Illustration of the growing incomparable points number (6) . . . 27

I.7 Illustration of the growing incomparable points number (7) . . . 27

I.8 Illustration of the growing incomparable points number (8) . . . 28

I.9 Illustration of the growing incomparable points number (9) . . . 28

I.10 Illustration of the growing incomparable points number (10) . . . 29

(8)

Chapter 1

Introduction

In cartographic literature, the main approach to letting people know what is on the map is attaching texts or labels to geographic features on the map. Automated label placement subject to the constraint that the labels are pairwise disjoint is a well-known important problem in geographic information systems (GIS). In the ACM Computational Geometry Impact Task Force report [1] the map label placement is listed as an important research area. Since this problem in general is known to be NP-complete, many heuristics or special cases for which polynomial time algorithms are given have been presented. For instance, there are many algorithms that have been developed for labeling points that are on lines [2–6] or in a region [7–16].

Let A denote a set of points {A1, A2, . . . , An}in the plane, called anchors.

Asso-ciated with each anchor there is an axis-parallel rectangle, called label. The point-feature

label placement problem or simply point labeling problem, is to determine a placement

of these labels such that the anchors coincide with one of the corners of their associated labels and no two labels overlap. The point labeling problem for labeling an arbitrary set of points has been shown to be NP-complete [8,10,11,14] and some heuristic algorithms were presented in [8,16,17].

There are many variations of the point labeling problem, including shapes of the labels, locations of the anchors to be labeled and where the labels are placed. Consider the case that the placement of the labels are restricted. For instance, one is fixed-position

model, denoted 4P model, in which a label must be placed so that the anchor coincides

with one of its four corners; and another is slider model, denoted 4S model, in which a label can be placed so that the anchor lies on one of the four boundary edges of the label. Figure 1.1 shows these two point labeling models. The positions {1, 2, 3, 4} in 4P model shown in Figure 1.1 denote the corner positions of labels coincident with the anchor, and the arrows in 4S model indicate the directions along which the label can slide, maintaining contact with the anchor. Moreover, if we restrict the number of fixed positions to be 2, and horizontal or vertical direction in which fixed-position labels are arranged, the problem will be denoted 2PH or 2PV model respectively.

(9)

1 4 2 3 2 3 2 1 2PH 4P 4S 2PV

Figure 1.1: Illustration of 2PV, 2PH, 4P, and 4S models.

In this paper we consider the case when the anchors lie on a line and are to be labeled with rectangular labels. This problem has been studied previously [2,3,6,12]. The prefix 1d or Slope refers to the problem in which the anchors lie on a horizontal or a sloping line, respectively. Garrido et al. [3] gave linear time algorithms for 1d4P rectangle label, 1d4S square label, and Slope4P square label models, and a quadratic time algorithm for Slope4S square label model as well. They also showed 1d4S rectangle label is NP-complete and consider the maximization version to maximize the size of labels. Chen et al. [2] further provided linear time algorithms for Slope4P fixed height(or width) rectangle label and elastic rectangular label (of a given area) models. They also presented a lower bound Ω(n log n)time and a different method to maximize the label size for 1d4S square label model. In addition, in order to produce map labeling of maximum legibility in automatic label placement, certain optimization versions of the problem were considered. The two most common optimization criteria are the number of labels and the size of labels, for which feasible solutions can be obtained. In 1998, Agarwal et al. [18] provided a PTAS (1 + 1/k)algorithm in O(n log n + n2k−1)time, for any integer k ≥ 1, for 4P fixed-height

rectangle label model and an O(log n) factor approximation algorithm in O(n log n) time for 4P arbitrary rectangle labels. Poon et al. [6] further considered the weighted case in which each label is associated with a given weight and provided the same approximation result for 4P fixed-height weighted rectangle model. They also gave a (2 + ) factor approximation algorithm in O(n2/) time for 1d4S weighted rectangle label. As for 4P

arbitrary rectangle label, Berman et al. [19] presented a dO(logkn)efactor approximation

algorithm in O(nk+1) time, for any integer k ≥ 2. In 2004, Chan [20] improved the

previous results to give a PTAS (1 + 1/k) algorithm in O(n log n + n∆k−1)time, where

∆ ≤ ndenotes the maximum number of rectangles whose intersection is nonempty, for 4P fixed-height rectangle label model and a dO(logkn)efactor approximation algorithm

(10)

in nO(k/ log k)time for 4P arbitrary rectangle label.

We investigate the maximization version of the feasible number of labels when the anchors lie on a horizontal line. That is, we want to maximize the number of labels for which a feasible placement exists that no two labels overlap. As a contrast to the previous results in which they all employed the line stabbing technique, we describe a different approach to solving this model, referred to as 1d4P rectangle label model, or

Max-1d4P for short, in O(n log n) time. This paper is organized as follows. In Section 2,

we introduce some definitions and ourR-map method. Then we present in Section 3 an

intuitive method to solve Max-1d2PH, Max-1d2PV models and point out the difference between Max-1d2P and Max-1d4P models. We also consider the intricate Max-1d4P model and provide an O(n log n) time algorithm. Then we extend it to an O(kn log kn) solution for Max-1d2kP model, which is a generalization of Max-1d4P model. Finally we conclude in Section 4 with some discussions of future work.

(11)

Chapter 2

Preliminaries

Consider a set of anchors A = {A1, A2, . . . , An} on a horizontal line, and each anchor

Ak is associated with its position (in x-coordinate) xk and label size lk. The aim is to

maximize the number of feasible labels so that they do not overlap with each other.

Figure 2.1: Example of maximizing the number of labeled points.

Since we consider the problem on a horizontal line and put the label either above or

below the line, we can simply associate a 2-tuple, namely (a, b), to represent the current

labeling state of a realization R, with R.a = a and R.b = b. The first variable, a, shows the coordinate of right edge of the rightmost label above the line; the second variable, b, shows the rightmost one below the line. A realization R will also contain a specification of the placement of feasible labels associated with a subset of anchors. To be more precise, we can use Ai.` ∈ R, where ` ∈ {0, 1, 2, 3, 4} indicates the label position for anchor Ai

included in R, with ` = 0 representing anchor Ai is not labeled. If R contains k-feasible

labels, i.e., it contains k non-zero `’s associated with Ai.`, then R is called a k-realization,

and we use R.c to denote the cardinality of the subset of feasible labels represented by the realization R. We shall use the notation R to represent not only a realization R of A, which is a subset of feasible anchors, i.e., R ⊆ A, but also use R.a, R.b and R.c to represent the state of its configuration and its size, respectively. Let us assume that the set of anchors has been ordered so that their x-coordinates are in strictly increasing order. That is, x1 < x2 < . . . < xn. Let Ai denote the subset of anchors {A1, A2, . . . , Ai}, for

i = 1, 2, . . . , n, and Ri denote a realization of A

i for some i. An optimal solution is a

realization Rnsuch that Rn.cis maximum among all possible realizations of A n.

We shall process the anchors, and their associated labels, in ascending order of their x-coordinates, i.e., in the order of A1, A2, . . . , An. Given a realization Ri−1of Ai−1, and

(12)

label both above and below the line in Ri−1are called feasible label placements. Before

proceeding we define the notion of equivalence of two realizations:

Definition 2.0.1 Given two realizations Ri

1 and Ri2 of Ai such that Ri1.c and Ri2.c are equal, if

{Ri

1.a, Ri1.b} = {Ri2.a, Ri2.b}

we say that the two realizations areequivalent in size, or simply equivalent to each other.

Based on the above definition, for a realization Riwith Ri.a < Ri.b, we always swap

the upper and lower sides of the realization. That is, a realization will be represented in a

normal form in which the coordinate above the line is no less than the coordinate below

the line, i.e., Ri.a ≥ Ri.bwithout loss of generality. Here we define the comparability of

two realizations.

Definition 2.0.2 For any two realizations Rk

i and Rjk, k = 1, 2, . . . , n, if the following statements hold,

1. Rk

i.c = Rkj.c, and 2. Rk

i.a ≤ Rkj.a, and Rik.b ≤ Rkj.b

then we say that the two realizations arecomparable and Rk

i isbetter than Rkj.

Other-wise, they areincomparable.

Lemma 2.0.3 Let R be an optimal realization of A. Suppose Rk

i and Rkj are two compa-rable realizations for Akand Rki is better than Rkj for some n ≥ k ≥ 1. If R contains Rkj as a subset, then there exists another optimal solution that contains Rk

i.

Proof: Since Rk

i.a ≤ Rkj.aand Rki.b ≤ Rkj.b, we can obtain R0by replacing Rkj in R with

Rk

(13)

By using a 2-tuple to represent the labeling state of a realization, we can transform it into a point in the 2-dimensional plane, which we call anR-map. To be more precise,

given a realization R represented by a 2-tuple (R.a, R.b), we transform it into a point (x,y), where x = R.a and y = R.b, in the plane. The two equivalent realizations will then be transformed into two points that are symmetric with respect to the line x = y. From now on, we use P.x and P.y to represent the x and y coordinates of a point P on the R-map, and P.c to represent its associated cardinality.

We assume the point labeling on a line starts at the origin without loss of generality, which means the transformed points on the R-map are all in the first quadrant. Using the normal form representation of a realization, all realizations will be mapped to points that are all located in the first quadrant below the line x = y. More specifically, it is the area generated by the following equations: x ≥ y, and y ≥ 0.

Based on the comparability definition between two realizations, if one is better than the other, then the transformed points will carry the relationship of domination. That is, if realization RAis better than realization RB, then point PBdominates1point PAon the

R-map. On the other hand, if they are incomparable realizations, the transformed points on the R-map do not dominate each other.

We shall also transform each anchor with its given label from the original representa-tion into another term on the R-map. We use across on the R-map to stand for an anchor

with its label, and the length of each arrow shows its given label size. The center of every cross is located on line x = y. The arrows are labeled from 1 to 4 for left, bottom, top and right, corresponding to the numbering of original labels respectively. The label overlap-ping situation is then transformed into arrows intersecting either the vertical line passing through the x-coordinate or the horizontal line passing through y-coordinate of a point on theR-map. We define the operations on the R-map as follows.

Definition 2.0.4 Given a point p(x, y) representing a realization and a cross C

repre-senting a new label i on the R-map, whose center is (C.x, C, y) and arrow length is C.`, we have the following operations depending on how we select the placement of label i of

1If P

(14)

the anchor c for the realization p (i.e. apply arrow i) 1. i = 1, then p(x, y) generates p0(C.x + C.l, y) 2. i = 2, then p(x, y) generates p0(C.x, y) 3. i = 3, then p(x, y) generates p0(x, C.y) 4. i = 4, then p(x, y) generates p0(x, C.y + C.l)

The cardinality associated with point p0 will be one more than that with point p’s

car-dinality. If the y-coordinate of p0 is greater than the x-coordinate, we do the swapping

operation to exchange the x- and y- coordinates. We call point p theparent point of p0

and the generated point p0 thechild point of p.

3

4

2

1

p p0 3 p0 1

Figure 2.2: Example of the R-map.

Take Figure 2.2 as an example. Given a parent point p(x, y) and a cross located at (C.x, C.y)with arrow length C.l, arrow 2 of the cross C represents an infeasible place-ment with respect to point p. Applying arrows 1 and 3, point p generates two child points p0

(15)

Property 2.0.5 Given a parent point p(x, y) and a cross C located at (C.x, C.y) with

arrow length C.l,

1. If y > C.y, the point can apply no arrow.

2. If C.y ≥ y > C.y − C.l, the point can apply arrow 4. 3. If C.y − C.l ≥ y, the point can apply arrows 3 and 4. 4. If x > C.x, the point can apply neither arrow 1 nor arrow 2. 5. If C.x ≥ x > C.x − C.l, the point can apply arrow 1. 6. If C.x − C.l ≥ x, the point can apply arrows 1 and 2.

(16)

Chapter 3

Maximum Independent Set of

Label Placements for Different Models

We adopt a greedy method to solve the problem for each model, namely, we process the anchors in sequential manner, and will maintain a set of realizations that reflect the best possible labeling, ignoring those that are known to be no better than the present set of realizations, after each anchor is processed.

3.1 1d2PH, 1d2PV

For the 1d2P H model, which only allows placement of labels 1 and 2, the problem can be transformed to the problem of Maximum Independent Set (MIS) of Interval Graph, which can be solved in O(n) time when the anchors are given sorted. The following lemma is obvious.

Lemma 3.1.1 Given two realizations Ri

A and RiB, for i = 1, 2, . . . , n, we will select RiA over Ri

B, either if RiA.c > RiB.c, or if RAi .c = RiB.c, and RiAis better than RBi .

Lemma 3.1.2 Given a realization Ri−1, when both placements of labels 2 and 3 of next anchor Ai are feasible, the selection of label , label 2, above the line will yield a better realization Ri.

Proof: Given a current realization (a, b) with the normal form representation (i.e., a > b)

and the anchor position x, placing label at x either above or below the line changes the labeling state into (x, b) or (a, x) respectively. Since a > b, placing the label above the line generates a better realization.  Here we give a greedy algorithm for the problem 1d2P V , which only allows labels 2 and 3 without loss of generality.

(17)

Algorithm 3.1.1 M2PV

Input: A set of anchors sorted by their x-coordinate and their associated labels. Output: The maximum cardinality of map labeling for model 1d2P V .

1: while pick up the next anchor from the sorted list do 2: if the placement of label 2 is feasible then

3: place label 2 and put the anchor into MIS solution, cardinality++ 4: else if the placement of label 3 is feasible then

5: place label 3 and put the anchor into MIS solution, cardinality++ 6: else

7: discard the anchor. 8: return cardinality

The time complexity of M2PV is O(n) given the sorted anchors.

Theorem 3.1.3 The algorithm of M2PV generates an optimal solution.

Proof: Immediate. 

3.2 1d4P

Now let us consider model 1d4P. Given an anchor whose feasible labels are label 1, 3

and 4, placing either label 1 or label 3 may generate an optimal solution. We cannot tell which placement is better at the time when we process the anchor. Figure 3.1(a) shows that the choice between the placements of labels 1 and 3 is best decided by future anchors. The top realization shown in Figure 3.1(a) shows the placement of label 1 of the anchor leads to an optimal solution. However, the bottom realization shown in Figure 3.1(a) shows the placement of label 3 of the anchor leads to an optimal solution. Furthermore, given an anchor whose feasible labels are labels 1 and 4, we cannot immediately decide whether placing either one can generate an optimal solution or not. Figure 3.1(b) shows the placement of label 1 may block the future labels. That is, we may need to postpone the decision as to whether the current anchor is to be included in the realization until

(18)

later. The condition also occurs for label 4. However, if we must choose one placement between label 1 and label 4 of an anchor, then following Lemma 3.1.2, the choice of the label above the line (label 1) gives a better realization. We first observe some properties of model 1d4P .

1

(2)

(1)

1

4

3

Figure 3.1: (a) Example of incomparability between realizations resulting from placing labels 1 and 3. (b) Example of undecidable situation as to whether we should choose to include label 1 or not.

Proposition 3.2.1 Given a realization Ri−1, when both placements of labels 1 and 2 (re-spectively, labels 3 and 4) of next anchor Ai are feasible, the selection of label 2 (respec-tively, label 3) will yield a better realization Ri.

Lemma 3.2.2 Given a realization Ri−1, when the placement of label 3 of next anchor A i is feasible, the anchor is included in the MIS solution.

Proof: Suppose the current realization is (a, b) with a > b and the next anchor Ai whose

placement at label 3 is feasible. Assume that there is an optimal solution such that it does not contain Ai. It is trivial that if placing label 1 or label 3 of Aiinto the solution overlaps

no labels, then we can place one more label into the solution to get a larger cardinality, which leads to a contradiction. Otherwise, there is an anchor Aj, j > i. i.e, Aj is to the

(19)

right of Ai, whose label 3 overlaps the label 3 of Ai. Since Aj is to the right of Ai, we can

replace label 3 of Aj by the placement of label 3 of Ai to get a better realization. 

Corollary 3.2.3 Given a realization Ri−1, when the placement of label 2 of next anchor

pi is feasible, the anchor is in the MIS solution.

We introduce our main idea as follows. Let S[i, j] denote a set of incomparable realizations Rj of cardinality i, for 1 ≤ i ≤ j ≤ n. We shall apply a dynamic

program-ming method to process the anchors and record the ’better’ realizations of each possible cardinality. To find an optimal realization Rn, we may need to maintain intermediate

realizations S[i, j] for 1 ≤ i ≤ j ≤ n, that have the potential leading to an optimal re-alization. As we shall show later, for each j ≤ n we only need to maintain at most five subsets S[k, j], S[k + 1, j], S[k + 2, j], S[k + 3, j], and S[k + 4, j] for some k. We shall process the table from j = 1 till n and fill each entry S[i, j] with a set of incomparable re-alizations, and there are probably quite a few incomparable realizations to be maintained at each step.

The realizations in an incomparable set form a ”point chain” on the R-map without having any point in the chain dominate another. When we encounter a new cross, some of the point in this chain of cardinality k, for some k, will generate new child points, thus getting upgraded to a realization of cardinality k + 1, some will remain as non-upgraded with cardinality k, and are kept as potential candidates leading possibly to an optimal solution, and some get eliminated due to some new child points upgraded from points of cardinality k − 1. At the end after anchor An is processed, the realizations in the

non-empty entry S[i, n] with the largest i are optimal solutions.

To sum up, some points in the set S[i, j] may simply move to S[i, j + 1] without increasing cardinality, following what we call a non-upgrading process. Other points in the set may generate points which are included in S[i + 1, j + 1], whose cardinality is incremented, following what we call an upgrading process. When a point moves from one entry to another, it should be compared with other points in the target entry, and only

better ones are kept. We repeat such operations until we have processed all anchors. The

(20)

Algorithm 3.2.1 M4P

Input: A set of anchors sorted by their x-coordinates and their associated labels. Output: A maximum cardinality of map labeling for model 1d4P .

1: Use dynamic programming method on two parameters S[i, j]: the anchor ordering in

column and the cardinality of possible solutions in row. Initialize the first entry by the placement of label 2 of the first anchor.

2: for j = 2 to n do

3: Let the largest cardinality of non-empty entries in column j − 1 be k. 4: for i = k to max{k − 4, 0} do

5: 2-1. Classify the points in S[i, j − 1] into upgrading and non-upgrading classes. 6: 2-2. Move the non-upgraded points into S[i, j].

7: 2-3. Move the upgraded points into S[i + 1, j].

8: 2-4. Compare the points in S[i + 1, j] and keep the better ones.

9: return The maximum cardinality of non-empty entries.

In what follows we will prove a few results that help establish the correctness of our algorithm. Let PAand PBbe two points on the R-map, and (C.x, C.y) be the coordinates

of the next cross.

(a) (b) PB PA PB PA PB P0 B PA

Figure 3.2: Illustration of Lemma 3.2.4.

Lemma 3.2.4 For the following two cases

(a) PA.x ≥ PB.x, PA.y < PB.y, PA.c < PB.cand C.y ≥ PB.y (b) PA.y ≥ PB.y, PA.x < PB.x, PA.c < PB.cand C.x ≥ PB.x

(21)

Proof:

(a) Since C.y ≥ PB.y > PA.y, applying the cross, PAwill generate a point Pnew where

Pnew.x ≥ PA.x ≥ PB.xand Pnew.y ≥ C.y ≥ PB.yand Pnew.c = PA.c + 1 ≤ PB.c. That

is, PAcannot generate any child point which is better than PB, so PAneed not be kept.

(b) Since C.x ≥ PB.x > PA.x, applying the cross, PA will generate a point Pnew

where Pnew.x ≥ C.x ≥ PB.xand Pnew.y ≥ PA.y ≥ PB.yand Pnew.c = PA.c+1 ≤ PB.c.

That is, PAcannot generate any child point which is better than PB, so PA need not be

kept. 

Lemma 3.2.5 The points in an incomparable set going through an upgrading process

generates at most two incomparable child points.

Proof: By the definition of operations on the R-map, we know that after applying a cross

C of the center (C.x, C.y), the child points will be located on one of the following four lines:

1. x = C.x 2. x = C.x + C.l 3. y = C.y 4. y = C.y + C.l

Moreover, since we represent a realization in a normal form, such four lines can be ex-pressed more specifically as:

1. x = C.x, y ≤ C.y

2. x = C.x + C.l, y ≤ C.y + C.l 3. y = C.y, x > C.x

4. y = C.y + C.l, x > C.x + C.l

It is then easy to see that at most two incomparable points can be found on these four

lines. 

Theorem 3.2.6 The number of points in an incomparable set is bounded by O(n). Proof: By Lemma 3.2.5, there are at most two points added to an entry while processing

(22)

O(n). 

Theorem 3.2.7 After processing a cross C, if there is a point with cardinality k which is

the ancestor of a point with cardinality k + 5, then no point with cardinality k will lead to an optimal solution. That is, the difference in cardinality of incomparable points is at most four.

Proof: Let point P (x, y) whose associated cardinality is k be the ancestor of a point with

cardinality k + 5. For any point Q(x0, y0)whose associated cardinality is k, we have the

following two cases to consider, y0 ≤ yand y0 > y.

Case 1: y0 ≤ y. Consider the three crosses that were applied to upgrade point P to a point

P0 of cardinality k + 3. Among these three crosses, at least two labels, say C iand

Cj, j > i, must be placed on the same side of the line. It is clear that the anchor

corresponding to the next cross C lies totally to the right of the label associated with Ci. Since Q(x0, y0)is an arbitrary point of cardinality k with y0 ≤ y, we know

that cross Ci can be applied to point Q. Then point Q0 upgraded by Ci is always

better than point Q, by Lemma 3.2.4(a). Thus point Q need not be kept, which is to say, any point with cardinality k whose y-coordinate is no more than y need not be retained. That is, when a point P (x, y) of cardinality k got upgraded by three to a point P0of cardinality k +3, those points Q(x0, y0)of the same cardinality k, y0 ≤ y

would be upgraded by at least one to Q0 of cardinality k + 1 and Q0 always better

than Q. And therefore the difference in cardinality of these points of cardinality k, when one of them got upgraded by three to P0of cardinality k + 3, is at most two.

Case 2: y0 > y. Without loss of generality let us consider an arbitrary point Q with x0 <

x and y0 > y. Among the five crosses that have been applied to point P , at least

three labels, say those associated with crosses Ci, Cj,and Ck, k > j > i, must be

placed on the same side of the line, and the next cross C lies totally to the right of labels associated with Ci and Cj. If Ci is placed above the line, it is obvious that

cross Ci can also be applied to upgrade Q, since x0 < x. By Lemma 3.2.4(b), point

Q0 upgraded by C

(23)

not be kept. Suppose all these three labels are placed below the line. Without loss of generality, let us take the leftmost three crosses, Ci, Cj,and Ck, k > j > i. Let

P0 denote the child point upgraded from point P after cross C

j is applied, and let

P0.y denote the right side of the label associated with C

j. If P0.y ≥ y0, then cross

Ckand the other two crosses, will play the role of the three crosses, P0will play the

role of P , as inCase 1 above, then as shown before , we no longer need to keep Q

(of cardinality k). Otherwise, (P0.y < y0) consider the the cross C

h corresponding

to the last label below the line associated with point Q. We know that Ch(or anchor

Ah) is to the left of Ci (or anchor Ai). Since the label associated with Cj is placed

totally to the right of the label associated with Ci, we can replace the last label

associated with Ch in Q by the label associated with Cj to obtain a new point Q0,

so that Q0.c = Q.c = k, and Q0.y = P0.y < y0. This implies that Q0 is better

than Q after the replacement, and Q would have been eliminated after Ci and Cj

were considered. Then when Ck is applied to P0, it can also be applied to point

Q0. Since cross C is totally to the right of the label associated with C

k, by Lemma

3.2.4(a), point Q0 (which is better than Q) upgraded by C

k is always better than

point Q. Thus, we no longer need to keep point Q. That is, when a point P (x, y) of cardinality k got upgraded by five to a point of cardinality k + 5, those points Q(x0, y0)of the same cardinality k, y0 > y would be upgraded by at least one to a

point of cardinality k + 1 and always better than Q which remain non-upgraded, and therefore the difference in cardinality of these points of cardinality k, when one of them got upgraded by five to a point of cardinality k + 5, is at most four.

To sum up, any point with cardinality k which gets upgraded to a point with cardi-nality k + 5, will force all the points which remain non-upgraded to have cardicardi-nality k to be subsumed by other upgraded points. Therefore no point with cardinality k will lead to an optimal solution and the difference in cardinality of these incomparable points is at

most four. 

By Theorem 3.2.7, in computing S[i, j] for 1 ≤ i ≤ j ≤ n, it is sufficient to maintain at most five consecutive sets of incomparable realizations S[k, ∗], S[k + 1, ∗], S[k + 2, ∗], S[k + 3, ∗]and S[k + 4, ∗].

(24)

Lemma 3.2.8 The following operations all take O(log n) time.

(1) Classifying points into the upgrading and non-upgrading classes. (2) Finding two incomparable points among all upgraded points. (3) The comparison between one point and n incomparable points.

Proof: (1) When we process a cross C centered at (C.x, C.y), we can simply divide the

set of points of our R-map into three layers by two lines below: 1. y = C.y

2. y = C.y − C.l

The points P in the top layer with P.y ≥ C.y belong to non-upgrading class. The points P in the middle layer with C.y ≥ P.y ≥ C.y − C.l belong to both upgrading and non-upgrading classes. The points P in the bottom layer with C.y − C.l ≥ P.y belong to the upgrading class. Since the set of incomparable points can be maintained in sorted order in y-coordinates, two binary searches suffice.

(2) We can divide the lower two layers above into five regions (R1, R2, R3, R4 and R5,

see Figure 3.3) by the following two lines: 1. x = C.x − C.l

2. x = C.x

By the operations on the R-map, we know that the following points in the chain of up-graded points are better than all the other points (in the chain) in each of their regions after the upgrading process:

1. the rightmost point of the chain in R1

2. the leftmost point of the chain in R2

3. the leftmost point of the chain in R3

4. the rightmost point of the chain in R4

5. the leftmost point of the chain in R5

We can also use binary search four times to obtain the five points (at most three points in a point chain actually). Finding the two incomparable points out of these points takes constant time.

(3) Since an incomparable set is a point chain without any point dominating another, we need only to find out all points in the chain that dominate p when we have to compare a point p with such a point chain. We can simply do binary search in the chain two times

(25)

to divide the chain into three sub-chains of consecutive points and the middle sub-chain which dominates p can then be eliminated and replaced by p. 

R

3

R

2

R

1

R

4

R

5

Figure 3.3: Proof for Lemma 3.2.8 (b).

Theorem 3.2.9 The time complexity of Algorithm M4P is O(n log n).

Proof: By Theorem 3.2.7, the inner for loop repeats at most five times. By Lemma 3.2.8,

the tasks in the inner for loop can be completed in O(log n) time. The outer for loop repeats n times to handle n anchors. Then the total time complexity for solving model

1d4P is O(n log n). 

When the algorithm terminates, any point in S[k, n] with the largest k is an optimal solution (of maximum cardinality k). The actual placement of labels can be obtained if we record the processing history when a point is upgraded.

(26)

3.3 1d2kP

The 1d2kP model is a generalization of 1d4P model. It allows the label of each anchor to be placed at k positions, k ≥ 2, both above and below the line. Poon et al., Strijk and van Kreveld, Kim et al. studied the decision k-position models [13,21,22]. We consider the maximization of 1d2kP problem. Due to the definition of k-position model, the incompa-rable points in an entry could be up to O(kn), therefore the time complexity of classifying points in Lemma 3.2.8 (1) is O(log kn). The number of lines in Lemma 3.2.5 is also mod-ified by k, and thus the number of incomparable points of upgrading process in Lemma 3.2.5 would be k. Therefore the time complexity of Lemma 3.2.8 (2) is O(k log kn), and the comparing time between k points and kn points would also be O(k log kn) in Lemma 3.2.8 (3). The overall time complexity of solving model 1d2kP would be O(kn log kn).

(27)

Chapter 4

Conclusion Remarks

We have extended the decision version of the map labeling problem on a horizontal line to an optimization version where the number of feasible labels is to be maximized. It is a variation of maximum independent set problem on interval graphs. It can also be regarded as a simplified version of job-machine scheduling problem (two machines, each job has k time intervals to be selected in its given time range) in which the number of schedulable jobs is to be maximized. We present an O(n log n) time algorithm for Max-1d4P model by dynamic programming on two parameters: the anchor ordering and the cardinality of possible solutions.

We have proposed the R-map idea which can be useful for quite a few problems, including many versions of job scheduling problems. Moreover, we feel that it may be used to improve the approximation ratio for general Max-4P problem when combining the line stabbing technique and our solution. Whether there exist solution for the Max-Slope4P fixed height(or width) rectangle label model remains to be seen.

(28)

Bibliography

[1] B. Chazelle and . co-authors. The computational geometry impact task force report ( 407-463), Advances in Discrete and Computational Geometry, vol. 223. American Mathematical Society, Providence, 1999.

[2] D. T. L. Yu-Shin Chen and C.-S. Liao, “Labeling points on a single line,”

Interna-tional Journal of ComputaInterna-tional Geometry and Applications (IJCGA), vol. 15, no. 3,

pp. 261–277, 2005.

[3] A. M. J. R. P. P. R. M. ´A. Garrido, C. Iturriaga and A. Wolff, “Labeling subway lines,” in Proc. 12th Annual International Symposium on Algorithms and

Computa-tion (ISAAC’01), vol. volume 2223 of Lecture Notes in Computer Science, pp. 649–

659, 2001.

[4] C. Iturriaga and A. Lubiw, “Elastic labels: The two-axis case,” in Proceedings of

the Symposium on Graph Drawing (GD’97), vol. volume 1353 of Lecture Notes in

Computer Science, pp. 181–192, 1997.

[5] C. Iturriaga and A. Lubiw, “Elastic labels around the perimeter of a map,” Journal

of Algorithms, vol. 47, no. 1, pp. 14–39, 2003.

[6] T. S. T. U. S.-H. Poon, C.-S. Shin and A. Wolff, “Labeling points with weights,”

Algorithmica, vol. 38, no. 2, pp. 341–362, 2003.

[7] A. V. R. Duncan, J. Qian and B. Zhu, “Polynomial time algorithms for three-label point labeling,” Theoretical Computer Science, vol. 296, no. 1, pp. 75–87, 2003. [8] M. Formann and F. Wagner, “A packing problem with applications in lettering of

maps,” in Proceedings of the 7th ACM Symposium on Computational Geometry, pp. 281–288, 1991.

[9] Z. Q. B. Z. M. Jiang, J. Qian and R. Cimikowski, “A simple factor-3 approximation for labeling points with circles,” in Inform. Process. Letters, vol. 87(2), pp. 101– 105, 2003.

(29)

[10] T. Kato and H. Imai, “The np-completeness of the character placement problem of 2 or 3 degrees of freedom,” in In Record of Joint Conference of Electrical and

Electronic engineers in Kyushu., p. 1138, 1988.

[11] D. Knuth and A. Raghunathan, “The problem of compatible representatives,” in

SIAM Disc. Math., vol. 5(3), pp. 422–427, 1992.

[12] T. S. M. van Kreveld and A. Wolff, “Point labeling with sliding labels,”

Computa-tional Geometry: Theory and Applications, vol. 13, pp. 21–47, 1999.

[13] C.-S. S. S. K. Kim and T.-C. Yang, “Labeling a rectilinear map with sliding labels,”

International Journal of Computational Geometry and Applications, vol. 11, no. 2,

pp. 167–179, 2001.

[14] J. Marks and S. Shieber, The computational complexity of cartographic label

place-ment, Technical Report TR-05-91. Harvard University CS, 1991.

[15] T. Strijk and A. Wolff, “Labeling points with circles,” International Journal of

Com-putational Geometry and Applications, vol. 11, pp. 181–195, April 2001.

[16] F. Wagner and A. Wolff, “A practical map labeling algorithm,” Computational

Ge-ometry: Theory and Applications, vol. 7, pp. 387–404, 1997.

[17] J. M. J. Christensen and S. Shieber, “An empirical study of algorithms for point feature label placement,” in ACM Transactions on Graphics, vol. 14(3), pp. 203– 232, 1995.

[18] M. v. K. Pankaj K. Agarwal and S. Suri, “Label placement by maximum indepen-dent set in rectangles,” in Computational Geometry: Theory and Applications 11, pp. 209–218, 1998.

[19] S. M. S. R. P. Berman, B. DasGupta, “Efficient approximation algorithms for tiling and packing problems with rectangles,” Journal of Algorithms, vol. 41, pp. 443– 470, 2001.

[20] T. M. Chan, “A note on maximum independent sets in rectangle intersection graphs,” in Inform. Process. Letters, vol. 89, pp. 19–23, 2004.

(30)

[21] B. Z. C.K. Poon and F. Chin, “A polynomial time solution for labeling a rectilinear map,” in Information Processing Letters, vol. 65(4), pp. 201–207, 1998.

[22] T. Strijk and M. van Kreveld, “Labeling a rectilinear map more efficiently,” in

(31)

Appendix I : Example of R-map

The following are the illustrations of the growing incomparable points number.

(32)

Figure I.2: Illustration of the growing incomparable points number (2)

(33)

Figure I.4: Illustration of the growing incomparable points number (4)

(34)

Figure I.6: Illustration of the growing incomparable points number (6)

(35)

Figure I.8: Illustration of the growing incomparable points number (8)

(36)

Figure I.10: Illustration of the growing incomparable points number (10)

(37)

Appendix II : Experimental Codes

The following is the experimental codes. #include <stdio.h> #include <stdlib.h> #include <time.h> struct data{ int card; int anchor; int x; int y;

struct data prev; struct data next; };

struct fourcard{ int total; int level;

struct data head; struct data tail; };

struct data node list head, node list tail; struct fourcard level ptr[4];

int anchor array[30000]; void init level(void){

(38)

for (i=0;i<4;i++){

level ptr[i] = malloc(sizeof(struct fourcard)); level ptr[i]->total=0; level ptr[i]->level=i+1; level ptr[i]->head=NULL; level ptr[i]->tail=NULL; } }

void special init(int x, int y){ int i;

struct data node = malloc(sizeof(struct data)); for (i=0;i<4;i++){

level ptr[i] = malloc(sizeof(struct fourcard)); level ptr[i]->total=0; level ptr[i]->level=i+2; level ptr[i]->head=NULL; level ptr[i]->tail=NULL; } node->card = 2; node->anchor = 0; node->x = x; node->y = y; node->prev = NULL; node->next = NULL; level ptr[0]->total++; level ptr[0]->head = node; level ptr[0]->tail = node; }

(39)

void incre level(void){ int i; struct data tmp1, tmp2; tmp1 = level ptr[0]->head; while (tmp1){ tmp2 = tmp1; tmp1 = tmp1->next; } for (i=0;i<3;i++){

level ptr[i]->total = level ptr[i+1]->total; level ptr[i]->level = level ptr[i+1]->level; level ptr[i]->head = level ptr[i+1]->head; level ptr[i]->tail = level ptr[i+1]->tail; }

level ptr[3]->total = 0;

level ptr[3]->level = (level ptr[2]->level)+1; level ptr[3]->head = NULL;

level ptr[3]->tail = NULL; }

void incre2 level(void){ int i;

for (i=0;i<2;i++){

level ptr[i]->total = level ptr[i+2]->total; level ptr[i]->level = level ptr[i+2]->level; level ptr[i]->head = level ptr[i+2]->head; level ptr[i]->tail = level ptr[i+2]->tail; }

level ptr[2]->total = 0;

level ptr[2]->level = level ptr[0]->level+2; level ptr[2]->head = NULL;

(40)

level ptr[2]->tail = NULL; level ptr[3]->total = 0;

level ptr[3]->level = level ptr[1]->level+2; level ptr[3]->head = NULL;

level ptr[3]->tail = NULL; }

int find level(struct data node){ int i;

for (i=0;i<4;i++){

if (level ptr[i]->level == node->card) return i;

}

return -1; }

int region(struct data node, int anchor){ if (anchor < node->y)

return 2;

else if (anchor >= node->x) return 0;

else

return 1; }

int opera(struct data node, int anchor, int label){ if (anchor < node->y)

return 0;

else if (anchor >= node->x){

if ((anchor-label < node->x) && (anchor-label >= node->y)) return 99;

(41)

else if (anchor-label >= node->x) return 1; else return 11; } else{ if (anchor-label < node->y) return 22; else return 2; } }

struct data operax(struct data node, int anchor, int label){ struct data tmp = malloc(sizeof(struct data));

tmp->anchor = anchor; tmp->card = node->card+1; tmp->prev = NULL; tmp->next = NULL; tmp->y = node->y; if ((anchor-label) >= node->x) tmp->x = anchor; else tmp->x = anchor+label; return tmp; }

struct data operay(struct data node, int anchor, int label){ int temp;

(42)

tmp->anchor = anchor; tmp->card = node->card+1; tmp->prev = NULL; tmp->next = NULL; tmp->x = node->x; if ((anchor-label) >= node->y) tmp->y = anchor; else tmp->y = anchor+label; if (tmp->x < tmp->y){ temp = tmp->x; tmp->x = tmp->y; tmp->y = temp; } return tmp; }

void del node(struct data node){ int i = find level(node); int j;

if (i == -1){

printf(”find level return -1 !!!\n”); exit(1);

}

if (level ptr[i]->total == 1){ level ptr[i]->head = NULL; level ptr[i]->tail = NULL; }

else if (node == level ptr[i]->head){

level ptr[i]->head = level ptr[i]->head->next; level ptr[i]->head->prev = NULL;

(43)

}

else if (node == level ptr[i]->tail){

level ptr[i]->tail = level ptr[i]->tail->prev; level ptr[i]->tail->next = NULL;

} else{ node->prev->next = node->next; node->next->prev = node->prev; } level ptr[i]->total–; }

int tune node(int anchor){ int reg;

struct data tmp, tmp1, tmp2, tmp3, tmp4; tmp3 = level ptr[2]->head;

tmp4 = level ptr[3]->head;

if (tmp4 && (region(tmp4, anchor) == 0)){ incre2 level();

return 1; }

if (tmp3 && (region(tmp3, anchor) == 0)){ incre level(); return 1; } tmp1 = level ptr[0]->head; tmp2 = level ptr[1]->head; while(tmp2){

reg = region(tmp2, anchor); while (tmp1){

(44)

tmp = tmp1; tmp1 = tmp1->next; if (reg == 0){ if (tmp->x >= tmp2->y) del node(tmp); } else if (reg ==1){ if (tmp->x >= tmp2->x) del node(tmp); } } tmp2 = tmp2->next; } tmp1 = level ptr[0]->head; tmp2 = level ptr[1]->head; tmp3 = level ptr[2]->head; while (tmp3){

reg = region(tmp3, anchor); while (tmp2){

tmp = tmp2;

tmp2 = tmp2->next; if (reg == 0){

printf(”increase level twice (in tmp2)!!!\n”); exit(1); } else if (reg == 1){ if (tmp->x >= tmp3->x) del node(tmp); } } while (tmp1){

(45)

tmp = tmp1;

tmp1 = tmp1->next; if (reg == 0){

printf(”increase level twice (in tmp1)!!!\n”); exit(1); } else if (reg == 1){ if (tmp->x >= tmp3->x) del node(tmp); } } tmp3 = tmp3->next; } tmp1 = level ptr[0]->head; tmp2 = level ptr[1]->head; tmp3 = level ptr[2]->head; tmp4 = level ptr[3]->head; while (tmp4){

reg = region(tmp4, anchor); while (tmp3){

tmp = tmp3;

tmp3 = tmp3->next; if (reg == 0){

printf(”increase 2 levels twice (in tmp3)!!!\n”); exit(1); } else if (reg == 1){ if (tmp->x >= tmp4->x) del node(tmp); } }

(46)

while (tmp2){ tmp = tmp2;

tmp2 = tmp2->next; if (reg == 0){

printf(”increase 2 levels twice (in tmp2)!!!\n”); exit(1); } else if (reg == 1){ if (tmp->x >= tmp4->x) del node(tmp); } } while (tmp1){ tmp = tmp1; tmp1 = tmp1->next; if (reg == 0){

printf(”increase 2 levels twice (in tmp1)!!!\n”); exit(1); } else if (reg == 1){ if (tmp->x >= tmp4->x) del node(tmp); } } tmp4 = tmp4->next; } return 0; }

void replace node(struct data a, struct data b){ b->prev = a->prev;

(47)

if (a->prev)

a->prev->next = b; if (a->next)

a->next->prev = b; }

void add node(struct data node){ int i;

struct data tmp; node->prev = NULL; node->next = NULL;

if (node->card > level ptr[3]->level) incre level();

i = find level(node);

if (level ptr[i]->total == 0){ level ptr[i]->head = node; level ptr[i]->tail = node; level ptr[i]->total++; }

else if (node->x < level ptr[i]->head->x){ node->next = level ptr[i]->head;

level ptr[i]->head->prev = node; level ptr[i]->head = node;

level ptr[i]->total++; tmp = level ptr[i]->head;

while ((tmp->next) && (tmp->y <= tmp->next->y)) del node(tmp->next);

(48)

}

else if (node->x > level ptr[i]->tail->x){ if (node->y < level ptr[i]->tail->y){

node->prev = level ptr[i]->tail; level ptr[i]->tail->next = node; level ptr[i]->tail = node; level ptr[i]->total++; } } else{ tmp = level ptr[i]->head; while(tmp){ if (tmp->x == node->x){ if (tmp->y > node->y){ tmp->y = node->y;

while ((tmp->next) && (tmp->y <= tmp->next->y)) del node(tmp->next);

} return; }

else if (node->x < tmp->next->x){ if (tmp->y > node->y){ node->prev = tmp; node->next = tmp->next; tmp->next->prev = node; tmp->next = node; level ptr[i]->total++; tmp = node;

while ((tmp->next) && (tmp->y <= tmp->next->y)) del node(tmp->next);

} return;

(49)

}

tmp = tmp->next; }

} }

void add to node list(struct data node){ if (node list tail == NULL){

node list head = node; node list tail = node;

node list tail->next = NULL; }

else {

node list tail->next = node; node->prev = node list tail; node list tail = node;

node list tail->next = NULL; }

}

void gen node list(int anchor, int label){ int i,oper;

struct data tmp;

node list head = NULL; node list tail = NULL; for (i=0;i<4;i++){

tmp = level ptr[i]->head; while (tmp){

oper = opera(tmp, anchor, label); if (oper == 99){

(50)

add to node list(operax(tmp, anchor,label)); add to node list(operay(tmp, anchor,label)); del node(tmp);

}

else if (oper == 1){

add to node list(operax(tmp, anchor,label)); del node(tmp);

}

else if (oper == 11){

add to node list(operax(tmp, anchor,label)); }

else if (oper == 2){

add to node list(operay(tmp, anchor,label)); del node(tmp);

}

else if (oper == 22){

add to node list(operay(tmp, anchor,label)); }

tmp = tmp->next; }

} }

void process anchor array(int offset, int anchor, int label, int rate, int sid){ int i;

for (i=0;i<5000;i++) anchor array[i] = 0; for (i=0;i<(anchorrate);i++){

srand(time(NULL)+i+sid);

anchor array[(rand()%anchor)+offset] = (rand()%label); }

(51)

if (anchor array[i])

printf(”%2d : %d\n”,i,anchor array[i]); }

}

void node list to level(void){ int i=0;

struct data tmp;

while (node list head){ tmp = node list head;

node list head = node list head->next; add node(tmp);

}

node list head = NULL; node list tail = NULL; }

void print table(void){ int i,j;

struct data tmp; for (i=0;i<4;i++){

if (level ptr[i]->total == 5) printf(”!!!!!!!!!\n”);

else if (level ptr[i]->total == 6) printf(”@@@@@@@@@\n”); else if (level ptr[i]->total == 7)

printf(”777777777\n”); else if (level ptr[i]->total == 8)

printf(”888888888\n”); else if (level ptr[i]->total == 9)

(52)

else if (level ptr[i]->total > 9) printf(”orzorzorz\n”);

printf(”%d(%d) : ”,level ptr[i]->level,level ptr[i]->total); if (level ptr[i]->total){ j = 0; tmp = level ptr[i]->head; while(tmp){ printf(” (%2d,%2d)”, tmp->x, tmp->y); tmp = tmp->next; j++; } if (j != level ptr[i]->total) printf(”\nXXXXXXXXXXXXX”); } printf(”\n”); } }

void array to node list(int anchor number){ int i,j;

struct data tmp;

for (i=0;i<anchor number;i++){ if (anchor array[i]){

if (tune node(i)) tune node(i);

printf(”\n=== %d(%d)\n”, i, anchor array[i]); print table();

gen node list(i,anchor array[i]); tmp = node list head;

printf(”———————–\n”); while(tmp){

(53)

printf(”%d(%d,%d) ”,tmp->card,tmp->x,tmp->y); tmp = tmp->next;

}

printf(”\n”);

printf(”———————–\n”); node list to level();

print table(); }

} }

void input spec(void){

struct data node1, node2, node3, node4, node5; int i;

node1 = malloc(sizeof(struct data)); node2 = malloc(sizeof(struct data)); node3 = malloc(sizeof(struct data)); node4 = malloc(sizeof(struct data)); node5 = malloc(sizeof(struct data)); for (i=0;i<4;i++){

level ptr[i] = malloc(sizeof(struct fourcard)); level ptr[i]->total = 0;

level ptr[i]->level = i+88; level ptr[i]->head = NULL; level ptr[i]->tail = NULL; } node1->prev = NULL; node1->next = NULL; node1->card = 89; node1->anchor = 12; node1->x = 13; node1->y = 12;

(54)

add node(node1); node2->prev = NULL; node2->next = NULL; node2->card = 89; node2->anchor = 12; node2->x = 16; node2->y = 9; add node(node2); node3->prev = NULL; node3->next = NULL; node3->card = 89; node3->anchor = 12; node3->x = 24; node3->y = 2; add node(node3); node4->prev = NULL; node4->next = NULL; node4->card = 90; node4->anchor = 12; node4->x = 24; node4->y = 16; add node(node4); node5->prev = NULL; node5->next = NULL; node5->card = 90; node5->anchor = 12; node5->x = 27; node5->y = 12; add node(node5); } int

(55)

main(int argn, char argv[]){ int i,j; if (argn!=9){ printf(”bad arguments!!\n”); return; } j = atoi(argv[7]); for (i=atoi(argv[6]);i>0;i–){ if (atoi(argv[1]) < atoi(argv[2])){

process anchor array(atoi(argv[1]),atoi(argv[3]),atoi(argv[4])/j,atoi(argv[5]),i); if (atoi(argv[8])==0)

special init(atoi(argv[2]), atoi(argv[1])); else

input spec(); }

else{

process anchor array(atoi(argv[2]),atoi(argv[3]),atoi(argv[4])/j,atoi(argv[5]),i); if (atoi(argv[8])==0)

special init(atoi(argv[1]), atoi(argv[2])); else input spec(); } j–; if (j==0) j = atoi(argv[7]);

array to node list(atoi(argv[3])); printf(”\n\n\n\n”);

} return; }

數據

Figure 1.1: Illustration of 2PV, 2PH, 4P, and 4S models.
Figure 2.1: Example of maximizing the number of labeled points.
Figure 2.2: Example of the R-map.
Figure 3.1: (a) Example of incomparability between realizations resulting from placing labels 1 and 3
+7

參考文獻

相關文件

Teachers may consider the school’s aims and conditions or even the language environment to select the most appropriate approach according to students’ need and ability; or develop

Now, nearly all of the current flows through wire S since it has a much lower resistance than the light bulb. The light bulb does not glow because the current flowing through it

Given a connected graph G together with a coloring f from the edge set of G to a set of colors, where adjacent edges may be colored the same, a u-v path P in G is said to be a

Microphone and 600 ohm line conduits shall be mechanically and electrically connected to receptacle boxes and electrically grounded to the audio system ground point.. Lines in

“Since our classification problem is essentially a multi-label task, during the prediction procedure, we assume that the number of labels for the unlabeled nodes is already known

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005..

The well-known halting problem (a decision problem), which is to determine whether or not an algorithm will terminate with a given input, is NP-hard, but

• If we know how to generate a solution, we can solve the corresponding decision problem. – If you can find a satisfying truth assignment efficiently, then sat is