<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Size-constrained 2-clustering in the plane with Manhattan distance</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Alberto Bertoni</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Massimiliano Goldwurm</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jianyi Lin</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Linda Pini</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Dipartimento di Informatica, Universita` degli Studi di Milano Via Comelico 39/41</institution>
          ,
          <addr-line>20135 Milano -</addr-line>
          <country country="IT">Italy</country>
        </aff>
      </contrib-group>
      <fpage>33</fpage>
      <lpage>44</lpage>
      <abstract>
        <p>We present an algorithm for the 2-clustering problem with cluster size constraints in the plane assuming `1-norm, that works in O(n3 log n) time and O(n) space. Such a procedure also solves a full version of the problem, computing the optimal solutions for all possible constraints on cluster sizes. The algorithm is based on a separation result concerning the clusters of any optimal solution of the problem and on an extended version of red-black trees to maintain a bipartition of a set of points in the plane.</p>
      </abstract>
      <kwd-group>
        <kwd>algorithms and data structures</kwd>
        <kwd>clustering</kwd>
        <kwd>cluster size constraints</kwd>
        <kwd>Manhattan distance</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        Clustering is one of the most used techniques in statistical data analysis and
machine learning [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], with a wide range of applications in many areas like pattern
recognition, bioinformatics and image processing. Clustering consists in
partitioning data into groups, called clusters, that are required to be homogeneous
and well-separated according to a data similarity measure [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. A natural
representation of the data elements is by means of points in a d-dimensional space
equipped with a suitable distance function that determines the similarity
measure. We study this very usual case, called distance clustering.
      </p>
      <p>
        A central problem in distance clustering is the well-known Minimum
Sum-ofSquares Clustering (MSSC), also called Variance-based Clustering [
        <xref ref-type="bibr" rid="ref10 ref2">2, 10</xref>
        ]. The
MSSC problem requires to find a k-partition {A1, ..., Ak} of a given set X =
{x1, ..., xn} ⊂ Rd of n points that minimizes the weight
where ||·||2 denotes the Euclidean norm and CAi is the mean point of the cluster
Ai, defined by
      </p>
      <p>2
||x − CAi ||2
CAi = argmin X ||μ − x||22 =
μ∈Rd x∈Ai</p>
      <p>
        1
|Ai| x∈Ai
MSSC is difficult in general; indeed for an arbitrary dimension d (given in the
instance) the problem is NP-hard even if the number of clusters is fixed to k = 2
[
        <xref ref-type="bibr" rid="ref1 ref8">1, 8</xref>
        ]; the same occurs if k is arbitrary and the dimension is fixed to d = 2 [
        <xref ref-type="bibr" rid="ref14">14</xref>
        ].
However there’s a well-known heuristic for finding an approximate solution of
MSSC, called k-Means [
        <xref ref-type="bibr" rid="ref13">13</xref>
        ], which is known to be usually very fast, but can
require exponential time in the worst case [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ].
      </p>
      <p>
        Moreover, a known variant of MSSC, called k-Medians Problem, is given by
substituting the squared-euclidean norm ||·||22 with the `1-norm ||·||1 [
        <xref ref-type="bibr" rid="ref15">15</xref>
        ].
      </p>
      <p>
        In many applications, often people have some information on the clusters [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]:
including this information into traditional clustering algorithms can increase the
clustering performance. Problems that include such background information are
called constrained clustering problems and are split into two classes. On the one
hand, clustering problems with point-level constraints typically comprise a set
of must-link constraints or cannot-link constraints [
        <xref ref-type="bibr" rid="ref18">18</xref>
        ], defining pairs of point
that, respectively, must be or cannot be grouped in the same cluster. On the
other hand, clustering problems with cluster-level constraints [
        <xref ref-type="bibr" rid="ref16 ref6">6, 16</xref>
        ] provides
constraints concerning the size of the resulting clusters. For example, in [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ]
cluster size constraints are used for improving clustering accuracy; this approach,
for instance, allows one to avoid extremely small or large clusters yielded by
classical clustering techniques.
      </p>
      <p>In this work we study the 2-clustering problem in the plane, with cluster size
constraints, assuming `1-norm. The relevance of the 2-clustering problems is also
due to the wide spread of hierarchical clustering techniques [11, Sec.14.3.12],
that repeatedly apply the 2-clustering as the key step. This leads to natural
size-constrained versions of so-called divisive hierarchical clustering.</p>
      <p>
        We recall that the 2-clustering problem with cluster size constraints has been
studied in [
        <xref ref-type="bibr" rid="ref12 ref4">12, 4</xref>
        ], where it is shown that in dimension 1 the problem is solvable
in polynomial time for every norm `p with integer p ≥ 1, while there is some
evidence that the same result does not hold for non-integer p. Moreover, it is
also known that for arbitrary dimension d the same problem is NP-hard even
assuming equal sizes of the two clusters.
      </p>
      <p>Here we prove that, assuming dimension 2 and `1-norm, the 2-clustering
problem with cluster size constraints can be solved in O(n3 log n) time and O(n)
space. Our procedure actually solves a full version of the problem, computing the
optimal solutions for all possible sizes of cluster. Clearly this yields the solution
to the general unconstrained 2-clustering problem in the plane with `1-norm.</p>
      <p>The algorithm is based on a separation result stating that, in our hypotheses,
the clusters of any optimal solution are separated by curves of some special forms,
which can be analysed in a suitable linear order. The algorithm also make use
of a particular extension of red-black trees to maintain a bipartition of a set of
points in the plane.</p>
      <p>
        We remark that in this work we propose an efficient method for obtaining a
solution that is globally optimal, instead of a locally optimal solution as yielded
by various heuristics [
        <xref ref-type="bibr" rid="ref19 ref3 ref6">3, 6, 19</xref>
        ].
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Problem definition</title>
      <p>In this section we introduce some basic notions of distance-based clustering
problems on the plane assuming the Manhattan norm (also called `1-norm), which
is defined by kxk1 = |x1| + |x2| for any x = (x1, x2) ∈ R2.</p>
      <p>Given a set X ⊂ R2 of n points in the plane, a k-partition of X is a family
k
{A1, A2, ..., Ak} of k nonempty subsets of X such that ∪i=1Ai = X and Ai∩Aj =
∅, for i 6= j. Each Ai is called cluster. The centroid CA of a cluster A ⊂ X is
CA = argmin X kx − μk1 = argmin X (|x1 − μ1| + |x2 − μ2|)</p>
      <p>μ∈R2 x∈A μ∈R2 x∈A
Since the objective function in the minimization is not strictly convex, the
centroid CA is not necessarily unique. Indeed it is well-known that the centroid CA
is the component-wise median, i.e. the abscissa (ordinate) of the centroid is the
median of the abscissae (ordinates) of the points in A. The weight W (A) of a
cluster A is</p>
      <p>W (A) = X</p>
      <p>kx − CAk1
x∈A
while the weight of a k-partition {A1, A2, ..., Ak} (also called k-clustering ) is
k
W (A1, A2, · · · , Ak) = X W (Ai).</p>
      <p>1
The classical Clustering Problem in the plane assuming the Manhattan norm is
stated as follows.</p>
      <p>Definition 1 (Clustering Problem in R2 under `1-norm). Given a point
set X ⊂ R2 of cardinality n and an integer k, 1 &lt; k &lt; n, find a k-clustering
{A1, A2, ..., Ak} that minimizes the weight W (A1, A2, · · · , Ak) = P1k W (Ai).
Note that here k is included in the instance of the problem. If k is fixed the
problem is called k-Clustering in R2. Our main contribution in this paper concerns
the 2-Clustering in R2 under `1-norm.</p>
      <p>We are interested in a version of clustering problem where the cluster sizes
are constrained. Formally, the problem can be stated as follows:
Definition 2 (Size Constrained Clustering Problem in R2 under
`1norm). Given a point set X ⊂ R2 of cardinality n, an integer k &gt; 1 and
k positive integers m1, m2, ..., mk such that P1k mi = n, find a k-clustering
{A1, A2, ..., Ak} with |Ai| = mi for i = 1, ..., k, that minimizes the weight
W (A1, A2, · · · , Ak) = P1k W (Ai).</p>
      <p>We denote this problem by SCC-2 (under `1-norm). We stress that in the SCC-2
problem the integers n, k, m1, . . . , mk are part of the instance. On the contrary,
if k is fixed and does not belong to the instance, the problem is denoted by
k-SCC-2.</p>
      <p>In the following sections we present an algorithm for the 2-Clustering problem
in R2 under `1-norm, which solves at the same time the full version of the
2SCC-2 problem, i.e. that yields the solutions to all 2-SCC-2 problems for every
value of m1 ∈ {1, 2, . . . , bn/2c} and the same point set X = {x1, x2, ..., xn} ⊂ R2
in input. The procedures works in O(n3 log n) time and is based on a separation
result concerning the optimal solutions of 2-Clustering in the plane, presented
in Section 3, and on an augmented version of red-black trees used to maintain
bipartitions of a set of real points, described in Section 4.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Separation results</title>
      <p>
        In this section we present a separation result concerning the optimal solution of
2-SCC-2 problem under `1-norm. It turns out that the clusters of the optimal
solutions of this problem are separated by plane curves of 8 different types, we
will call Ci and Si, i = 1, 2, 3, 4, respectively. Similar results are obtained in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]
for higher dimensional spaces and `p-norms, with p &gt; 1.
      </p>
      <p>First, we show that in an optimal 2-clustering the swapping of two elements
in different clusters does not decrease the solution value.</p>
      <p>Lemma 1 (Swapping Lemma). Let {A, B} be an optimal solution of the
2SCC-2 problem. Then, for any a ∈ A and b ∈ B, it holds</p>
      <p>||a − CA||1 + ||b − CB||1 ≤ ||a − CB||1 + ||b − CA||1 .</p>
      <p>Proof. For the sake of simplicity, we omit the subscript 1 in denoting norm. By
contradiction, let us assume that for some a ∈ A and b ∈ B</p>
      <p>||a − CA|| + ||b − CB|| &gt; ||a − CB|| + ||b − CA|| .</p>
      <sec id="sec-3-1">
        <title>Then, the weight of the optimal solution is</title>
        <p>W (A, B) = X ||x − CA|| + X ||x − CB|| =
&gt;
=
x∈A</p>
        <p>X
x∈Ar{a}</p>
        <p>X
x∈Ar{a}∪{b}</p>
        <p>x∈B
||x − CA|| +</p>
        <p>X
x∈Br{b}</p>
        <p>X
x∈Br{b}∪{a}</p>
        <p>||x − CB|| .
||x − CA|| + ||b − CA|| +
||x − CB|| + ||a − CB|| =
Now, it is clear that the 2-clustering {A0, B0}, with A0 = A r {a} ∪ {b} and
B0 = B r {b} ∪ {a}, is a feasible solution since |A0| = |A| and |B0| = |B|.
Furthermore, by definition of centroid it holds:
X ||x − CA||+ X
||x − CB|| ≥
||x − CA0 ||+</p>
        <p>X ||x − CB0 || = W (A0, B0)
x∈A0
x∈B0
x∈B0
and hence W (A, B) &gt; W (A0, B0). However, this is in contradiction since {A, B}
is an optimal solution.
tu
X
x∈A0
We are now able to obtain the general form of the equation for the curves
separating the clusters in an optimal 2-clustering.</p>
        <p>Theorem 1 (Separation Result). In an optimal solution {A, B} of the
2SCC-2 problem, the clusters A and B are separated by a curve of equation
||z − α||1 − ||z − β||1 = g
(1)
where the variable z ranges over R2, while α, β ∈ R2 and g ∈ R are suitable
constants.</p>
        <p>Proof. Let CA and CB be the centroids of A and B respectively. Then, by Lemma
1 the inequality</p>
        <p>
          ||a − CA||1 − ||a − CB||1 ≤ ||b − CA||1 − ||b − CB||1
is satisfied for all a ∈ A and b ∈ B, and hence it also holds by taking the
maximum over a’s on the left and the minimum over b’s on the right:
cA := ma∈aAx{||a − CA||1 − ||a − CB||1} ≤ mb∈iBn{||b − CA||1 − ||b − CB||1} =: cB
Therefore, choosing g ∈ [cA, cB], all the points of A and B are contained in the
region defined respectively by ||z − CA||1 − ||z − CB||1 ≤ g and ||z − CA||1 −
||z − CB||1 ≥ g. The common boundary of the two regions has equation
||z − CA||1 − ||z − CB||1 = g, and thus the proof is concluded by setting α = CA
and β = CB. tu
Remark 1. It is noteworthy to observe that both the Swapping Lemma and the
Separation Result can be extended to the case of `p-norm with any p ≥ 1 and
dimension d ≥ 2, provided the norm is raised to the p-th power [
          <xref ref-type="bibr" rid="ref12">12</xref>
          ].
Setting the symbols z = (x, y), α = (c, d), β = (e, f ), equation (1) becomes
|x − c| − |x − e| + |y − d| − |y − f | = g
It is clear that it always represents a connected curve on the plane, which may
have some sharp corner points, i.e. points where one or both partial derivatives
do not exist. A rather standard study of this equation, conducted by considering
all possible values of c, d, e, f, g, leads to derive 8 types of separating curves, we
denote by symbols C1, C2, C3, C4 and S1, S2, S3, S4, according to their shape.
The proof is here omitted for lack of space. Such 8 types of curves are depicted
in Figures 1–4.
4
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Bipartition red-black trees</title>
      <p>In this section we describe a natural data structure to maintain a bipartition of
a set of real numbers, with possible multiple values, able to test membership, to
execute insertion and deletion, and to perform two further operations: selecting
the i-th smallest element in either of the two clusters of the bipartition, for any
integer i, and moving an element from one cluster to the other.</p>
      <p>Let X be a finite multiset of real numbers, i.e. a finite set X of reals where
any value may occur several times, represented as a finite ordered sequence</p>
      <p>X = (x1, x2, . . . , xn), xi ∈ R for every i, and x1 ≤ x2 ≤ · · · ≤ xn.
Moreover, consider a bipartition {A, B} of X, i.e. two non-empty subsets A ⊆ X,
B ⊆ X such that A ∩ B = ∅ and A ∪ B = X. In the following A and B are
called clusters. Operations Member, Insert and Delete can be defined in order
to specify the cluster the elements belong to. More precisely, for every z ∈ R,
Member(z) = (j1, j2), where j1 (resp. j2) is the number of xi’s in A (resp. in B)
such that xi = z, Insert(z, A) adds a new element z to A, Insert(z, B) does the
same to B, while Delete(z, A) and Delete(z, B) execute the delete operations.
S1
C2
C3
S3
f
d
d
f
α
α</p>
      <p>C1</p>
      <p>C2
C3
f
d
d
f</p>
      <p>S2</p>
      <p>C1
α
Moreover, for every i ∈ {1, 2, . . . , n}, we define</p>
      <p>SelectA(i) =
SelectB(i) =
a if i ≤ |A| and a is the i-th smallest element of A
⊥ if i &gt; |A|
b if i ≤ |B| and b is the i-th smallest element of B .</p>
      <p>⊥ if i &gt; |B|
Finally, for any z ∈ R, if A contains an element xi = z then MoveAB(z) deletes
a value z from A and adds it to B, otherwise MoveAB(z) = ⊥. The operation
MoveBA(z) is defined symmetrically.</p>
      <p>
        A natural data structure, able to executes the above operations in time
logarithmic with respect to n = |X|, is an augmented version of the well-known
red-black trees [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Formally, we define a Bipartition Red-Black Tree for a
bipartition {A, B} of X as a binary tree T such that: i ) all internal nodes have both
the left and the right son, ii ) every node is red or black, iii ) the root and the
leaves are black, iv ) if a node is red its sons are black, and v ) for every node v all
simple paths from v to any leaf have the same number of black nodes. Further,
the distinct elements of X (called keys) are assigned to the internal nodes in
a bijective correspondence, respecting the standard rule of binary search trees,
and the leaves are empty (usually represented by “nil”). Moreover, T satisfies
the following two conditions:
1. every internal node v contains a triple (z, mA(v), mB(v)), where z is the key
assigned to v, and mA(v) (respectively, mB(v)) is the number of elements xi
belonging to A (resp. B) such that xi = z;
2. every internal node v contains the pair of integers (cA(v), cB(v)), where cA(v)
(resp. cB(v)) is the number of elements of X belonging to A (resp. B) whose
value is assigned to a vertex in the subtree rooted at v.
      </p>
      <p>For each internal node v, we denote by key (v), left (v) and right (v) the key
contained in v, the left son and the right son of v, respectively. Clearly, v can be
implemented as a record including the values mA(v), mB(v)), cA(v), cB(v).</p>
      <p>
        Procedures Member, Insert and Delete can be defined as in the standard
redblacks trees [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] with obvious changes. Clearly, Insert and Delete have to update
the values mA(v), mB(v)), cA(v), cB(v), for all nodes v on the path from the
root to the vertex resulting from the binary search.
      </p>
      <p>Operations Select and Move can be executed as follows. To compute SelectA(i)
one checks whether i ≤ cA(r), where r is the root of T : in the affirmative case
a standard searching procedure (we avoid to define for lack of space) is called,
otherwise the value ⊥ is returned. SelectB(i) is defined in a similar way.</p>
      <p>To compute MoveAB(z) one first determines the node v containing z by
calling a rather usual procedure, then the commands
mA(v) = mA(v) − 1
and
mB(v) = mB(v) + 1
are executed. Procedure MoveBA(z) is defined symmetrically.</p>
      <p>It is clear that all previous procedures can be executed in O(log n) time.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Updating the weight of clusters</title>
      <p>Our main result, presented in the next section, is based on a procedure that
updates a current bipartition by moving one point from a cluster to the other.
Here we want to show how to update the centroids and the weights of the clusters
of a current bipartition after executing such a moving operation.</p>
      <p>To this end we first deal with the problem of updating centroid and weight
of a set of real numbers subject to insert and delete operations. The results will
be easily extended to a set of points in R2.</p>
      <p>Let A be a cluster in R, i.e. a finite sequence of ordered real numbers, A =
{a1, a2, . . . , ak}, where a1 ≤ a2 ≤ · · · ≤ ak. Assuming `1-norm it is well-known
that the centroid of A is the median of the set, that is the value</p>
      <p>M (A) =
( a k+1 if k is odd</p>
      <p>2
1 a k + a k2 +1 if k is even
2 2
Thus, if A is a cluster of a bipartition (of a finite multiset X ⊂ R of n elements),
maintained by a Bipartition Red-Black Tree, then M (A) can be computed in
O(log n) time by calling procedure SelectA(j) for suitable j’s.</p>
      <p>Now, let us recall the definition of the left and right part of the weight of A;
given m = k +21 , we have</p>
      <p>X
L(A) :=
ai ,</p>
      <p>R(A) :=</p>
      <p>X
m&lt;i≤k
ai
It is not difficult to see that the weight of A, given by W (A) = Pk
i=1 |ai −M (A)|,
can be computed as the difference between R(A) and L(A).</p>
      <p>Proposition 1. For every ordered sequence of real numbers A = {a1, a2, . . . , ak},
where a1 ≤ a2 ≤ · · · ≤ ak, we have</p>
      <p>W (A) = R(A) − L(A)
Proof. If k is even then m = k+1 is not integer and hence</p>
      <p>2
k
W (A) = X |ai − M (A)| =
i=1</p>
      <p>X (M (A) − ai) +</p>
      <p>X (ai − M (A))
1≤i&lt;m
= −L(A) + R(A)
m&lt;i≤k</p>
      <sec id="sec-5-1">
        <title>If k is odd the reasoning is almost the same.</title>
        <p>As a consequence, in order to maintain W (A) it is sufficient to update L(A) and
R(A). This can be done by a straightforward procedure that implements, as a
chain of if-then-else instructions, the rules for computing the left and right part
of the weight of a current cluster upon insertion and deletion. For lack of space
here we omit their cumbersome formal description. These rules together with
tu
Proposition 1, define procedures UpdateW-ins(A, x) and UpdateW-del(A, aj ),
which update the weight of a current cluster A ⊂ R, respectively upon insertion
and deletion of an element of value x ∈ R.</p>
        <p>They can be executed by using a Bipartition Red-Black tree with the
corresponding Select operation, introduced in the previous section. Note that, for
updating both L(A) and R(A), the Select procedure is necessary to find in the
tree the i-th value of A when required. As a consequence also UpdateW-ins(A, x)
and UpdateW-del(A, aj ) can be executed in logarithmic time.
6</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Main algorithm</title>
      <p>In this section we apply the previous results, in particular the separation property
of Section 3, to define an algorithm for the 2-SCC-2 problem in the full version,
i.e. for all possible sizes of cluster. Thus the same algorithm also yields a solution
of the general 2-Clustering problem in the plane.</p>
      <p>By our Theorem 1, the optimal solution of a 2-SCC-2 problem for a set
X ⊂ R2 of n points and a cluster size m, consists of a bipartition (A, B), with
|A| = m and |B| = n − m, where A and B are separated by a curve of the form
Ci or Si, i = 1, 2, 3, 4.</p>
      <p>Note that each curve of type Ci can be obtained from a curve of any other
form Cj , j 6= i, by means of a simple rotation of the plane. Similarly each curve
of type Si can be obtained from another curve of any different type Sj by means
of a rotation and/or a reflection through a line.</p>
      <p>For these reasons we treat in detail only the case of bipartitions separated
by a curve of type C1. The cases of curves of type C2, C3 and C4 are solved by
the same algorithm through a rotation of the input points. The same algorithm
can be easily adapted to the cases of separating curves of type Si, i = 1, 2, 3, 4.</p>
      <p>Let X = {p1, p2, . . . , pn} ⊂ R2 be a set of n points and let us set pi = (xi, yi),
for any i = 1, 2 . . . , n. Without loss of generality we may assume that all pi’s lie
in the first quadrant, i.e. xi &gt; 0 and yi &gt; 0 for all i.</p>
      <p>We define a procedure that searches an optimal bipartition of X whose
clusters are separated by a curve of type C1. The procedure first sorts X according
with 3 parameters: the two coordinates and their sum, i.e. the values xi’s, yi’s and
xi + yi’s, respectively. Then the elements of X are processed by three for-loops,
each nested into the other, corresponding to the three parameters considered
above. The algorithm evaluates all possible bipartitions of X whose clusters are
separated by curves of type C1 and, for every admissible cluster size, only the
bipartition with minimum weight is maintained. These bipartitions are
considered in a linear order and, at each step, a new bipartition of X is obtained from
the current one {A, B} by swapping a point from cluster B to cluster A.</p>
      <p>Such a current bipartition {A, B} is maintained by two bipartition red-black
trees: one for the 2-clustering {Ax, Bx} of the set {xi | pi = (xi, yi) ∈ X},
where Ax = {xi | pi ∈ A} and Bx = {xi | pi ∈ B}, and the other for the
2-clustering (Ay, By) of {yi | pi = (xi, yi) ∈ X}, where Ay = {yi | pi ∈ A} and
By = {yi | pi ∈ B}.</p>
      <p>An Update subroutine can be defined which, for an input (A, B, pi), where
{A, B} is the current bipartition of X and pi ∈ B, computes the new bipartition
moving pi from B to A and returns the weights of its clusters. The subroutine
applies the procedures described in Sections 4 and 5 and it is defined by the
following scheme:
Procedure Update(A, B, pi)
begin</p>
      <p>MoveBxAx (xi)
MoveByAy (yi)
w(Ax) := UpdateW-ins(Ax, xi)
w(Bx) := UpdateW-del(Bx, xi)
w(Ay) := UpdateW-ins(Ay, yi)
w(By) := UpdateW-del(By, yi)
return (w(Ax) + w(Ay), w(Bx) + w(By))
end</p>
      <p>By the discussion presented in Sections 4 and 5 also this subroutine only
requires O(log n) time.</p>
      <p>Thus, the overall algorithm is described in detail by the procedure given
below, where three bipartitions are actually maintained, denoted by (A, B), (A0, B0)
and (A00, B00), respectively. Each of them need two Bipartition Red-Black trees,
one for the abscissae and the other for the ordinates.</p>
      <p>Moreover, instruction Sortx (resp., Sorty and Sortx+y) yields an ordered list
of the indices of the points in X, sorted in non-decreasing order with respect to
the values xi (resp., yi and xi + yi).</p>
      <p>Taking into account the previous discussion, it is easy to see that the
algorithm works in O(n3 log n) time; moreover, it has a space complexity O(n) since
each Bipartition Red-Black tree only requires linear space.</p>
      <sec id="sec-6-1">
        <title>Procedure Full-biclustering(p1, p2, . . . , pn)</title>
        <p>begin
(i1, i2, . . . , in) := Sortx(1, 2, . . . , n)
(j1, j2, . . . , jn) := Sorty(1, 2, . . . , n)
(k1, k2, . . . , kn) := Sortx+y(1, 2, . . . , n)
A := ∅ ; w(A) := 0
B := {p1, p2, . . . , pn}
compute the weight w(B) of cluster B
i0 := 0 ; j0 := 0 ; x0 := 0 ; y0 := 0
for r = 0, 1, . . . , n do</p>
        <p>A0 := A ; B0 := B ; w(A0) := w(A) ; w(B0) := w(B)
for s = 0, 1, . . . , n do</p>
        <p>A00 := A0 ; B00 := B0 ; w(A00) := w(A0) ; w(B00) := w(B0)
for k = k1, k2, . . . , kn do
if xk ≥ xir ∧ yk ≥ yjs then
(w(A00), w(B00)) = Update(A00, B00, pk)
h := min(|A00|, |B00|)
z := w(A00) + w(B00)
if W [h] &gt; z then</p>
        <p>W [h] := z
Π[h] := (ir, js, k)
if s 6= n ∧ xjs+1 ≥ xir then
(w(A0), w(B0)) = Update(A0, B0, pjs+1 )
h := min(|A0|, |B0|)
z := w(A0) + w(B0)
if W [h] &gt; z then
if r 6= n then
(w(A), w(B)) = Update(A, B, pir+1 )
h := min(|A|, |B|)
z := w(A) + w(B)</p>
        <p>W [h] := z
Π[h] := (ir, js+1, 0)
if W [h] &gt; z then</p>
        <p>W [h] := z
Π[h] := (ir+1, 0, 0)
return (W, Π)
end
7</p>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>Conclusions</title>
      <p>In this paper we have shown a O(n3 log n) time algorithm for the size-constrained
2-Clustering problem in the plane with `1-norm. It is clear that our results
strictly depend on those conditions and it is not evident (at least at the present
time) whether they hold under different hypotheses or for more general problems.
Moreover, being our algorithm exact and working in polynomial time, we do not
think it is necessary to produce here, in our hypotheses (2-clustering in R2 with
`1-norm), an experimental comparison with traditional heuristics like k-Means,
which instead yields an approximate solution, tackles a more general problem
with larger number of clusters, and works in exponential time in the worst case.</p>
      <p>
        However, we think that the present contribution could be the starting point
for a further analysis, still based on the separation result introduced in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ], of
more general clustering problems, with dimension greater than 2, larger number
of clusters, different norms and other constraints. It is clear that such a research
direction should also include an experimental activity that plans a comparison
with classical heuristics.
      </p>
      <p>We also remark we have already obtained recently some results under other
hypotheses. In particular, in a companion paper we present more efficient
algorithms for solving exactly the same problem with Euclidean norm, based on
rather different techniques of computational geometry. More precisely, it turns
out that the 2-Clustering problem in R2 under Euclidean norm, with size
con√
straint k, can be solved by an exact algorithm in O(n 3 k log2 n) time, while the
full version of the same problem (i.e. for all k = 1, 2, . . . , bn/2c) is solvable in
O(n2 log n) time.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>D.</given-names>
            <surname>Aloise</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Deshpande</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Hansen</surname>
          </string-name>
          , and
          <string-name>
            <given-names>P.</given-names>
            <surname>Popat</surname>
          </string-name>
          .
          <article-title>NP-hardness of Euclidean sum-of-squares clustering</article-title>
          .
          <source>Machine Learning</source>
          ,
          <volume>75</volume>
          :
          <fpage>245</fpage>
          -
          <lpage>249</lpage>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>D.</given-names>
            <surname>Aloise</surname>
          </string-name>
          and
          <string-name>
            <given-names>P.</given-names>
            <surname>Hansen</surname>
          </string-name>
          .
          <article-title>On the complexity of minimum sum-of-squares clustering</article-title>
          .
          <source>Technical report, Les Cahiers du GERAD</source>
          ,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>S.</given-names>
            <surname>Basu</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Davidson</surname>
          </string-name>
          , and
          <string-name>
            <given-names>K.</given-names>
            <surname>Wagstaff</surname>
          </string-name>
          . Constrained Clustering:
          <article-title>Advances in Algorithms</article-title>
          , Theory, and
          <string-name>
            <surname>Applications</surname>
          </string-name>
          . Chapman and Hall/CRC,
          <year>2008</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>A.</given-names>
            <surname>Bertoni</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Goldwurm</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Lin</surname>
          </string-name>
          , and
          <string-name>
            <given-names>F.</given-names>
            <surname>Sacca</surname>
          </string-name>
          <article-title>`</article-title>
          .
          <source>Size Constrained Distance Clustering: Separation Properties and Some Complexity Results. Fundamenta Informaticae</source>
          ,
          <volume>115</volume>
          (
          <issue>1</issue>
          ):
          <fpage>125</fpage>
          -
          <lpage>139</lpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>C.</given-names>
            <surname>Bishop</surname>
          </string-name>
          .
          <source>Pattern Recognition and Machine Learning</source>
          . Springer,
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>P. S.</given-names>
            <surname>Bradley</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K. P.</given-names>
            <surname>Bennett</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Demiriz. Constrained K-Means Clustering</surname>
          </string-name>
          .
          <source>Technical Report MSR-TR-2000-65</source>
          , Miscrosoft Research Publication, May
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>T. H.</given-names>
            <surname>Cormen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C. E.</given-names>
            <surname>Leiserson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R. L.</given-names>
            <surname>Rivest</surname>
          </string-name>
          , and
          <string-name>
            <given-names>C.</given-names>
            <surname>Stein</surname>
          </string-name>
          . Introduction to Algorithms. MIT Press,
          <source>2nd edition</source>
          ,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>S.</given-names>
            <surname>Dasgupta</surname>
          </string-name>
          .
          <article-title>The hardness of k-means clustering</article-title>
          .
          <source>Technical Report CS2007-0890</source>
          , Dept.
          <source>Computer Sc. and Eng</source>
          ., Univ. of California, San Diego,
          <year>2007</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9. W. D. Fisher.
          <article-title>On grouping for maximum homogeneity</article-title>
          .
          <source>Journal of the American Statistical Association</source>
          ,
          <volume>53</volume>
          (
          <issue>284</issue>
          ):
          <fpage>789</fpage>
          -
          <lpage>798</lpage>
          ,
          <year>1958</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <given-names>S.</given-names>
            <surname>Hasegawa</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Imai</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Inaba</surname>
          </string-name>
          , and
          <string-name>
            <given-names>N.</given-names>
            <surname>Katoh</surname>
          </string-name>
          .
          <article-title>Efficient algorithms for variancebased k-clustering</article-title>
          .
          <source>In Proceedings of Pacific Graphics '93</source>
          , pages
          <fpage>75</fpage>
          -
          <lpage>89</lpage>
          ,
          <year>1993</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11. T. Hastie,
          <string-name>
            <given-names>R.</given-names>
            <surname>Tibshirani</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Friedman</surname>
          </string-name>
          .
          <source>The Elements of Statistical Learning: Data Mining, Inference, and Prediction. Springer-Verlag, 2nd edition</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <given-names>J.</given-names>
            <surname>Lin</surname>
          </string-name>
          .
          <article-title>Exact algorithms for size constrained clustering</article-title>
          .
          <source>PhD Thesis</source>
          , Universita` degli Studi di Milano. Ledizioni Publishing, Milano,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>J. B. MacQueen</surname>
          </string-name>
          .
          <article-title>Some method for the classification and analysis of multivariate observations</article-title>
          .
          <source>In Proc. 5th Berkeley Symp. Math. Structures</source>
          , pages
          <fpage>281</fpage>
          -
          <lpage>297</lpage>
          ,
          <year>1967</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>M. Mahajan</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          <string-name>
            <surname>Nimbhorkar</surname>
            , and
            <given-names>K.</given-names>
          </string-name>
          <string-name>
            <surname>Varadarajan</surname>
          </string-name>
          .
          <article-title>The planar k-means problem is NP-hard</article-title>
          .
          <source>Theoretical Computer Science</source>
          ,
          <volume>442</volume>
          :
          <fpage>13</fpage>
          -
          <lpage>21</lpage>
          ,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <given-names>K.</given-names>
            <surname>Sabo</surname>
          </string-name>
          .
          <article-title>Center-based l1-clustering method</article-title>
          .
          <source>International Journal of Applied Mathematics and Computer Science</source>
          ,
          <volume>24</volume>
          (
          <issue>1</issue>
          ):
          <fpage>7</fpage>
          -
          <lpage>225</lpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <given-names>A.</given-names>
            <surname>Tung</surname>
          </string-name>
          , J. Han,
          <string-name>
            <surname>L</surname>
          </string-name>
          . Lakshmanan, and
          <string-name>
            <given-names>R.</given-names>
            <surname>Ng</surname>
          </string-name>
          .
          <article-title>Constraint-Based Clustering in Large Databases</article-title>
          . In J. Van den Bussche and V. Vianu, editors,
          <source>Database Theory ICDT</source>
          <year>2001</year>
          , volume
          <volume>1973</volume>
          <source>of LNCS</source>
          , pages
          <fpage>405</fpage>
          -
          <lpage>419</lpage>
          . Springer Berlin/Heidelberg,
          <year>2001</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <given-names>A.</given-names>
            <surname>Vattani</surname>
          </string-name>
          .
          <article-title>K-means requires exponentially many iterations even in the plane</article-title>
          .
          <source>In Proceedings of the 25th Symposium on Computational Geometry (SoCG)</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <given-names>K.</given-names>
            <surname>Wagstaff</surname>
          </string-name>
          and
          <string-name>
            <given-names>C.</given-names>
            <surname>Cardie</surname>
          </string-name>
          .
          <article-title>Clustering with instance-level constraints</article-title>
          .
          <source>In Proc. of the 17th Intl. Conf. on Machine Learning</source>
          , pages
          <fpage>1103</fpage>
          -
          <lpage>1110</lpage>
          ,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <given-names>S.</given-names>
            <surname>Zhu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Wang</surname>
          </string-name>
          , and
          <string-name>
            <given-names>T.</given-names>
            <surname>Li</surname>
          </string-name>
          .
          <article-title>Data clustering with size constraints</article-title>
          .
          <source>KnowledgeBased Systems</source>
          ,
          <volume>23</volume>
          (
          <issue>8</issue>
          ):
          <fpage>883</fpage>
          -
          <lpage>889</lpage>
          ,
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>