#### Diameter partitioning

Discrete Comput Geom
David Avis 0
0 School of Computer Science , McGillUniversity,805 SherbrookeSt. W., Montreal , Canada , H3A2K6
We discuss the problem of partitioning a set of points into two subsets with certain conditions on the diameters of the subsets and on their cardinalities. For example, we give an O(n 2 log n) algorithm to find the smallest t such that the set can be split into two equal cardinality subsets each of which has diameter at most t. We also give an algorithm that takes two pairs of points (x, y) and (s, t) and decides whether the set can be partitioned into two subsets with the respective pairs of points as diameters.
1. Introduction
Consider a set of communications posts on a large plane. Each post is equipped
with a transmitter that can reach some distance t from the post. I f all the posts
are within distance t o f each other, all can communicate without difficulty.
Suppose, however, that some posts are further than t units apart. We would like
tO know if the posts can be split into two groups, so that within each g r o u p each
pair o f posts m a y communicate. In order to conserve energy, we wish to reduce
the power o f the transmitters as much as possible. Accordingly, what is the
smallest t for which such a partition into two groups is possible? In addition,
we m a y wish to impose criteria on the cardinality of the subsets: for example,
we may wish to make the subsets have equal cardinality.
The above problem is typical of a large class of problems that have been
studied recently, that concern the partitioning o f point sets. A closely related
problem is the m-centers problem. In this case, it is required to cover the point
set by a set o f m circles o f minimum radius [9], [13], [15]. Cardinality criteria
have also been much studied, motivated b y the generalized range search problem
in data retrieval. Various results have been obtained on the problem o f splitting
a set o f points in d dimensions b y a set o f intersecting hyperplanes, such that
each open region contains an equal or n e a r equal fraction of the points [2], [3],
[5], [16], [17]. A related problem is that o f finding subsets of cardinality k that
can be separated from the point set by a hyperplane. Even for d = 2 when the
hyperplane becomes a line, the problem o f finding the number o f such subsets
appears very diffficult [6], [8], [12].
In this paper, we combine cardinality criteria with criteria on the diameter of
the subsets, giving the problem mentioned in the first paragraph. Two major cases
arise depending on whether or not we require the subsets to be linearly separable.
Two subsets S and T of a planar point set P are linearly separable if there is a
line such that each subset lies in opposite half spaces b o u n d e d by the line. We
call a partition into S and Tbalanced if IS[ = [[P[/2J. As shown by the example
in Fig. 1, the minimum diameter balanced partition o f a point set may not be
separable. In this figure, both circles have unit radius. The only minimum balanced
partition is {Pl, ]72,P3, P4}, {Ps, P6, PT, P8}, and it is not separable. If we restrict
ourselves to separable partitions, we can find a minimum diameter balanced
partition in polynomial time by brute force. This follows from the fact that any
separating line can be rotated until it hits at least one point in S and one point
in T. Therefore we can effectively enumerate all separable subsets by choosing
all pairs o f points in the set and constructing the separating line through each
o f them. This yields an O(n 3 log n) algorithm, since it takes O(n log n) time to
find the diameters o f the two subsets [14]. For the nonseparable case, no obvious
brute force approach suggests itself.
The main results o f this paper are contained in the next three sections. In
Section 2 we present an efficient algorithm for finding the minimum diameter
balanced partition in the case where the subsets need not be separable. In Section
P ~ .
%
P4
P8
3 we consider the additional restriction that the subsets must be separable. Finally,
we consider a slightly different type of problem in Section 4. Here we are given
two candidate pairs of points for the diameters, and the problem is to decide
whether the point set can indeed be partitioned with these pairs as the diameters
o f the subsets. The techniques throughout are related: an appropriate graph is
defined and the geometric problem is transformed into an easily solvable graph
problem.
2.
Minimum Diameter Balanced Partitions
Let P = { p ~ , . . . ,Pn} be a set of points in Euclidean space. Let d ( p , pj) be the
distance between points Pi and p~. In this section we make no restrictions on the
distance function. For the application mentioned in the introduction Euclidean
distance is assumed. The diameter o f the set is denoted diam(P) and is defined
by
d i a m ( P ) =
max d ( p , pj).
l ~ i < j ~ n
For any real number t we consider the following predicate Qo(t):
P can be partitioned into subsets S and T such that max(diam(S), diam(T)) <- t.
Clearly Qo(t) is false if there exist three points in P which are all more than t
units apart. This suggests defining an auxiliary graph G, = (P, E,) on the point
set P, where (pi, Pj) is an edge in E, if and only if d (pi, pj) > t. Such a construction
is shown in Fig. 2. The following easy lemma gives a graph theoretic answer to
Qo(t).
P6
P2
P3
P5
P4
t
Lemma 2.1.
Qo( t) is true if and only if Gt is bipartite.
Proof. Suppose Qo(t) is true, and let S and T be the corresponding subsets.
Since max(diam(S), d i a m ( T ) ) < t, S and T are independent sets in Gt, that is,
no edge has both its endpoints in the same subset. Therefore Gt is bipartite.
Conversely, if Gt is bipartite, let S and T be the two parts. Since they are
independent, Qo(t) holds. []
We are interested in finding the smallest value of t such that Qo(t) is true.
Clearly if Qo(t) is true, then so is Qo(t') for any t ' - t. Furthermore, the minimum
value of t for which Qo(t) is true is a distance d(pi, pj) for some i and j. (The
diameter o f the larger subset gives such a pair, for example.) This suggests the
following algorithm, which will later be extended to solve several problems. The
algorithm employs a binary search on the sorted set of distances between the n
points.
Algorithm M I N - D I A M ( P )
1. Sort the distances d(pi, pj) into increasing order: dl < d2 -<" • • < ~dt~).
2. Set u = n ; l : = l ;
while u -> l do
begin
Set m = [ ( u + l ) / 2 ] ; t = d , , ;
Construct G,;
if T E S T - G R A P H - 1 ( Gt) then u = m - 1 else l = m + l
end;
if not T E S T - G R A P H - 1 (Gt) then t = d,,+l;
return (t).
Algorithm M I N - D I A M is a straightforward binary search to find the minimum
diameter partition. The procedure TEST-GRAPH-1 is a Boolean procedure that
returns true if the graph G, is bipartite. Such a procedure is easily implemented
by depth first search [1] in time proportional to the number of edges in the graph.
Step 1 of M I N - D I A M takes O(n21og n) time. The while loop in step 2 is
performed at most O(log n) times. Each call to TEST-GRAPH-1 takes at most
O(n 2) time. Therefore the overall complexity of M I N - D I A M is O(n 2 log n) time.
The subsets produced by algorithm M I N - D I A M will not in general be
balanced. For real t and integer k we define the predicate Q(t, k):
P can be split into sets S and T such that
(i) max(diam(S), d i a m ( T ) ) < t and (ii) IS[ = k.
Of particular interest is the case k = [n/2J. Along the lines of Lemma 2.1 we
have the following lemma.
Lemma 2.2.
Q(t, k) is true if and only if Gt has a bipartition (S, T) with IS I = k.
If Gt is connected then there is a unique bipartition, but if it is disconnected,
there may be exponentially many different bipartitions. Suppose that Gt has m
connected c o m p o n e n t s . E a c h o f these c o m p o n e n t s is bipartite and we will denote
each by the bipartition (S~, T~), i = 1 , . . . , m. N o t e that St = O or T~= O is possible.
Figure 2 illustrates the case m = 2 . H e r e S ~ = { p l } , TI={p4,p~} and $2={p6},
T2 = {P2, P3}. It can be seen that Q(t, k) is true if there are binary values x ~ , . . . , x,,
so that
In general, it is an N P - c o m p l e t e p r o b l e m to solve equations o f type (1) [10].
However, in our case, all o f the data are b o u n d e d by n and so (1) can be solved
in O ( n 2) time by a so-called p s e u d o p o l y n o m i a l time algorithm. We outline the
p r o c e d u r e below in TEST-GRAPH-2 (Gt, k). The idea o f this algorithm is as
follows. We consider which sums o f form (1) are possible using c o m p o n e n t s
(S~, T1), ($2, T2), . . . , (Si, T~), for each i = 1, 2 , . . . , m. This is d o n e sequentially.
For i = 1 the only sums possible are for k = s~ or k = tl. I f a sum o f value j can
be o b t a i n e d using the first i c o m p o n e n t s , then sums o f value j + s~+l and j + t~+l
are o b t a i n a b l e using the first i + 1 c o m p o n e n t s . The sums are r e c o r d e d using the
array w. After the ith iteration, w[j] = 1 if and only if the sum j can be o b t a i n e d
by a pactition o f the first i c o m p o n e n t s . Clearly, we do not need to record w[j]
for j greater than k. W h e n u p d a t i n g the array w, we u p d a t e in decreasing order
by subscript so as not to destroy i n f o r m a t i o n a b o u t the previous iteration until
it is no longer o f value. T h e array f lag is used to record the c o m p o s i t i o n o f the
partial sums. This is to allow the construction o f the actual partition if the
algorithm terminates successfully. A s s u m e at iteration i - 1 a partial sum o f value
j can be constructed. T h e n at iteration i we can construct sums o f value j~ = j + s~
and J2 = j + t~. We record h o w these new sums are constructed by setting
respectively f lag[ i, j~] = " S " a n d flag[ i,j2] = " T " . Later, we describe h o w f l a g is used
to construct the partition,
Algorithm TEST-GRAPH-2 ( Gt, k)
1. Find connected c o m p o n e n t s (Si, T~), i = 1. . . . , m.
set s,=lS, I, tt =IT~I, i = l , . . . , m .
set w [ i ] = 0 , i = 0 , . . . , k;
set w[sl] = 1, w[h] = 1, f l a g [ l , sl] = " S " , f l a g [ l , tl] = " T " ;
2. for i = 2 t o m d o
for j = k to 0 do
if w[j] = 1 then
begin
w [ j ] = 0 ;
Jl = j + s ~ ;
j 2 = j + t,;
if jl <---k then w[j~] = 1, flag[i,j~] = " S " ;
i r A -< k then w[j2] = 1, flag[i, j2] = " T " ;
end;
3. if w[k] = 1 then return (true) else return (false).
The correctness of algorithm T E S T - G R A P H - 2 (Gt, k) can be verified by
induction on m, the n u m b e r o f connected components. Our hypothesis is that
for O<--j-< k, w[j] = 1 if and only if there exists a bipartition (S, T) o f G, with
Isl =j. This is clearly true for m = 1. Assume that the hypothesis is true for
arbitrary m. Suppose Gt has m + 1 components. By hypothesis, after the algorithm
has executed the main for loop with i = m, the array w tells us exactly which
bipartitions are possible using the first m components of G,. Then there is a
bipartition of Gt with ISl--j if and only if at this stage in the computation
w [ j - sin+t] = 1 or w [ j - t,,+~] = 1. Since the array w is processed in decreasing
order by subscript, this update can be done in place with no additional storage.
This completes the induction.
We now show how to construct a partition which obtains the value k whenever
such a partition exists. If f l a g [ m , k] = " S " then the last subset of vertices used
in constructing the partition was Sin, otherwise it was Tin. In the former case,
the penultimate subset of vertices used can be found by e x a m i n i n g f l a g [ m - 1, k
s,,]. In the latter case, we examine f l a g [ m - 1 , k - t o , ] . Repeating in this way,
we can trace the entire partition in m steps.
The modified algorithm T E S T - G R A P H - 2 still runs in O(n 2) time. Thus we
are able to test the predicate Q(t, k) in time 0(0 2) time. Using it in procedure
M I N - D I A M in place o f T E S T - G R A P H - 1 therefore gives an O ( n 2 1 o g n )
algorithm for finding the m i n i m u m diameter balanced partition o f P. This proves
T h e o r e m 2.3.
Theorem 2.3. A minimum diameter balanced partition of a planar point set can
be found in time O( n 2 log n).
Minimum Diameter Separable Partitions
In this section we consider the problem o f partitioning a point set P into two
linearly separable point sets S and T with minimum diameter. We allow points
o f S and T to lie on the separating line, which we will denote /. For any real
n u m b e r t consider the following predicate Ql(t):
P can be partitioned into two separable subsets S and T such that
m a x ( d i a m ( S ) , d i a m ( T ) ) -< t.
We proceed as in Section 2 by defining the auxiliary graph Gt = (P, Et). We also
require the following definition. Let E be a set o f line segments in the plane. A
line l is a stabbing line for E if I intersects every line segment in E. Figure 3
illustrates the construction o f Gt and a stabbing line for the point set o f Fig. 1.
Observe that if Et has a stabbing line then Gt is bipartite. Therefore, corresponding
to L e m m a 2.1 we have the following.
Lemma 3.1.
Ql(t) is true if and only if there exists a stabbing line for Et.
An algorithm for finding a stabbing line for a set of m line segments in
O ( m log m) time has b e e n given by Edelsbrunner et al. [7]. For our problem,
0 p3
P6
_ __ __ Stabbing Line
P7
this gives an O(n 2 log n) bound for determining if E, has a stabbing line. We
may therefore test Q,(t) in O(nElog n) time. By using the algorithm
TESTGRAPH-3 (G,), algorithm M I N - D I A M may be used to find the smallest t such
that Q~(t) is true in time O(n 2 log n). This proves Theorem 3.2.
Theorem 3.2. A minimum diameter separable partition can be found in time
O(n 2 log 2 n).
Algorithm T E S T - G R A P H - 3 ( G, )
begin
if G, has a stabbing line then return (true)
else return (false)
end;
4. Specified Diameter Partitions
In this section we describe an algorithm that takes as input a point set P and
four distinct points Po, Pb, Pc, Pa of P. The algorithm finds a partition o f P into
subsets S containing pa, Pb and T containing Pc, I'd, such that diam(S) = d(pa, Pb)
and d i a m ( T ) = d ( p c , pd), or decides that such a partition does not exist. For
convenience throughout we assume that
d(pa, Pb) <- d(pc, Pa).
As in previous sections, our a p p r o a c h is to construct an auxiliary graph G =
(P, E ) , where (p~,pj) is an edge in E if and only if
d(p,, pj) > d ( p , , Pb).
We will also color the edges E green and black. Edge (Pi, Pj) is green if d ( p , pj)
<d(pc, Pd) and black otherwise. Then S and T is a valid partition of P if and only
if
(i) S is an independent set in G;
(ii) T only contains green edges.
Algorithm SPEC-DIAM(P, a, b, c, d)
1. set S'={po, pb}, T'={pe, pd};
set Q={Pa, Pb, Pc, Pd};
2. while Q # ~ begin
remove x from Q;
for every edge (x, y) e E do
begin
case {x e S'}
if y E S' then return (false)
else if y ~ T' then T' = T' u {y}, Q = Q u {y};
case {x e T' and (x, y) is black}
if y e T' then return (false)
else if y ~ S' then S' = S' u {y}, Q = Q u {y};
The correctness o f the algorithm depends on the following temmas. We say
that a step terminates successfully if the return (false) exit is not taken.
Lemma 4.1. I f step 2 of SPEC-DIAM terminates successfully:
(a) S' is an independent set in G;
(b) T' contains only green edges;
(c) every valid partition (S, T) of P satisfies S'~_ S, T ' ~ T.
Proof. Suppose that x, y e S' and (x, y) ~ E. Clearly {x, y} # {a, b}. Further, both
x and y must have been placed into Q at some time. Let x be the point first
considered in the while loop. At this stage, y is not in S otherwise SPEC.DIAM
would return false. But then y is put into T' by the first ease statement in the for
loop. Once a point is placed in either S' or T' it cannot be placed into the other
subset. Therefore (a) holds.
Suppose now that x, y E T', and (x, y) is a black edge. Therefore {x, y} # {c, d}.
Again let x be processed before y in the while loop. Then y is not in T' when x
is processed and so y is placed in S' and (b) holds.
It remains to verify (c). Obviously (c) is true when we begin to execute step
2. We need only verify inductively that as each new point is added to S' or T'
(c) remains true. But if a point about to be added to T' were put into S' condition
(1) would be violated, so that S could not be extended into a valid partition.
Similarly, if a point about to be added to S' were added to T', condition (ii)
would be violated. []
Lemma 4.2. I f step 2 of SPEC-DIAM terminates successfully:
(a) the only edges with exactly one endpoint in U are green;
(b) U induces a bipartite subgraph in G if and only if P has a valid partition.
Proof. Part (a) follows from the fact that every point in S ' u T' is at some time
placed in Q. The first case statement ensures that no edges go from S' to U; the
second case statement ensures that no black edges go from T' to U.
For part (b) we require the following definition.
Lane(p,,, Pb) = {x [max(d(x, pa), d(x, pb)) < d(p`,, pt,)}.
I f y e P and y is not in Lune(p`,, Pb) then y is adjacent to either Pa or Pb in G.
Since both p`, and Pb are considered in step 2, y must be put into T'. Therefore,
U ~ Lune(p`,, pt,).
This is illustrated in Fig. 5. Join p`, to Pb by a line segment splitting Lune(p`,, Pb)
into two regions L and R. For definiteness, we include the line segment in R.
Now it is easily verified that if (x, y) e L or (x, y) e R, then d(x, y) < d(pa, Pb).
Therefore (x, y) is not an edge in E. Therefore, U n L and U n R is a bipartition
o f U, hence U inducos a bipartite subgraph. []
We may now state the main result of this section.
Theorem 4.3. S P E C - D I A M finds a valid partition of P or concludes none exists
in time O(n2).
Proof By Lemma 4.1(a)-(c), if step 2 terminates successfully then S' and T'
satisfy conditions (i) and (ii) and are extendable to all valid partitions of P. If
the step is unsuccessful, then P cannot be partitioned. Step 3 terminates
successfully whenever U is bipartite. Let S* and T* be the bipartition produced by the
algorithm. We claim that S = $' w S* and T = T' u T* is a valid partition of P.
By Lemma 4.2(a) there are no edges from S' to $*, thus (i) holds. Similarly,
there are only green edges between T' and T*. Thus (ii) holds, proving the claim.
The time bound is easily verified. []
5. Generalizations and Open Problems
We first consider generalizing the results in the preceding sections to d dimensions.
As mentioned in Section 2, no restrictions are placed on the distance function
for the results in that section. Therefore a minimum diameter balanced partition
can be found in time O(dn 2 log n).
In Section 3, the dimension of the problem plays a role. In higher dimensions,
we require the subsets to be separated by a hyperplane. Using the method of
Section 3, we need an efficient algorithm to find a hyperplane that intersects a
given set o f line segments. Such an algorithm has been announced in [4] for
d = 3 that runs in O(n 3) time.
For the problem of partitioning a set into subsets with given diameters,
considered in Section 4, the results again do not generalize immediately to higher
dimensions. The argument in the p r o o f of Lemma 4.2(b) does not work even in
three dimensions. Perhaps step 2 of S P E C - D I A M can be applied recursively to
the unpartitioned subset U.
A different type o f generalization is to consider partitions into three or more
subsets. Here the results for the general problem are negative. It has been shown
independently in [9], [13], [15] that the m-centers problem mentioned in the
introduction is NP-complete. As pointed out in [11] a similar argument shows
that the problem o f partitioning a planar point set into k subsets o f diameter t
is also NP-complete.
Finally there is the question o f lower bounds. The author knows o f no nontrivial
lower bounds for any o f the problems considered here. Therefore it is an open
problem whether any of the algorithms given here are optimal.
Acknowledgment
The author wishes to thank two anonymous referees for suggesting improvements
to the original paper.
1. A. V. Aho, J. E. Hopcroft, and J. D. Ullman, The Design and Analysis of Computer Algorithms,
Addison-Wesley, Reading, MA 1974.
2. D. Avis, Non-partitionable point sets, Inform. Proc. Lett. 19 (1984), 125-129.
3. D. Avis, Space partitioning and its application to generalized retrieval problems, Proceedings o f
the International Conference on Foundations of Data Organization, 154-162, Kyoto, May 1985.
4. D. Avis and M. Doskas, Algorithms for high dimensional stabbing problems, (to appear).
5. D. P. Dobkin and H. Edelsbrunner, Space searching for intersecting objects, Proceedings of the
25th FOCS, 387-391, October, 1984.
6. H. Edelsbrunner and E. Welzl, On the number of line separations of a finite set in the plane, J.
Combin. Theory Ser. A 38 (1985), 15-29.
7. H. Edelsbrunner, H. A. Maurer, F. P. Preparata, A. L. Rosenberg, E. Welzl, and D. Wood,
Stabbing line segments, B I T 22 (1982), 274-281.
8. P. Erd6s, L. Lov~isz,A. Simmons, and E. G. Straus, Dissection graphs of planar point sets, in A
Survey of Combinatorial Theory, (J. N. Srivastava et al. ed.), 139-149, Amsterdam, North-Holland,
1973.
9. R. J. Fowler, M. S, Paterson, and S. L. Tanimoto, Optimal packing and covering in the plane
are NP-complete, Inform. process. Lett. 12 (1981), 133-137.
10. M. R. Garey and D. S. Johnson, Computers and Intractability, Freeman, New York, 1979.
1I. D. S. Johnson, NP-completeness column, J. Algorithms 3 (1982), 182-195.
12. L Lovfisz, On the number of halving lines, Ann. Univ. Sci. Budapest. E6tv6s Sect. Math. 14 (1971),
107-108.
13. S. Masuyama, T. lbaraki, and T. Hasegawa, The computational complexity of the m-centers
problem in the plane, Trans. IECE Japan, (1981), 57-64.
14. M. I. Shamos, Computational Geometry, University Microfilms, Ann Arbor, MI, 1978.
15. K. Supowit, Topics in Computational Geometry, Report No. UIUCDCS-R-81-1062, Department
of Computer Science, University of Illinois, Urbana, IL, 1981.
16. D. E. Willard, Polygon retrieval, S l A M J. Comput. 11 (1982), 149-165.
17. F. Yao, 3-Space partition and its applications, Proceedings of the 15th STOC, Boston, MA, 1983.