Computing the Smallest Color-Spanning Equaliteral Triangle

EuroCG 2015, Ljubljana, Slovenia, March 16–18, 2015
Computing the Smallest Color-Spanning Equaliteral Triangle
Javad Hasheminejad∗
Payam Khanteimouri
Abstract
Let P be a set of n colored points with k colors in
the plane. A region is color-spanning if it contains
at least one point from each color. In this paper, we
study the problem of computing the smallest colorspanning equilateral triangle whose one side is parallel to x-axis. We first show that the number of the
minimal color-spanning equilateral triangles is O(n)
in the worst case. Then, we present an efficient algorithm running in O(n log n) time to solve the problem. Finally, we show that our algorithm can be
used to compute a 2-approximation of the smallest
perimeter color-spanning convex hull which is the first
subquadratic time algorithm with approximation factor 2.
1
Introduction
Background. In many practical problems in computational geometry, the input points are imprecise.
An imprecise point can be defined by a region where
the exact location of the point can be anywhere inside the region [7]. In a case that an imprecise point
is modeled with a discrete range such as a point set,
each imprecise point can be represented by a set of
points which determines all possible locations of that
point. Therefore, by assigning a distinct color to each
imprecise point, a set of k imprecise points can be
modeled by n points with k colors, where n is the
number of possible locations for all imprecise points.
In this point of view, the problem is to choose exactly
k points with different colors in such a way that a geometric structure e.g. convex hull, diameter, bounding box, etc. gets minimized or maximized —see [5]
and references therein. Furthermore, we have similar
models in other areas such as facility location, statistical clustering, pattern recognition and generalized
range searching [1, 3, 8].
Related works. Suppose we are given a set of n
points with k colors in the plane. A region is said
to be color-spanning if it contains at least one point
from each color. Abellanas et al. [1] presented an algorithm to compute the smallest color-spanning axisparallel rectangle in O(n(n − k) log2 k) time. The
problem of computing the smallest color-spanning circle can be solved in O(nk log n) time using the up∗ Department
of Mathematics and Computer Science,
Amirkabir University of Technology, Iran
32
∗
Ali Mohades
∗
per envelope of Voronoi surfaces [4]. In addition,
Khanteimouri et al. [6] presented an O(n log2 n) time
algorithm to compute the smallest color-spanning
axis-parallel square. Moreover, For the problem of
computing the smallest perimeter color-spanning convex hull, Ju et al. [5] showed the NP-hardness of the
problem, and they proposed a π-approximation algorithm running
in O(n2 +nk log k) time. They also pro√
posed a 2-approximation algorithm for the problem
running in the same time of computing the smallest
color-spanning rectangle.
Our Results. In this paper, we study the problem
of computing the smallest color-spanning equilateral
triangle whose one side is parallel to x-axis (SCST,
for short). Beside the applications of this problem in
location planning, the perimeter of the SCST approximates the perimeter of the smallest color-spanning
convex hull. In Section 2, we first show that there are
O(n) minimal color-spanning triangles in the worst
case. Then, we present an O(n log n) time algorithm
to compute the SCST. Next in Section 3, we show that
the perimeter of the SCST gives a 2-approximation
for the perimeter of the smallest color-spanning convex hull which significantly improves the first result
presented in [5]. In fact, no subquadratic time algorithm with approximation factor 2 was known before.
Finally, we conclude in Section 4.
2
Computing the Smallest Color-Spanning Equilateral Triangle
In this section, we focus on the problem of computing
the smallest color-spanning equilateral triangle whose
base is parallel to the x-axis. We start by some preliminaries and definitions.
2.1
Preliminaries and Definitions
Let S = {s1 , · · · , sn } be a set of points in the plane.
• For a point si ∈ S, wedge of si is the portion of
the plane√restricted between two half-lines with
slopes ± 3 starting from si towards increasing
y-coordinates—see Figure 1-(a). We denote the
wedge of si by W(si ).
• We say si dominates sj if and only if W(si ) ⊆
W(sj ). A point si is maximal if it is not dominated by any other point in S.
This is an extended abstract of a presentation given at EuroCG 2015. It has been made public for the benefit of the community and should be considered a
preprint rather than a formally reviewed paper. Thus, this work is expected to appear in a conference with formal proceedings and/or in a journal.
31st European Workshop on Computational Geometry, 2015
• For a set of m functions F = {f1 , · · · , fm } we
define LF as the lower envelope of F. Precisely, LF (x) = minf ∈F f (x). Similarly, UF =
maxf ∈F f (x) denotes the upper envelope of F.
Figure 3: Two types of a minimal color-spanning equilateral triangle.
(a)
(b)
Figure 1: (a) The wedge of point si . (b) si dominates
point sj .
Now, let P = P1 ∪ P2 · · · ∪ Pk be the given set of n
points with k colors in the plane where Pi is the set
of points with color i.
• We define Li as the lower envelope of color i
which is the lower envelope of boundaries of W(p)
for all p ∈ Pi .
• Li consists of mountains and valleys. In fact, a
valley is a point in Pi that does not dominate
any other point of Pi and a mountain is a local maximum point which appears between two
consecutive valleys. In addition, we define two
additional mountains at −∞ and +∞ for each
Li —see Figure 2 for more illustration.
We first show a new view of a color-spanning triangle whose base lies on some horizontal line l. Let
Pl ⊆ P be the subset of points above l and L =
{L1 , · · · , Lk } be the set of lower envelopes of all colors for the points in Pl . Moreover, let R be the region
above the upper envelope UL . We present the following lemma.
Lemma 1 An equilateral triangle T whose base lies
on line l is color-spanning if and only if its apex belongs to R.
Proof. Let p0 be some point in Pl . Clearly, triangle
T with base on l contains p0 if and only if its apex
belongs to W(p0 ). Since the region above Li is the
union of all wedges of points with color i, the triangle T with apex located at a point above Li contains
at least one i-colored point. From the fact that R is
the intersection of regions above Li for all i, we conclude that T is color-spanning if its apex belongs to R.
The converse implication can be proved in a similar
way.
Now, suppose we sweep the points with line l.
When the sweep line l crosses a new point p ∈ P
with color i, the insertion of p changes the structure Li —see Figure 4. Thus, the upper envelope may
also be changed. To see the relation between minimal
color-spanning triangles and the upper envelope of described structures, we present the following lemma.
Additional
Mountains
Mountain
Valley
eliminated part
Figure 2: The mountains and valleys on Li .
• A minimal color-spanning object contains at least
one point from each color and any sub-region of
it does not contain all colors. We can assume
without loss of generality that a minimal colorspanning equilateral triangle with the base parallel to x-axis (minimal CST, for short) is defined
with two or three points with unique colors on its
edges, as illustrated in Figure 3.
2.2
Algorithm
We now present our algorithm to compute the SCST.
The sketch of our algorithm is as follows. We sweep
the points with a horizontal line l from top to bottom and we test all minimal CSTs when an insertion
occurs.
Figure 4: The apex of a minimal CST is placed on a
valley point of UL .
33
EuroCG 2015, Ljubljana, Slovenia, March 16–18, 2015
Lemma 2 A triangle T with apex q is a minimal CST
if and only if q appears for the first time as a valley
point on some UL during the plane sweep.
Proof. Consider the event that l encounters the point
p with color i and q appears as a valley point on UL
for the first time. Let T be the triangle defined by the
apex q with base on l. As q belongs to UL , triangle T
is color-spanning according to Lemma 1. To conclude
that T is minimal, we first show that p is the unique
point with color i included in T . Since q appeared
for the first time, therefore q belongs to W(p) and
T contains p on its bottom edge. Besides, since q
appeared for the first time, it must be a point below
the structure Li before the insertion of point p. Thus,
T could not contain any point of color i just before
the time l reaches p. On the other hand, each valley
point of UL can be either a valley of some Lj or an
intersection point of Lj and Lt for some colors j and
t—see Figure 4. These cases determine the two types
of minimal CSTs which are illustrated in Figure 3.
We can simply prove the converse implication in a
similar way, but we omit the details due to the space
constraint.
Therefore, we can state that the number of minimal CSTs is equal to the number of distinct valleys
that are created on UL during the plane sweep process. Although there is a configuration of points P
in which the lower envelops Li intersect each other in
Ω(nk) points, we show that only O(n) distinct valley
points can appear on UL . Let appi be the number of
mountains that appear for the first time on UL when
l reaches point pi . Similarly, let deli be the number
of deleted mountains. We first present the following
lemma.
Lemma 3 The number of newly appeared valleys is
at most deli + appi when l crosses point pi .
Proof. We can partition the set of newly appeared
mountains into m components of consecutive mountains of UL , as illustrated in Figure 5. Each component should be placed under at least one deleted
mountain. It is easy to see that the number of newly
appeared valleys that are located among these components is at most appi + m—see Figure 5. In addition, there could be some deleted mountains such
that there is not any newly appeared mountain below
them. The number of this type of deleted mountains
is at most deli − m. We can simply show that the
number of newly appeared valleys of this type is at
most deli − m. Therefore, since a deleted mountain
never reappears we conclude the lemma.
From the fact that each point pi creates exactly
two new mountains on Li the total number of created
34
Two components
Figure 5: Squares and filled circles indicate respectively the newly appeared and the deleted mountains.
mountains during the sweep process is 2n. Moreover,
each mountain can appear on UL and is deleted once.
Thus, we conclude the following lemma according to
Lomma 3.
Lemma 4 There are O(n) minimal CSTs in the
worst case.
Brodal et al. [2] presented a data structure to maintain the planar maximal points with O(log n) worst
case time per insertion or deletion. They define
that a point p = (px , py ) dominates another point
q = (qx , qy ) if inequalities px ≥ qx and py ≥ qy hold.
Moreover, they showed their data structure allows reporting the maximal points that dominate a given
query point q in O(log n + r) time, where r is the
number of reported points.
It is easy to see that we can adopt the definition of
maximal points used in this paper with the one defined in [2]. Furthermore, to maintain the upper envelope UL it suffices to maintain the maximal points
of mountains instead of the original points. A valley
on UL can be obtained by two consecutive maximal
mountain points. We exploit the data structure presented in [2] to perform the insertion and deletion of
mountains. Moreover, we use a maximal reporting
query to obtain the newly appeared valleys. In the
following we explain the details.
Consider the event that l passes point p with color
i. First, we intersect the boundary of W(p) with Li .
Let s and t be the intersected points such that sx ≤ tx
(s or t may be equal to −∞ and +∞ respectively).
Moreover, let Q = {q1 , · · · , qm } be the sorted list of
points that appear on Li from s to t. First, we do
the insertions of mountains s and t. Now, to perform
the deletion of point qi and report the newly appeared
valleys we do as follows. As the first case, suppose qi
is not a point of UL . In this case, we only perform
a deletion of qi and no new valley gets reported. In
the other case, qi is a maximal mountain point. To
report the new valleys that appear by deletion of qi ,
we first compute the query point qi0 by finding the two
adjacent mountains of qi on UL —see Figure 6. Then,
we perform a deletion of qi from the data structure
and perform a maximal reporting with query point qi0
to compute the newly appeared valleys. Therefore,
we present the following theorem.
31st European Workshop on Computational Geometry, 2015
(after update)
the perimeter of T 0 —consider the equilateral triangle
with vertices placed at the middle points of T 0 edges.
Therefore, inequalities P (CH ∗ ) ≥ 21 P (T 0 ) ≥ 12 P (T )
also hold and we conclude that the SCST computes a
2-approximation of SCSCH.
4
Figure 6: Updating the upper envelope UL and reporting the newly appeared valleys.
Theorem 5 For a given set of n points with k colors
in the plane, the problem of computing the SCST can
be solved in O(n log n) time.
In this paper, we presented a novel idea to solve the
problem of computing the SCST. We first proved that
there are O(n) minimal CSTs. Then, we proposed
an O(n log n) time algorithm to compute the SCST
which exploits the data structure presented in [2]. Finally, we showed that a 2-approximation of the SCSCH can be computed in O(n log n) time by finding
the SCST which significantly improves one of the earlier results.
References
[1] Abellanas, M., Hurtado, F., Icking, C., Klein,
R., Langetepe, E., Ma, L., Palop, B., Sacrist´an,
V.: Smallest Color-Spanning Objects. Proc. European Symp. Algorithms (ESA-2001), LNCS 2161, (2001) 278–289.
Proof. We can compute s and t by performing a binary search in the sorted list of Li in O(log n) time.
Since there are totally 2n mountains, all insertions
and deletions take O(n log n) time. On the other
hand, the data structure presented in [2] allows us to
compute each query point qi0 in O(log n) time. Since
we perform O(n) queries in such a way that each minimal CST gets reported only once, we conclude from
Lemma 4 that the query takes O(n log n) time in total. Therefore, the running time of the algorithm is
O(n log n).
3
Conclusion
[2] Brodal, G. S., Tsakalidis, K.: Dynamic Planar Range Maxima Queries. In Automata, Languages and Programming. Springer Berlin Heidelberg (2011) 256–267.
[3] Gupta, P., Janardan, R., Smid, M. H. M.: Further Results on Generalized Intersection Searching Problems: Counting, Reporting, and Dynamization. J. Algorithms. 19 2 (1995) 282–317.
Approximating the Smallest Perimeter ColorSpanning Convex Hull
[4] Huttenlocher, D. P., Kedem, K., Sharir, M.: The
Upper Envelope of Voronoi Surfaces and Its Applications. Discrete Computational Geometry. 9
(1993) 267–291.
In this section, we show that the SCST gives a constant factor approximation for the smallest perimeter
color-spanning convex hull (SCSCH, for short). The
problem of computing the SCSCH is to choose one
point from each color in such a way the perimeter of
convex hull of the selected points gets minimum. We
present the following theorem.
[5] Ju, W., Fan, C., Luo, J., Zhu, B., Daescu, O.:
On Some Geometric Problems of Color-Spanning
Sets. Journal of Combinatorial Optimization. 26
2 (2013) 266–283.
[6] Khanteimouri, P., Mohades, A., Abam, M. A.,
Kazemi, M. R.: Computing the Smallest ColorSpanning Axis-Parallel Square. In Algorithms
and Computation (ISAAC 2013), LNCS - 8283,
(2013) 634–643.
Theorem 6 There is a 2-approximation algorithm
for computing the SCSCH running in O(n log n) time.
Proof. Let T be the SCST computed by the algorithm described in previous section. Moreover, let
CH ∗ be the SCSCH. Since T is color-spanning there is
a convex hull CH inscribed in T . Therefore, inequalities P (CH ∗ ) ≤ P (CH) ≤ P (T ) hold, where P (.) denotes the perimeter function. On the other hand, let
T 0 be the smallest equilateral triangle which contains
CH ∗ . For the points included in T 0 , we can show by
primitive calculations that the perimeter of any convex hull that touches the edges of T 0 is at least half of
[7] L¨
offler, M.: Data Imprecision in Computational Geometry. Ph.D. Thesis. Utrecht University. (2009).
[8] Matouˇsek, J.: On Enclosing k Points by a Circle.
Inf. Process. Lett.. 53 4 (1995) 217–221.
35