Introduction
k k k -means [23 ] is a canonical clustering method because of its simple geometric interpretation, with broad applications including image analysis [16 , 21 , 1 ] (Qi et al. 2024), large-scale similarity search [15 ] , single-cell genomics [7 ] , climate science [19 ] , and speech processing (Ambilduke et al., 2025). k k k -means seeks a partition that minimizes the within-cluster sum of squares (WCSS). Despite the simplicity of its objective, finding a global minimizer is NP-hard [2 ] . Practical methods therefore seek a suboptimal solution from a given initialization.
Lloyd’s algorithm alternates between assignment and centroid updates. At termination, the assignments and centroids are each optimal with the other fixed [22 ] . This partial optimality does not exclude a reassignment that decreases WCSS after centroid recomputation. Hartigan-style methods [14 ] (Telgarsky and Vattani 2010) address this weakness, and Li et al. [20 ] formalize D-local optimality , under which no one-sample reassignment decreases WCSS after centroid recomputation.
However, two reassignments that are individually non-improving can yield an improvement when applied simultaneously, because their centroid updates interact through shared clusters. This motivates r r r -point local optimality, which excludes improvements from simultaneously reassigning at most r r r samples and ranges from D-locality at r = 1 r = 1 r = 1 to global optimality at r = n r = n r = n . We focus on r = 2 r = 2 r = 2 , the first level beyond one-point relocation.
Exact certification of two-point local optimality appears expensive because direct enumeration over sample pairs and their destination clusters yields ( n 2 ) ( k − 1 ) 2 \binom{n}{2}(k - 1)^2 ( 2 n ) ( k − 1 ) 2 candidates. Nevertheless, we establish that, at a D-local optimum, every improving two-point move must involve a cluster shared by both sample reassignments, reducing all potentially improving moves to six directed configurations. To further reduce sample-pair enumeration, we construct, for each sample, an upper bound on the gains of connected two-point moves involving it, following the safe-screening principle El Ghaoui et al. [9 ] ; Fercoq et al. [11 ] . A sample with a non-positive upper bound cannot participate in any improving pair and can therefore be safely discarded. After initial Lloyd convergence, alternating Min-D-LO one-point descent with exact search over the retained samples yields Boundary-Point-Screened Two-Point Local Search (BPS-2PLS), which terminates at a two-point local optimum. With m m m retained candidates and lazily computed pair distances, screening and search cost O ( k 2 d + n k log n + m 2 ( d + k ) ) O(k^2d + nk \log n + m^2(d + k)) O ( k 2 d + nk log n + m 2 ( d + k )) after each one-point descent phase, without a full sample-pair cache.
The benefit of screening depends on how m m m grows with n n n . We localize retained samples near empirical cluster boundaries and prove m = O P ( log n ) m = O_{\mathrm{P}}(\log n) m = O P ( log n ) for fixed k k k , d d d under bounded-support sampling with bounded density or Gaussian-mixture sampling. The bounds hold uniformly over D-local states with nonvanishing cluster occupancy. Complementing this theoretical analysis, a six-dataset subsampling experiment shows mean pruning rates above 97% at the largest tested sizes. Together, these results show that exact two-point local optimality can be attained efficiently on the evaluated problems.
Overall, our contributions are summarized as follows:
We introduce a hierarchy from D-local to global optimality and characterize improving moves through connected cluster-transfer graphs.
We develop BPS-2PLS, combining exact two-point search with safe sample screening to certify two-point local optimality.
We establish uniform logarithmic candidate-size bounds m = O P ( log n ) m = O_{\mathrm{P}}(\log n) m = O P ( log n ) for two common distribution classes and a nonvanishing cluster-occupancy condition.
Related Work
Sample-reassignment methods include Hartigan-type one-sample relocations (Hartigan and Wong [14 ] ; Telgarsky and Vattani (2010)) and D-LO/Min-D-LO, which exclude improving one-point moves at termination (Li et al. [20 ] ). Beyond single-sample relocations, Tarsitano (2003) studied general two-sample reassignments under the Friedman–Rubin determinant criterion by scanning sample pairs and their destination clusters. In contrast to Tarsitano (2003), we study the standard WCSS objective through a point-cardinality local-optimality hierarchy, with exact search and safe screening for its complete two-point neighborhood.
Center- or cluster-based neighborhoods include J-Means centroid relocation (Hansen and Mladenović [13 ] ), merge-and-split repartitioning (Nielsen and Nock (2014)), and center swaps with approximation guarantees (Arya et al. [4 ] ; Kanungo et al. [17 ] ). These operations may change many labels, whereas our neighborhoods are defined by the number of reassigned samples.
A complementary line of work reduces computation without changing the output of a prescribed algorithm. For example, exact Lloyd accelerations use triangle inequalities and distance bounds to reduce evaluations (Elkan [10 ] ; Hamerly [12 ] ; Newling and Fleuret (2016)). Safe screening in sparse optimization uses certificates to discard inactive variables without changing the target solution (El Ghaoui et al. [9 ] ; Fercoq et al. [11 ] ). BPS-2PLS combines these two goals: it goes beyond single-sample moves, uses safe screening to preserve every improving two-point move, and certifies two-point local optimality at termination.
Problem Setup and Preliminaries
Throughout this paper, deterministic vectors and matrices are bold italic , sets are blackboard bold , and scalars are upright letters. All unqualified vector norms are Euclidean. Let X = ( x i ) i = 1 n \mathcal{X} = (x_i)_{i=1}^{n} X = ( x i ) i = 1 n be an indexed collection of samples in R d \mathbb{R}^{d} R d , and write [ n ] = { 1 , … , n } [n] = \{1,\ldots,n\} [ n ] = { 1 , … , n } and [ k ] = { 1 , … , k } [k] = \{1,\ldots,k\} [ k ] = { 1 , … , k } . A clustering is represented by a label vector z ∈ [ k ] n z \in[k]^n z ∈ [ k ] n , with cluster index sets I ℓ ( z ) = { i ∈ [ n ] : z i = ℓ } I_{\ell}(z) = \{i \in[n] : z_i = \ell\} I ℓ ( z ) = { i ∈ [ n ] : z i = ℓ } , ℓ ∈ [ k ] \ell\in[k] ℓ ∈ [ k ] . We restrict attention to partitions with nonempty clusters and to reassignments whose resulting partitions also satisfy this condition. For a fixed state z z z , we suppress the dependence on z z z in the cluster statistics and write n ℓ = ∣ I ℓ ∣ n_\ell= |I_\ell| n ℓ = ∣ I ℓ ∣ , s ℓ = ∑ i ∈ I ℓ x i s_\ell= \sum_{i\in I_\ell} x_i s ℓ = ∑ i ∈ I ℓ x i , μ ℓ = s ℓ / n ℓ \mu_\ell= s_\ell/n_\ell μ ℓ = s ℓ / n ℓ . The k k k -means objective, also known as the within-cluster sum of squares (WCSS), is
F ( z ) = ∑ ℓ = 1 k ∑ i ∈ I ℓ ∥ x i − μ ℓ ∥ 2 = ∑ i = 1 n ∥ x i ∥ 2 − ∑ ℓ = 1 k ∥ s ℓ ∥ 2 n ℓ . (1) F(z) = \sum_{\ell=1}^{k}\sum_{i\in I_\ell}\lVert x_i-\mu_\ell\rVert^2 = \sum_{i=1}^{n}\lVert x_i\rVert^2-\sum_{\ell=1}^{k}\frac{\lVert s_\ell\rVert^2}{n_\ell}. \tag*{(1)} F ( z ) = ℓ = 1 ∑ k i ∈ I ℓ ∑ ∥ x i − μ ℓ ∥ 2 = i = 1 ∑ n ∥ x i ∥ 2 − ℓ = 1 ∑ k n ℓ ∥ s ℓ ∥ 2 . (1)
A reassignment from z z z to z ′ z' z ′ is improving precisely when F ( z ) − F ( z ′ ) > 0 F(z)-F(z')>0 F ( z ) − F ( z ′ ) > 0 . For later use, define the squared sample–centroid and sample–sample distances
D i ℓ = ∥ x i − μ ℓ ∥ 2 , p i j = ∥ x i − x j ∥ 2 . (2) D_{i\ell}=\lVert x_i-\mu_\ell\rVert^2,\qquad p_{ij}=\lVert x_i-x_j\rVert^2. \tag*{(2)} D i ℓ = ∥ x i − μ ℓ ∥ 2 , p ij = ∥ x i − x j ∥ 2 . (2)
Lloyd’s algorithm alternates between assigning each sample to a nearest centroid and recomputing each centroid as the mean of its assigned samples (Lloyd [22 ] ). At convergence, the resulting clustering satisfies
D i , z i ≤ D i b , ∀ i ∈ [ n ] , ∀ b ∈ [ k ] . (3) D_{i,z_i}\le D_{ib},\qquad\forall i\in[n],\quad\forall b\in[k]. \tag*{(3)} D i , z i ≤ D ib , ∀ i ∈ [ n ] , ∀ b ∈ [ k ] . (3)
This gives partial optimality : assignments and centroids are each optimal with the other fixed (Li et al. [20 ] ). However, partial optimality does not account for the centroid changes caused by reassigning a sample and therefore need not imply local optimality of the partition.
To account for these centroid changes, consider a one-point move u = ( i : s → a ) u=(i:s\to a) u = ( i : s → a ) , with s = z i s=z_i s = z i , a ≠ s a\ne s a = s , and n s > 1 n_s>1 n s > 1 . Its exact gain after recomputing the two affected centroids is
g i ( a ) = n s n s − 1 D i s − n a n a + 1 D i a . (4) g_i(a)=\frac{n_s}{n_s-1}D_{is}-\frac{n_a}{n_a+1}D_{ia}. \tag*{(4)} g i ( a ) = n s − 1 n s D i s − n a + 1 n a D ia . (4)
The first term is the reduction in WCSS obtained by removing x i x_i x i from cluster s s s , whereas the second term is the increase caused by inserting it into cluster a a a . Following Li et al. [20 ] , this gives the following notion of local optimality.
Definition 3.1 (D-local optimality). A clustering z z z is D D D -locally optimal if g i ( a ) ≤ 0 g_i(a)\le0 g i ( a ) ≤ 0 for every feasible one-point move ( i : z i → a ) (i:z_i\to a) ( i : z i → a ) , with the affected centroids recomputed.
Every D-locally optimal clustering satisfies the Lloyd fixed-point condition, whereas the converse need not hold. However, jointly reassigning multiple samples may still improve WCSS, motivating the point-cardinality hierarchy in the next section.
r-Point Local Optimality
We extend D-local optimality to joint label changes and identify the cluster interactions that can produce improvements. Let Z k = { z ∈ [ k ] n : I a ( z ) ≠ ∅ , ∀ a ∈ [ k ] } Z_k=\{z\in[k]^n:I_a(z)\ne\varnothing,\ \forall a\in[k]\} Z k = { z ∈ [ k ] n : I a ( z ) = ∅ , ∀ a ∈ [ k ]} be the feasible label space. For z ∈ Z k z\in Z_k z ∈ Z k , a simultaneous q q q -point reassignment is an unordered collection of q q q sample reassignments
M = { ( i t : a t → b t ) } t = 1 q , a t = z i t , b t ∈ [ k ] ∖ { a t } , (5) M=\{(i_t:a_t\to b_t)\}_{t=1}^{q},\qquad a_t=z_{i_t},\quad b_t\in[k]\setminus\{a_t\}, \tag*{(5)} M = {( i t : a t → b t ) } t = 1 q , a t = z i t , b t ∈ [ k ] ∖ { a t } , (5)
where i 1 , … , i q i_1,\ldots,i_q i 1 , … , i q are distinct. The resulting vector z M z^M z M changes each z i t z_{i_t} z i t to b t b_t b t and leaves all other entries unchanged. Feasibility requires the final simultaneous reassignment to satisfy z M ∈ Z k z^M\in Z_k z M ∈ Z k ; all affected centroids are then recomputed.
For z , z ′ ∈ Z k z,z'\in Z_k z , z ′ ∈ Z k , let d H ( z , z ′ ) = ∣ { i ∈ [ n ] : z i ′ ≠ z i } ∣ d_H(z,z')=|\{i\in[n]:z'_i\ne z_i\}| d H ( z , z ′ ) = ∣ { i ∈ [ n ] : z i ′ = z i } ∣ denote the differing labels, and define the exact-q q q shell and radius-r r r neighborhood by
N = q ( z ) = { z ′ ∈ Z k : d H ( z , z ′ ) = q } , N ≤ r ( z ) = ⋃ q = 1 r N = q ( z ) . (6) N_{=q}(z)=\{z'\in Z_k:d_H(z,z')=q\},\qquad N_{\le r}(z)=\bigcup_{q=1}^{r}N_{=q}(z). \tag*{(6)} N = q ( z ) = { z ′ ∈ Z k : d H ( z , z ′ ) = q } , N ≤ r ( z ) = q = 1 ⋃ r N = q ( z ) . (6)
For a feasible move M M M , define its gain by G ( M ; z ) = F ( z ) − F ( z M ) G(M;z)=F(z)-F(z^M) G ( M ; z ) = F ( z ) − F ( z M ) .
Definition 4.1 (r-point local optimality). A clustering z ∈ Z k z\in Z_k z ∈ Z k is r r r -point locally optimal if
F ( z ) ≤ F ( z ′ ) , for every z ′ ∈ N ≤ r ( z ) . (7) F(z)\le F(z'),\qquad\text{for every }z'\in N_{\le r}(z). \tag*{(7)} F ( z ) ≤ F ( z ′ ) , for every z ′ ∈ N ≤ r ( z ) . (7)
Proposition 4.2 (Hierarchy). Let L r \mathcal{L}_r L r denote the set of all r r r -point local optima. For 1 ≤ s < r ≤ n 1\le s<r\le n 1 ≤ s < r ≤ n ,
N ≤ s ( z ) ⊆ N ≤ r ( z ) , L r ⊆ L s . (8) N_{\le s}(z)\subseteq N_{\le r}(z),\qquad\mathcal{L}_r\subseteq\mathcal{L}_s. \tag*{(8)} N ≤ s ( z ) ⊆ N ≤ r ( z ) , L r ⊆ L s . (8) Moreover , 1-point local optimality coincides with D-local optimality, whereas n n n -point local optimality coincides with global optimality over Z k Z_k Z k .
The objective is a sum of cluster contributions, so reassignments can interact only through shared clusters. This motivates the following graph representation.
Definition 4.3 (Cluster-transfer graph). For a simultaneous move M M M , its cluster-transfer graph G ( M ) \mathcal{G}(M) G ( M ) is the directed multigraph whose vertex set V ( M ) V(M) V ( M ) consists of the affected clusters. For each reassignment, the graph contains one edge a t → b t a_t \to b_t a t → b t , labeled by i t i_t i t .
Distinct components affect disjoint cluster statistics, so their gains are additive, yielding the following characterization.
Theorem 4.4 (Connected-move characterization). A clustering z z z is r r r -point locally optimal if and only if every feasible simultaneous move M M M with 1 ≤ ∣ M ∣ ≤ r 1 \leq|M| \leq r 1 ≤ ∣ M ∣ ≤ r whose transfer graph G ( M ) \mathcal{G}(M) G ( M ) is weakly connected is non-improving. Consequently, if z z z is already ( r − 1 ) (r-1) ( r − 1 ) -point locally optimal, then every improving exact-r r r move must have a weakly connected transfer graph.
The gain decomposition and proofs are given in Appendix § 13 . A connected graph with q q q edges has at most q + 1 q+1 q + 1 vertices, so every connected q q q -point move affects at most q + 1 q+1 q + 1 clusters.
Connectedness alone need not reduce the worst-case order for general r r r (Appendix § 14 ). For r = 2 r=2 r = 2 , every improving move at a D-local state affects at most three clusters, yielding six configurations whose destination choices admit exact optimization. Given D D D and the required p i j p_{ij} p ij , destination search costs O ( n 2 k ) O(n^2k) O ( n 2 k ) per pass, without requiring cluster balance.
Exact Two-Point Local Search
At a D-local state z z z , enumerating sample pairs i < j i<j i < j and their destination labels yields ( n 2 ) ( k − 1 ) 2 \binom{n}{2}(k-1)^2 ( 2 n ) ( k − 1 ) 2 candidates. By Theorem 4.4, every improving pair u = ( i : s → a ) u=(i:s\to a) u = ( i : s → a ) , v = ( j : z j → b ) v=(j:z_j\to b) v = ( j : z j → b ) is connected: { s , a } ∩ { z j , b } ≠ ∅ \{s,a\}\cap\{z_j,b\}\ne\varnothing { s , a } ∩ { z j , b } = ∅ , where s = z i s=z_i s = z i .
Fixing u = ( i : s → a ) u=(i:s\to a) u = ( i : s → a ) as the anchor gives the six partner configurations in Table 1, indexed by τ \tau τ . Write G ( u , v ) : = G ( { u , v } ; z ) G(u,v):=G(\{u,v\};z) G ( u , v ) := G ({ u , v } ; z ) . Let J τ ( u ) J_\tau(u) J τ ( u ) and D τ ( u , j ) D_\tau(u,j) D τ ( u , j ) be the feasible partner-index and destination sets, and F ( u ) = { τ : J τ ( u ) ≠ ∅ } F(u)=\{\tau:J_\tau(u)\ne\varnothing\} F ( u ) = { τ : J τ ( u ) = ∅ } .
Proposition 5.1 (Exact WCSS changes under cluster updates). For feasible cluster updates, the exact WCSS changes after centroid recomputation can be expressed using pre-update sizes and distances as follows, with i ≠ j i\ne j i = j for two-sample updates:
R ℓ ( i ) = n ℓ n ℓ − 1 D i ℓ , gain from removing x i from cluster ℓ , (9) R_\ell(i)=\frac{n_\ell}{n_\ell-1}D_{i\ell},\qquad\text{gain from removing }x_i\text{ from cluster }\ell, \tag*{(9)} R ℓ ( i ) = n ℓ − 1 n ℓ D i ℓ , gain from removing x i from cluster ℓ , (9) A ℓ ( i ) = n ℓ n ℓ + 1 D i ℓ , cost of inserting x i into cluster ℓ , (10) A_\ell(i)=\frac{n_\ell}{n_\ell+1}D_{i\ell},\qquad\text{cost of inserting }x_i\text{ into cluster }\ell, \tag*{(10)} A ℓ ( i ) = n ℓ + 1 n ℓ D i ℓ , cost of inserting x i into cluster ℓ , (10) R ℓ ( i , j ) = n ℓ ( D i ℓ + D j ℓ ) − p i j n ℓ − 2 , gain from removing x i and x j from cluster ℓ , (11) R_\ell(i,j)=\frac{n_\ell(D_{i\ell}+D_{j\ell})-p_{ij}}{n_\ell-2},\qquad\text{gain from removing }x_i\text{ and }x_j\text{ from cluster }\ell, \tag*{(11)} R ℓ ( i , j ) = n ℓ − 2 n ℓ ( D i ℓ + D j ℓ ) − p ij , gain from removing x i and x j from cluster ℓ , (11) A ℓ ( i , j ) = n ℓ ( D i ℓ + D j ℓ ) + p i j n ℓ + 2 , cost of inserting x i and x j into cluster ℓ , (12) A_\ell(i,j)=\frac{n_\ell(D_{i\ell}+D_{j\ell})+p_{ij}}{n_\ell+2},\qquad\text{cost of inserting }x_i\text{ and }x_j\text{ into cluster }\ell, \tag*{(12)} A ℓ ( i , j ) = n ℓ + 2 n ℓ ( D i ℓ + D j ℓ ) + p ij , cost of inserting x i and x j into cluster ℓ , (12) T ℓ ( i , j ) = D i ℓ − D j ℓ + p i j n ℓ , gain from replacing x i with x j in cluster ℓ . (13) T_\ell(i,j)=D_{i\ell}-D_{j\ell}+\frac{p_{ij}}{n_\ell},\qquad\text{gain from replacing }x_i\text{ with }x_j\text{ in cluster }\ell. \tag*{(13)} T ℓ ( i , j ) = D i ℓ − D j ℓ + n ℓ p ij , gain from replacing x i with x j in cluster ℓ . (13)
The cluster contributions sum to the six gains in Table 1 (proof in Appendix § 15 ). For example, a forward chain removes x i x_i x i from cluster s s s , replaces x j x_j x j with x i x_i x i in cluster a a a , and inserts x j x_j x j into cluster b b b , giving G ( u , v ) = R s ( i ) + T a ( j , i ) − A b ( j ) G(u,v)=R_s(i)+T_a(j,i)-A_b(j) G ( u , v ) = R s ( i ) + T a ( j , i ) − A b ( j ) .
Once the required entries of D D D and p i j p_{ij} p ij are available, each gain takes O ( 1 ) O(1) O ( 1 ) time to evaluate, but unbalanced cluster sizes can still leave Θ ( n 2 k 2 ) \Theta(n^2k^2) Θ ( n 2 k 2 ) candidates (Proposition B.1 ). Only the same source, different destinations and forward chain configurations require optimizing a second destination b b b .
For a fixed anchor u = ( i : s → a ) u=(i:s\to a) u = ( i : s → a ) and partner sample j j j , both gains depend on b b b solely through − A b ( j ) -A_b(j) − A b ( j ) . When the destination domain is nonempty, choose any minimizer
b ⋆ ( j ; s , a ) ∈ arg min b ∈ [ k ] ∖ { s , a } A b ( j ) . b^\star(j;s,a)\in\underset{b\in[k]\setminus\{s,a\}}{\arg\min}\ A_b(j). b ⋆ ( j ; s , a ) ∈ b ∈ [ k ] ∖ { s , a } arg min A b ( j ) .
For each sample j j j , store an ordered Top-3 all-cluster list K j K_j K j of the min { 3 , k } \min\{3,k\} min { 3 , k } smallest scores A b ( j ) A_b(j) A b ( j ) , ranking all labels including the current source. The scores and all lists can be constructed from D D D in O ( n k ) O(nk) O ( nk ) time. Excluding at most two labels leaves a minimizing feasible label in K j ∖ { s , a } K_j\setminus\{s,a\} K j ∖ { s , a } , enabling constant-time destination queries and O ( n 2 k ) O(n^2k) O ( n 2 k ) anchor–partner evaluations per pass.
Table 1. Search spaces for the partner v = ( j : z j → b ) v=(j:z_j \to b) v = ( j : z j → b ) and exact gains for fixed u = ( i : s → a ) u=(i:s \to a) u = ( i : s → a ) .
ExactPairSearch( z , I ) (z,I) ( z , I ) restricts both moved indices to I ⊆ [ n ] I \subseteq[n] I ⊆ [ n ] while using the full clustering statistics and destination domains. It returns the best positive gain and its move, or ( 0 , ∅ ) (0,\varnothing) ( 0 , ∅ ) . After initial Lloyd convergence, Pair-Driven Two-Point Local Search (PD-2PLS) alternates Min-D-LO one-point descent with ExactPairSearch( z , [ n ] ) (z,[n]) ( z , [ n ]) (Appendix § 15 .§ 1 ). Here the descent phase repeatedly accepts the feasible one-point move with the largest positive gain until D-locality is reached.
Throughout one- and two-point descent, { n ℓ , μ ℓ } \{n_\ell,\mu_\ell\} { n ℓ , μ ℓ } and D D D are maintained across moves. A one-point move changes two clusters, and a connected two-point move changes at most three. The affected cluster counts and means are updated from the moved samples, and only the corresponding columns of D D D are refreshed, costing O ( n d ) O(nd) O ( n d ) per accepted move. A Min-D-LO gain scan costs O ( n k ) O(nk) O ( nk ) , so one scan and its possible update cost O ( n k + n d ) O(nk+nd) O ( nk + n d ) ; no full O ( n d k ) O(ndk) O ( n d k ) distance recomputation is needed.
Safe Boundary-Point Screening
At a D-local state, anchored search still considers up to n ( n − 1 ) n(n-1) n ( n − 1 ) ordered sample pairs. Motivated by the boundary-point intuition, Boundary-Point Screening (BPS) constructs an upper bound U i U_i U i on every feasible connected two-point gain involving i i i and discards i i i if U i ≤ 0 U_i \le0 U i ≤ 0 .
Fix an anchor u = ( i : s → a ) u=(i:s \to a) u = ( i : s → a ) with s = z i s=z_i s = z i . For configuration τ \tau τ , the envelope key e = e ( τ , u ) e=e(\tau,u) e = e ( τ , u ) in Table 2 records the cluster labels needed by the partner terms and the pivot; anchors with the same key share an envelope.
Table 2. Reusable envelope families for u = ( i : s → a ) u=(i:s\to a) u = ( i : s → a ) , with s ≠ a s\ne a s = a .
To construct this bound, we first remove the dependence on the partner destination b b b :
G ( u , v ) ≤ C τ ( u ) + Q e ( j ) + η e p i j . (14) G(u,v) \le C_\tau(u)+Q_e(j)+\eta_e p_{ij}. \tag*{(14)} G ( u , v ) ≤ C τ ( u ) + Q e ( j ) + η e p ij . (14)
Here C τ ( u ) C_\tau(u) C τ ( u ) collects the anchor terms and Q e ( j ) Q_e(j) Q e ( j ) the partner terms; their coefficients are listed in Table 6 in Appendix § 16 . Equality holds when b b b is prescribed or chosen as b ∗ ( j ; s , a ) b^*(j;s,a) b ∗ ( j ; s , a ) .
Table 6. Separable gains for u = ( i : s → a ) u=(i:s\to a) u = ( i : s → a ) , with s = z i s=z_i s = z i and envelope key e = e ( τ , u ) e=e(\tau,u) e = e ( τ , u ) .
Next, introduce a pivot o e ∈ R d o_e \in\mathbb{R}^d o e ∈ R d and write ρ e ( h ) = ∥ x h − o e ∥ \rho_e(h)=\lVert x_h-o_e\rVert ρ e ( h ) = ∥ x h − o e ∥ for each sample h h h . The triangle and reverse triangle inequalities, accounting for the sign of η e \eta_e η e , yield
η e p i j ≤ η e ρ e ( i ) 2 + 2 ∣ η e ∣ ρ e ( i ) ρ e ( j ) + η e ρ e ( j ) 2 . (15) \eta_e p_{ij} \le\eta_e\rho_e(i)^2+2|\eta_e|\rho_e(i)\rho_e(j)+\eta_e\rho_e(j)^2. \tag*{(15)} η e p ij ≤ η e ρ e ( i ) 2 + 2∣ η e ∣ ρ e ( i ) ρ e ( j ) + η e ρ e ( j ) 2 . (15)
Substituting this inequality into equation (14) , we define the partner line and the resulting bound by
L e , j ( ρ ) = 2 ∣ η e ∣ ρ e ( j ) ρ + Q e ( j ) + η e ρ e ( j ) 2 , L_{e,j}(\rho)=2|\eta_e|\rho_e(j)\rho+Q_e(j)+\eta_e\rho_e(j)^2, L e , j ( ρ ) = 2∣ η e ∣ ρ e ( j ) ρ + Q e ( j ) + η e ρ e ( j ) 2 ,
G ( u , v ) ≤ C τ ( u ) + η e ρ e ( i ) 2 + L e , j ( ρ e ( i ) ) . (16) G(u,v)\le C_\tau(u)+\eta_e\rho_e(i)^2+L_{e,j}(\rho_e(i)). \tag*{(16)} G ( u , v ) ≤ C τ ( u ) + η e ρ e ( i ) 2 + L e , j ( ρ e ( i )) . (16)
For a fixed key e e e , each partner j j j defines an affine function of the scalar query radius ρ \rho ρ .
Finally, we maximize over the shared partner superset J ~ e ⊇ J τ ( u ) \widetilde{J}_e \supseteq J_\tau(u) J e ⊇ J τ ( u ) in Table 2 to obtain a bound depending only on the anchor and configuration:
U τ ( u ) : = C τ ( u ) + η e ρ e ( i ) 2 + H e ( ρ e ( i ) ) ≥ G ( u , v ) , where H e ( ρ ) = max j ∈ J ~ e L e , j ( ρ ) . (17) U_\tau(u):=C_\tau(u)+\eta_e\rho_e(i)^2+H_e(\rho_e(i))\ge G(u,v),\qquad\text{where}\quad H_e(\rho)=\max_{j\in\widetilde{J}_e}L_{e,j}(\rho). \tag*{(17)} U τ ( u ) := C τ ( u ) + η e ρ e ( i ) 2 + H e ( ρ e ( i )) ≥ G ( u , v ) , where H e ( ρ ) = j ∈ J e max L e , j ( ρ ) . (17)
The remaining computational issues are: (i) How can H e H_e H e be constructed and queried efficiently? (ii) How can it be reused across anchors? (iii) How should its pivot o e o_e o e be chosen?
A line upper envelope can be constructed in O ( ∣ J ~ e ∣ log ∣ J ~ e ∣ ) \mathcal{O}(|\widetilde{\mathcal{J}}_e|\log|\widetilde{\mathcal{J}}_e|) O ( ∣ J e ∣ log ∣ J e ∣ ) time and queried in O ( log ∣ J ~ e ∣ ) \mathcal{O}(\log|\widetilde{\mathcal{J}}_e|) O ( log ∣ J e ∣ ) time by binary search on its breakpoints [8 ] ; construction details are in Appendix § 16 .
For each feasible key in Table 2 , the coefficients and pivot are fixed, so one envelope serves all corresponding anchors. There are at most 6 ( k − 1 ) n 6(k-1)n 6 ( k − 1 ) n partner lines in total, and each envelope contains at most n n n lines, giving O ( n k log n ) \mathcal{O}(nk\log n) O ( nk log n ) total construction time.
Accordingly, we aggregate the configuration bounds into the sample certificate
U i = max a ∈ [ k ] ∖ { z i } max τ ∈ F ( u ) U τ ( u ) , u = ( i : z i → a ) . (18) U_i=\max_{a\in[k]\setminus\{z_i\}}\max_{\tau\in\mathcal{F}(u)}U_\tau(u),\qquad u=(i:z_i\to a). \tag*{(18)} U i = a ∈ [ k ] ∖ { z i } max τ ∈ F ( u ) max U τ ( u ) , u = ( i : z i → a ) . (18)
Given the line coefficients and query radii, constructing the envelopes and computing all certificates takes O ( n k log n ) \mathcal{O}(nk\log n) O ( nk log n ) time. We therefore retain the boundary candidate set B = { i ∈ [ n ] : U i > 0 } \mathbb{B}=\{i\in[n]:U_i>0\} B = { i ∈ [ n ] : U i > 0 } and let m = ∣ B ∣ m=|\mathbb{B}| m = ∣ B ∣ . At a D-local state, every improving two-point move is connected, so both of its samples have positive certificates and belong to B \mathbb{B} B . Therefore, ExactPairSearch( z , B ) (z,\mathbb{B}) ( z , B ) preserves the maximum positive gain while restricting distance evaluation and search to retained pairs.
Figure 1 illustrates the pivot choices. For fixed radii, equation 15 is tight for opposing directions when η e > 0 \eta_e>0 η e > 0 and aligned directions when η e < 0 \eta_e<0 η e < 0 . The radii can be evaluated in constant time from D D D and the squared centroid distance Δ s , a = ∥ μ s − μ a ∥ 2 \Delta_{s,a}=\lVert\mu_s-\mu_a\rVert^2 Δ s , a = ∥ μ s − μ a ∥ 2 , computed in O ( k 2 d ) \mathcal{O}(k^2d) O ( k 2 d ) time (Appendix § 16 ).
Figure 1. Schematic pivot choices for the six connected configurations: (a) both same-source configurations; (b) forward chains and swaps; (c) different sources with the same destination; and (d) backward chains. Shaded regions denote clusters.
BPS-2PLS uses the same initial Lloyd run and Min-D-LO descent, followed by screening and ExactPairSearch( z , B ) (z,\mathbb{B}) ( z , B ) (Algorithm 2); strict descent ensures finite termination at a two-point local optimum. Screening does not require evaluating any p i j p_{ij} p ij . Candidate distances are computed in blocks in O ( m 2 d ) \mathcal{O}(m^2d) O ( m 2 d ) time and reused across destination choices, giving O ( m 2 ( d + k ) ) \mathcal{O}(m^2(d+k)) O ( m 2 ( d + k )) pair-search time. For T L T_L T L Lloyd iterations, T 1 T_1 T 1 one-point gain scans, and T 2 T_2 T 2 screening-and-search rounds, the total cost is
O ( T L n d k + T 1 ( n d + n k ) + T 2 [ n d + n k log n + k 2 d + m 2 ( d + k ) ] ) . (19) \mathcal{O}\left(T_Lndk+T_1(nd+nk)+T_2\left[nd+nk\log n+k^2d+m^2(d+k)\right]\right). \tag*{(19)} O ( T L n d k + T 1 ( n d + nk ) + T 2 [ n d + nk log n + k 2 d + m 2 ( d + k ) ] ) . (19)
where m m m is the maximum retained count over the T 2 T_2 T 2 rounds. The scan and round counts include unsuccessful termination checks; the n d nd n d term in each round covers an accepted pair’s local state update. Appendix C.6 gives the bound with varying candidate counts and compares lazy evaluation with full caching.
Candidate-Set Size Guarantees
We formalize the boundary-point intuition by locating retained samples where the squared distances to the nearest and second-nearest empirical centers are close, and then derive logarithmic candidate-size bounds under two sampling models.
For a D-local state z z z with k ≥ 2 k \ge2 k ≥ 2 , write n min = min ℓ n ℓ n_{\min} = \min_{\ell} n_{\ell} n m i n = min ℓ n ℓ and p max = max i , j ∈ [ n ] p i j p_{\max} = \max_{i,j \in[n]} p_{ij} p m a x = max i , j ∈ [ n ] p ij , the minimum cluster size and the squared sample diameter. Let D ( 1 ) ( x ; z ) ≤ D ( 2 ) ( x ; z ) D_{(1)}(x; z) \le D_{(2)}(x; z) D ( 1 ) ( x ; z ) ≤ D ( 2 ) ( x ; z ) be the two smallest values of ∥ x − μ ℓ ( z ) ∥ 2 \lVert x - \mu_{\ell}(z) \rVert^2 ∥ x − μ ℓ ( z ) ∥ 2 , counting ties. Suppressing z z z when it is fixed, define the boundary region
U ( z ) : = { x ∈ R d : D ( 2 ) ( x ) − D ( 1 ) ( x ) ≤ 25 p max n min } . \mathrm{U}(z) := \left\{x \in\mathbb{R}^{d} : D_{(2)}(x) - D_{(1)}(x) \le\frac{25p_{\max}}{n_{\min}}\right\}. U ( z ) := { x ∈ R d : D ( 2 ) ( x ) − D ( 1 ) ( x ) ≤ n m i n 25 p m a x } .
Proposition 7.1 (Geometric localization of retained samples). Let z z z be a D D D -local state with n min ≥ 4 n_{\min} \ge4 n m i n ≥ 4 . For the exact-arithmetic BPS certificate defined in § 6 , the candidate set B ( z ) \mathbb{B}(z) B ( z ) satisfies
B ( z ) ⊆ { i ∈ [ n ] : x i ∈ U ( z ) } . (20) \mathbb{B}(z) \subseteq\{i \in[n] : x_i \in\mathrm{U}(z)\}. \tag*{(20)} B ( z ) ⊆ { i ∈ [ n ] : x i ∈ U ( z )} . (20)
For distinct empirical centers, U ( z ) \mathrm{U}(z) U ( z ) is a union of portions of at most ( k 2 ) \binom{k}{2} ( 2 k ) slabs around pairwise equal-distance hyperplanes. The illustration on the right shows a two-dimensional Gaussian mixture, in which only 20 of the 3,000 samples lie in U ( z ) \mathrm{U}(z) U ( z ) . The proof is given in Appendix § 17 .§ 1 .
Figure U.
Localization alone does not guarantee a small candidate set: bounded, balanced two-cluster instances can have m = n m = n m = n (Appendix § 17 .§ 2 ). To obtain a sublinear bound, we control the boundary-region probability mass and squared sample diameter under nonvanishing empirical cluster occupancy.
Theorem 7.2 (Logarithmic candidate-set size). Let x 1 , … , x n x_1, \ldots, x_n x 1 , … , x n be i.i.d. random vectors from a fixed distribution P P P on R d \mathbb{R}^{d} R d , and let x 1 , … , x n \boldsymbol{x}_1, \ldots, \boldsymbol{x}_n x 1 , … , x n denote their realizations. Fix k k k , d d d and α ∈ ( 0 , 1 / k ] \alpha\in(0, 1/k] α ∈ ( 0 , 1/ k ] . Define the admissible state class
Z n , α = { z ∈ Z k : z is D -local and min ℓ n ℓ ( z ) ≥ α n } , (21) \mathcal{Z}_{n,\alpha} = \{z \in\mathcal{Z}_k : z\text{ is }D\text{-local and }\min_{\ell} n_{\ell}(z) \ge\alpha n\}, \tag*{(21)} Z n , α = { z ∈ Z k : z is D -local and ℓ min n ℓ ( z ) ≥ α n } , (21) and write m ( z ) = ∣ B ( z ) ∣ m(z) = |\mathbb{B}(z)| m ( z ) = ∣ B ( z ) ∣ . Suppose P P P satisfies either of the following conditions:
P P P is supported on a fixed ball of radius R R R centered at x 0 x_0 x 0 and has a Lebesgue density f f f with ∥ f ∥ ∞ < ∞ \lVert f\rVert_{\infty} < \infty ∥ f ∥ ∞ < ∞ .
P P P is a Gaussian mixture P = ∑ ℓ = 1 k π ℓ N ( θ ℓ , Σ ℓ ) P = \sum_{\ell=1}^{k} \pi_{\ell}\mathcal{N}(\theta_{\ell}, \Sigma_{\ell}) P = ∑ ℓ = 1 k π ℓ N ( θ ℓ , Σ ℓ ) with π ℓ > 0 \pi_{\ell} > 0 π ℓ > 0 , ∑ ℓ = 1 k π ℓ = 1 \sum_{\ell=1}^{k} \pi_{\ell} = 1 ∑ ℓ = 1 k π ℓ = 1 , Σ ℓ ≻ 0 \Sigma_{\ell} \succ0 Σ ℓ ≻ 0 .
The mixture parameters ( π ℓ , θ ℓ , Σ ℓ ) (\pi_{\ell}, \theta_{\ell}, \Sigma_{\ell}) ( π ℓ , θ ℓ , Σ ℓ ) are fixed population quantities, whereas μ ℓ ( z ) \mu_{\ell}(z) μ ℓ ( z ) are empirical cluster means. For the exact-arithmetic BPS certificate defined in § 6 , set m ‾ n = 0 \overline{m}_n = 0 m n = 0 if Z n , α \mathcal{Z}_{n,\alpha} Z n , α is empty. Otherwise,
m ‾ n : = sup z ∈ Z n , α m ( z ) = O P ( log n ) . (22) \overline{m}_n := \sup_{z \in\mathcal{Z}_{n,\alpha}} m(z) = O_{\mathbb{P}}(\log n). \tag*{(22)} m n := z ∈ Z n , α sup m ( z ) = O P ( log n ) . (22)
Here O P O_{\mathbb{P}} O P denotes order in probability (van der Vaart, 1998). The proof combines uniform slab counting, diameter control, and empirical center separation (Appendices § 17 .§ 3 –§ 17 .§ 4 ). The bound covers data-dependent clusterings; the mixture case allows unequal weights and anisotropic covariances without requiring separated component means.
For fixed d d d , k k k , if a sequence of D D D -local outputs satisfies the occupancy condition with probability tending to one, then m / n → 0 m/n \to0 m / n → 0 in probability and the screening-and-search cost after one-point descent, including lazy distance evaluation, is O P ( n log n ) O_{\mathbb{P}}(n \log n) O P ( n log n ) . The theorem neither guarantees occupancy attainment nor bounds the number of Lloyd iterations, one-point scans, or two-point rounds.
Experiments
We evaluate clustering quality and cost, heuristic enhancement, and candidate-set scaling. Datasets, methods, metrics, and timing protocols are detailed in Appendix § 18 .
Comparison of Sample-Reassignment-Based Methods
We compare six sample-reassignment methods using ten shared initializations, with each method–initialization pair timed five times (Appendix § 18 ). In Table 3 , BPS-2PLS attains the lowest available mean WCSS on ten of twelve datasets, including ties. Hartigan yields lower WCSS on MNIST-2000 and Sensorless; however, neighborhood inclusion does not impose an ordering on independently reached local optima.
Table 3. Mean WCSS and runtime (seconds) over ten shared initializations. Bold: lowest available WCSS. Dashes mark Hartigan runs omitted because of excessive runtime.
Table 3 shows that BPS-2PLS reduces mean WCSS relative to Lloyd by 4.30% on Yale and 7.28% on ORL. On five of the six largest datasets, the reductions are below 0.06%, including the CIFAR-10 tie; the reduction on Sensorless is 1.11%. The diminishing influence of individual samples on larger clusters offers a possible explanation (Appendix § 19 ).
In terms of computational cost, BPS-2PLS takes 1.08–2.57× as long as D-LO on eight datasets and less time on the other four. Hartigan takes 11.09× and 242.76× as long as BPS-2PLS on MNIST-2000 and Sensorless, respectively. Attributing speedups specifically to screening requires paired BPS-on/off timings.
Figure 2 shows how two-point moves extend descent beyond one-point local optima. On Yale, ORL, USPS-1000, and COIL20, successful two-point moves are followed by further one-point improvements. For example, on COIL20, the first D-local solution retains 99.87% of the initial Lloyd WCSS, whereas the final solution retains 95.62%; most of this additional reduction comes from one-point moves made possible by the two-point updates. The displayed MNIST-2000 run instead terminates at its first D-local solution, where two-point search finds no improvement.
Figure 2. BPS-2PLS descent trajectories on five datasets. The x x x -axis shows the iteration count after Lloyd convergence, and the y y y -axis shows WCSS as a percentage of the WCSS at Lloyd convergence.
Enhancing Heuristic Methods
Table 4 evaluates terminal (Post ) and internal (Inner ) BPS-2PLS refinement; insertion points are detailed in Appendix § 19 .§ 2 . Among the four heuristic methods, Post reduces mean WCSS in all eighteen available comparisons. For LocalSearch, Post reduces mean WCSS by 38.12–41.87%; this refinement includes centroid recomputation and one-point descent, which are absent from the baseline. Inner lowers mean WCSS relative to Baseline in twelve of thirteen available comparisons but does not consistently outperform Post. For J-Means, Inner uses 37.6% and 40.2% of the baseline runtime on Yale and ORL, while Post achieves lower mean WCSS. For MergeSplit, Inner takes 1.56–5.32× as long as Post and gives lower mean WCSS on Yale, ORL, and MNIST-2000; on COIL20, it has higher mean WCSS than both Baseline and Post.
Table 4. Heuristic enhancement: mean WCSS and runtime (seconds). Bold: lowest WCSS within each method and dataset, including ties; dashes: omitted runs.
Candidate-Set Size versus Sample Size
We study random subsets drawn from six datasets, recording m m m at the first D-local state before any two-point move. Figure 3 summarizes five subsets per size, each averaged over three initializations; subset sizes and aggregation details are in Appendix § 19 .§ 3 .
Figure 3. Retained candidate count m m m versus sample size n n n at the first D-local state. Markers show means over five random subsets, each averaged over three initializations; error bars indicate one standard deviation across subsets.
The candidate counts show no sustained increase across the evaluated range: 20News and CIFAR-100 rise over smaller sample sizes before leveling off or decreasing, while the other datasets are flat, decreasing, or non-monotone. At the largest available size, mean retained fractions range from 0.10% to 2.81%, corresponding to mean pruning rates above 97% in all six cases. These observations motivate studying sharper bounds for algorithmic outputs (Appendix § 19 .§ 3 ).
Conclusion
We introduced r r r -point local optimality and developed BPS-2PLS to certify two-point local optima of k k k -means. Connected moves yield six configurations, while safe screening confines distance evaluation and search to retained samples. Under the stated sampling and occupancy conditions, geometric localization gives m = O P ( log n ) m = O_{\mathbb{P}}(\log n) m = O P ( log n ) and O P ( n log n ) O_{\mathbb{P}}(n\log n) O P ( n log n ) screening-and-search time after one-point descent for fixed d d d , k k k . Experiments show that BPS-2PLS enables further descent beyond one-point local optima and can improve existing heuristics when used as a refinement.
Screening can retain all samples, and the theorem bounds neither one-point descent time nor the number of rounds. Future work includes larger neighborhoods, faster screening and descent, and sharper candidate-size bounds for algorithmic outputs.
AI USE STATEMENT
In this work, we used generative AI tools solely to assist with grammar, spelling, and sentence clarity. We have reviewed all AI-assisted edits and assume full responsibility for the final manuscript. The generative AI contributed in no other way to this work. The research idea, experimental design, and all other substantive content were developed and completed by the authors.
ETHICS STATEMENT
We confirm that our work adheres to the ICLR Code of Ethics. This work uses publicly available datasets that contain no personally identifiable information. Given the strictly technical nature of this contribution, we foresee no ethical issues or potential misuse.
REPRODUCIBILITY STATEMENT
Proofs of the theoretical results are provided in Appendices § 13 , § 14 , and § 17 ; detailed algorithms and screening constructions are given in Appendices § 15 and § 16 . Appendix § 18 specifies the dataset sources and representations, comparison methods and search budgets, initialization protocol, evaluation metrics, timing procedure, and computing environment. Appendices § 19 .§ 2 , § 19 .§ 3 and § 19 .§ 6 describe the heuristic refinement insertion points and candidate-set scaling protocol.
Proofs for r r r -Point Local Optimality
Exact Simultaneous-Reassignment Gain
To analyze interactions among the reassignments in a simultaneous move M \mathrm{M} M , we first define the changes in the size and sum of each cluster ℓ \ell ℓ by
Δ n ℓ ( M ) = ∣ { t : b t = ℓ } ∣ − ∣ { t : a t = ℓ } ∣ , Δ s ℓ ( M ) = ∑ t : b t = ℓ x i t − ∑ t : a t = ℓ x i t . (23) \Delta n_{\ell}(\mathrm{M}) = \lvert\{t : b_t = \ell\}\rvert- \lvert\{t : a_t = \ell\}\rvert,\qquad\Delta s_{\ell}(\mathrm{M}) = \sum_{t:b_t=\ell} x_{it} - \sum_{t:a_t=\ell} x_{it}. \tag*{(23)} Δ n ℓ ( M ) = ∣{ t : b t = ℓ }∣ − ∣{ t : a t = ℓ }∣ , Δ s ℓ ( M ) = t : b t = ℓ ∑ x i t − t : a t = ℓ ∑ x i t . (23)
Let V ( M ) \mathrm{V}(\mathrm{M}) V ( M ) be the set of affected clusters. Equation (1) then yields the following exact gain.
Proposition A.1. For every feasible simultaneous reassignment M \mathrm{M} M ,
G ( M ; z ) = ∑ ℓ ∈ V ( M ) ( ∥ s ℓ + Δ s ℓ ( M ) ∥ 2 n ℓ + Δ n ℓ ( M ) − ∥ s ℓ ∥ 2 n ℓ ) . (24) G(\mathrm{M};z) = \sum_{\ell\in\mathrm{V}(\mathrm{M})}\left(\frac{\lVert s_{\ell}+\Delta s_{\ell}(\mathrm{M})\rVert^2}{n_{\ell}+\Delta n_{\ell}(\mathrm{M})}-\frac{\lVert s_{\ell}\rVert^2}{n_{\ell}}\right). \tag*{(24)} G ( M ; z ) = ℓ ∈ V ( M ) ∑ ( n ℓ + Δ n ℓ ( M ) ∥ s ℓ + Δ s ℓ ( M ) ∥ 2 − n ℓ ∥ s ℓ ∥ 2 ) . (24)
Proof of Proposition A.1. For each cluster ℓ \ell ℓ , the move changes its size and sum to
n ℓ M = n ℓ + Δ n ℓ ( M ) , s ℓ M = s ℓ + Δ s ℓ ( M ) . n_{\ell}^{\mathrm{M}} = n_{\ell}+\Delta n_{\ell}(\mathrm{M}),\qquad s_{\ell}^{\mathrm{M}} = s_{\ell}+\Delta s_{\ell}(\mathrm{M}). n ℓ M = n ℓ + Δ n ℓ ( M ) , s ℓ M = s ℓ + Δ s ℓ ( M ) .
Because M \mathrm{M} M is feasible, n ℓ M ≥ 1 n_{\ell}^{\mathrm{M}}\geq1 n ℓ M ≥ 1 for every ℓ \ell ℓ . By equation (1) , the common term ∑ i ∥ x i ∥ 2 \sum_i\lVert x_i\rVert^2 ∑ i ∥ x i ∥ 2 cancels in F ( z ) − F ( z M ) F(z)-F(z^{\mathrm{M}}) F ( z ) − F ( z M ) , as do the contributions of all untouched clusters. Substituting the updated statistics of the affected clusters yields equation (24) .
Componentwise Additivity and Connected Moves
Proposition A.2 (Componentwise additivity). Let M \mathrm{M} M be feasible and let M 1 , … , M h \mathrm{M}_1,\ldots,\mathrm{M}_h M 1 , … , M h be the moves induced by the weakly connected components of G ( M ) \mathcal{G}(\mathrm{M}) G ( M ) . Then every M j \mathrm{M}_j M j is feasible when applied directly to z z z , and G ( M ; z ) = ∑ j = 1 h G ( M j ; z ) G(\mathrm{M};z)=\sum_{j=1}^{h}G(\mathrm{M}_j;z) G ( M ; z ) = ∑ j = 1 h G ( M j ; z ) .
Proof of Proposition A.2. Different weakly connected components of G ( M ) \mathcal{G}(\mathrm{M}) G ( M ) have disjoint vertex sets and therefore mutually disjoint sets of cluster sufficient statistics. For any cluster ℓ \ell ℓ touched by component M j \mathrm{M}_j M j , no transfer from another component can enter or leave ℓ \ell ℓ , so
Δ n ℓ ( M j ) = Δ n ℓ ( M ) , Δ s ℓ ( M j ) = Δ s ℓ ( M ) . \Delta n_{\ell}(\mathrm{M}_j)=\Delta n_{\ell}(\mathrm{M}),\qquad\Delta s_{\ell}(\mathrm{M}_j)=\Delta s_{\ell}(\mathrm{M}). Δ n ℓ ( M j ) = Δ n ℓ ( M ) , Δ s ℓ ( M j ) = Δ s ℓ ( M ) .
Since the full move is feasible, every touched cluster has positive final size under its component move as well, while all other clusters remain unchanged; hence each M j \mathsf{M}_j M j is feasible. Partitioning the sum in equation 24 over the disjoint component vertex sets gives
G ( M ; z ) = ∑ j = 1 h G ( M j ; z ) . G(\mathsf{M};z)=\sum_{j=1}^{h}G(\mathsf{M}_j;z). G ( M ; z ) = j = 1 ∑ h G ( M j ; z ) .
Proof of Theorem 4.4. If z z z is r r r -point locally optimal, every connected feasible move of size at most r r r is non-improving by definition. Conversely, assume that every such connected move is non-improving and consider an arbitrary feasible move M \mathsf{M} M with ∣ M ∣ ≤ r |\mathsf{M}|\le r ∣ M ∣ ≤ r . If G ( M ) \mathcal{G}(\mathsf{M}) G ( M ) is connected, then G ( M ; z ) ≤ 0 G(\mathsf{M};z)\le0 G ( M ; z ) ≤ 0 by assumption. Otherwise, let M 1 , … , M h \mathsf{M}_1,\ldots,\mathsf{M}_h M 1 , … , M h denote its component moves. By Proposition A.2, each M j \mathsf{M}_j M j is feasible and connected, with ∣ M j ∣ ≤ r |\mathsf{M}_j|\le r ∣ M j ∣ ≤ r , and therefore G ( M j ; z ) ≤ 0 G(\mathsf{M}_j;z)\le0 G ( M j ; z ) ≤ 0 . Hence
G ( M ; z ) = ∑ j = 1 h G ( M j ; z ) ≤ 0. G(\mathsf{M};z)=\sum_{j=1}^{h}G(\mathsf{M}_j;z)\le0. G ( M ; z ) = j = 1 ∑ h G ( M j ; z ) ≤ 0.
Thus no feasible move involving at most r r r samples improves the objective, proving r r r -point local optimality.
For the final statement, suppose z z z is ( r − 1 ) (r-1) ( r − 1 ) -point locally optimal and an improving exact-r r r move M \mathsf{M} M is disconnected. Every component of G ( M ) \mathcal{G}(\mathsf{M}) G ( M ) contains at most r − 1 r-1 r − 1 edges and is therefore non-improving. Componentwise additivity would then imply G ( M ; z ) ≤ 0 G(\mathsf{M};z)\le0 G ( M ; z ) ≤ 0 , a contradiction.
Counting Connected Exact-r r r Moves
Connectedness removes structurally redundant moves, but it does not by itself make general exact-r r r certification inexpensive. Let
C = r ( z ) = { z M ∈ N = r ( z ) : G ( M ) is weakly connected } . (25) \mathcal{C}_{=r}(z)=\{\mathsf{z}^{\mathsf{M}}\in\mathcal{N}_{=r}(z):\mathcal{G}(\mathsf{M})\text{ is weakly connected}\}. \tag*{(25)} C = r ( z ) = { z M ∈ N = r ( z ) : G ( M ) is weakly connected } . (25)
denote the connected exact-r r r shell.
Proposition B.1 (Size of the connected exact-r r r shell). Fix r ≥ 2 r\ge2 r ≥ 2 . In general,
∣ C = r ( z ) ∣ ≤ ( n r ) ( k − 1 ) r . (26) |\mathcal{C}_{=r}(z)|\le\binom{n}{r}(k-1)^r. \tag*{(26)} ∣ C = r ( z ) ∣ ≤ ( r n ) ( k − 1 ) r . (26) This order is attainable up to r r r -dependent constants: a cluster of size Θ ( n ) \Theta(n) Θ ( n ) can yield Θ r ( n r k r ) \Theta_r(n^r k^r) Θ r ( n r k r ) connected moves. If instead the partition is β \beta β -balanced, meaning n a ≤ β n / k n_a\le\beta n/k n a ≤ β n / k for every a a a , then
∣ C = r ( z ) ∣ = O r ( β r n r k ) . (27) |\mathcal{C}_{=r}(z)|=\mathcal{O}_r(\beta^r n^r k). \tag*{(27)} ∣ C = r ( z ) ∣ = O r ( β r n r k ) . (27) For equal-size balanced partitions with k ≥ r + 1 k\ge r+1 k ≥ r + 1 and n / k ≥ 2 n/k\ge2 n / k ≥ 2 , this order is tight:
∣ C = r ( z ) ∣ = Θ r ( n r k ) . (28) |\mathcal{C}_{=r}(z)|=\Theta_r(n^r k). \tag*{(28)} ∣ C = r ( z ) ∣ = Θ r ( n r k ) . (28)
Proof of Proposition B.1. The upper bound in equation 26 follows immediately from C = r ( z ) ⊆ N = r ( z ) \mathcal{C}_{=r}(z)\subseteq\mathcal{N}_{=r}(z) C = r ( z ) ⊆ N = r ( z ) and ∣ N = r ( z ) ∣ ≤ ( n r ) ( k − 1 ) r |\mathcal{N}_{=r}(z)|\le\binom{n}{r}(k-1)^r ∣ N = r ( z ) ∣ ≤ ( r n ) ( k − 1 ) r . To see that connectedness alone does not improve the worst-case order, suppose cluster a a a has size n a ≥ r + 1 n_a\ge r+1 n a ≥ r + 1 . Choose any r r r samples from a a a and independently send each to any of the other k − 1 k-1 k − 1 clusters. The source cluster remains nonempty, and all transfer edges share the source vertex a a a , so every such move is feasible and connected. Consequently,
∣ C = r ( z ) ∣ ≥ ( n a r ) ( k − 1 ) r . |\mathcal{C}_{=r}(z)|\ge\binom{n_a}{r}(k-1)^r. ∣ C = r ( z ) ∣ ≥ ( r n a ) ( k − 1 ) r .
If n a = Θ ( n ) n_a=\Theta(n) n a = Θ ( n ) and r r r is fixed, this matches the upper bound up to r r r -dependent constants and gives the stated Θ r ( n r k r ) \Theta_r(n^r k^r) Θ r ( n r k r ) order.
It remains to prove the balanced bound. For an r r r -sample support I ⊆ [ n ] \mathcal{I}\subseteq[n] I ⊆ [ n ] , let s = ∣ { z i : i ∈ I } ∣ s=|\{z_i:i\in\mathcal{I}\}| s = ∣ { z i : i ∈ I } ∣ be its number of distinct source clusters. Fix s ∈ { 1 , … , min ( r , k ) } s\in\{1,\ldots,\min(r,k)\} s ∈ { 1 , … , min ( r , k )} and a set A ⊆ [ k ] A\subseteq[k] A ⊆ [ k ] of s s s source clusters. Under β \beta β -balance,
∑ a ∈ A n a ≤ s β n k . \sum_{a\in A}n_a\le s\beta\frac{n}{k}. a ∈ A ∑ n a ≤ s β k n .
Hence the number of r r r -sample supports whose source clusters are contained in A A A is at most
( ∑ a ∈ A n a r ) ≤ 1 r ! ( s β n k ) r . \binom{\sum_{a\in A} n_a}{r} \le\frac{1}{r!}\left(s\beta\frac{n}{k}\right)^r. ( r ∑ a ∈ A n a ) ≤ r ! 1 ( s β k n ) r .
Summing over the at most ( k s ) \binom{k}{s} ( s k ) choices of A A A shows that the number of supports with source diversity s s s is
O r ( β r n r k s − r ) . (29) O_r\left(\beta^r n^r k^{s-r}\right). \tag*{(29)} O r ( β r n r k s − r ) . (29)
Now fix one such support. A connected graph with r r r edges has at most r + 1 r+1 r + 1 vertices, so in addition to its s s s source clusters it can contain at most r + 1 − s r+1-s r + 1 − s destination-only clusters. If exactly t t t destination-only clusters are used, choose them in at most ( k − s t ) \binom{k-s}{t} ( t k − s ) ways. Once these clusters are fixed, each destination lies among at most s + t s+t s + t cluster labels. Ignoring self-loop and connectivity restrictions only enlarges the count, so the number of destination assignments is at most
∑ t = 0 r + 1 − s ( k − s t ) ( s + t ) r = O r ( k r + 1 − s ) . \sum_{t=0}^{r+1-s} \binom{k-s}{t}(s+t)^r = O_r\left(k^{r+1-s}\right). t = 0 ∑ r + 1 − s ( t k − s ) ( s + t ) r = O r ( k r + 1 − s ) .
Multiplying by equation (29) gives O r ( β r n r k ) O_r(\beta^r n^r k) O r ( β r n r k ) connected candidates for each s s s . Summing over at most r r r possible values of s s s proves equation (27) .
For sharpness, suppose all clusters have the same size n / k ≥ 2 n/k \ge2 n / k ≥ 2 and k ≥ r + 1 k \ge r+1 k ≥ r + 1 . Choose r r r distinct source clusters, one sample from each, and one common destination cluster outside those sources. Sending all selected samples to the common destination gives a feasible connected in-star. The number of such moves is
( k r ) ( n k ) r ( k − r ) = Θ r ( n r k ) , \binom{k}{r}\left(\frac{n}{k}\right)^r(k-r)=\Theta_r(n^r k), ( r k ) ( k n ) r ( k − r ) = Θ r ( n r k ) ,
which matches the upper bound for β = 1 \beta=1 β = 1 and proves equation (28) .
Details for Exact Two-Point Local Search
Algorithms and Shared Search Routine
Algorithms 1 and 2 give the complete PD-2PLS and BPS-2PLS procedures in exact arithmetic. Both run Lloyd initially and then alternate best-improvement one-point descent with a two-point search. In the pseudocode, Min-D-LO denotes the one-point descent phase: scan all feasible moves using equation (4) , accept a move with the largest positive gain, update the affected state, and repeat until no positive gain remains. This phase reuses the supplied statistics and D D D without restarting Lloyd. This is the schedule used by Model.myLocal2KM; the standalone Model.MinDLO_KM baseline resumes Lloyd after an accepted one-point move, and Model.myLocal2KMv2 resumes Lloyd after an accepted pair. Both call ExactPairSearch(z,I) (Algorithm 3), with I = [ n ] I=[n] I = [ n ] for PD-2PLS and I = B I=B I = B for BPS-2PLS. The shared routine uses the counts and sample–centroid distances D D D of the full current clustering; only the two moved sample indices are restricted to I I I . Destination minima can be obtained using the Top-3 lists or the equivalent O ( k ) O(k) O ( k ) scans described in Appendix § 15 .§ 4 . The algorithms below compute sample-pair distances lazily, after I I I is known, using the equivalent pair ordering in Appendix § 15 .§ 4 . Each distance is reused across all destination choices for its pair; no full sample-pair cache is initialized. Feasibility is checked jointly using Table 1, and cases with empty destination domains are skipped.
Table 1 (PDF p. 14).
Algorithm 2 Boundary-Point-Screened Two-Point Local Search (BPS-2PLS)
Require: data X X X , cluster count k k k , initial clustering z ∈ Z k z \in\mathbb{Z}_k z ∈ Z k
( z , D , { n ℓ , μ ℓ } ) ← Lloyd ( X , z ) (z,D,\{n_\ell,\mu_\ell\}) \leftarrow\operatorname{Lloyd}(X,z) ( z , D , { n ℓ , μ ℓ }) ← Lloyd ( X , z )
while true do
( z , D , { n ℓ , μ ℓ } ) ← Min-D-LO ( X , z , D , { n ℓ , μ ℓ } ) (z,D,\{n_\ell,\mu_\ell\}) \leftarrow\operatorname{Min\text{-}D\text{-}LO}(X,z,D,\{n_\ell,\mu_\ell\}) ( z , D , { n ℓ , μ ℓ }) ← Min - D - LO ( X , z , D , { n ℓ , μ ℓ })
Compute insertion scores A A A , Top-3 lists { K j } \{K_j\} { K j } , and center distances Δ \Delta Δ
Build the shared envelopes specified in Table 2
Compute U i U_i U i for all i ∈ [ n ] i \in[n] i ∈ [ n ] using equation (18)
B ← { i ∈ [ n ] : U i > 0 } B \leftarrow\{i \in[n] : U_i > 0\} B ← { i ∈ [ n ] : U i > 0 }
( G max , M max ) ← ExactPairSearch ( z , B ) (G_{\max},M_{\max}) \leftarrow\operatorname{ExactPairSearch}(z,B) ( G m a x , M m a x ) ← ExactPairSearch ( z , B )
if G max ≤ 0 G_{\max} \le0 G m a x ≤ 0 then
return z z z
end if
Apply M max M_{\max} M m a x to z z z ; update affected n ℓ n_\ell n ℓ , μ ℓ \mu_\ell μ ℓ and columns of D D D
end while
Algorithm 3 ExactPairSearch( z , I ) (z,I) ( z , I )
Require: data X X X , D D D -local clustering z z z , sample set I ⊆ [ n ] I \subseteq[n] I ⊆ [ n ] , full-clustering statistics and D D D
G max ← 0 G_{\max} \leftarrow0 G m a x ← 0 ; M max ← ∅ M_{\max} \leftarrow\varnothing M m a x ← ∅
for all blocks covering unordered pairs i < j i<j i < j with i , j ∈ I i,j \in I i , j ∈ I do
Compute p i j = ∥ x i − x j ∥ 2 p_{ij}=\lVert x_i-x_j\rVert^2 p ij = ∥ x i − x j ∥ 2 for the current block
for all pairs i < j i<j i < j in the block do
Find the best feasible connected move M M M for this pair using Table 1 and Appendix § 15 .§ 4
if such a move exists and G ( M ; z ) > G max G(M;z)>G_{\max} G ( M ; z ) > G m a x then
G max ← G ( M ; z ) G_{\max} \leftarrow G(M;z) G m a x ← G ( M ; z ) ; M max ← M M_{\max} \leftarrow M M m a x ← M
end if
end for
Discard the current distance block
end for
return ( G max , M max ) (G_{\max},M_{\max}) ( G m a x , M m a x )
Local state updates. For a one- or two-point move M M M , we use the pre-move statistics and the changes defined in Appendix § 13 . For each affected cluster ℓ ∈ V ( M ) \ell\in V(M) ℓ ∈ V ( M ) , set
n ℓ ′ = n ℓ + Δ n ℓ ( M ) , μ ℓ ′ = n ℓ μ ℓ + Δ s ℓ ( M ) n ℓ ′ , D i ℓ ′ = ∥ x i − μ ℓ ′ ∥ 2 ( i ∈ [ n ] ) . n'_\ell= n_\ell+ \Delta n_\ell(M), \qquad
\mu'_\ell= \frac{n_\ell\mu_\ell+\Delta s_\ell(M)}{n'_\ell}, \qquad
D'_{i\ell}=\lVert x_i-\mu'_\ell\rVert^2 \quad(i\in[n]). n ℓ ′ = n ℓ + Δ n ℓ ( M ) , μ ℓ ′ = n ℓ ′ n ℓ μ ℓ + Δ s ℓ ( M ) , D i ℓ ′ = ∥ x i − μ ℓ ′ ∥ 2 ( i ∈ [ n ]) .
All other counts, centroids, and columns of D D D remain valid. Updating the counts costs O ( 1 ) O(1) O ( 1 ) , and updating the centroids costs O ( d ) O(d) O ( d ) for a one-point or connected two-point move; refreshing the two or at most three affected distance columns costs O ( n d ) O(nd) O ( n d ) . Locality refers to the affected columns, not to restricting their rows to moved samples. The same update is used inside Min-D-LO and after a pair is accepted. Insertion scores, destination lists, and screening envelopes are refreshed from the current state before the next screening round; they must not be reused unchanged after centroid or count updates.
Cluster-Update Primitives and Feasibility
For a cluster index set I ℓ I_\ell I ℓ , recall its size n ℓ n_\ell n ℓ , sum s ℓ s_\ell s ℓ , and centroid μ ℓ = s ℓ / n ℓ \mu_\ell=s_\ell/n_\ell μ ℓ = s ℓ / n ℓ . Its within-cluster sum of squares is
WCSS ( I ℓ ) = ∑ i ∈ I ℓ ∥ x i ∥ 2 − ∥ s ℓ ∥ 2 n ℓ . \operatorname{WCSS}(I_\ell)=\sum_{i\in I_\ell}\lVert x_i\rVert^2-\frac{\lVert s_\ell\rVert^2}{n_\ell}. WCSS ( I ℓ ) = i ∈ I ℓ ∑ ∥ x i ∥ 2 − n ℓ ∥ s ℓ ∥ 2 .
Substituting the updated sufficient statistics after removing, inserting, or replacing samples gives
WCSS ( I ℓ ) − WCSS ( I ℓ ∖ { i } ) = n ℓ n ℓ − 1 D i ℓ = R ℓ ( i ) , \operatorname{WCSS}(I_\ell)-\operatorname{WCSS}(I_\ell\setminus\{i\})=\frac{n_\ell}{n_\ell-1}D_{i\ell}=R_\ell(i), WCSS ( I ℓ ) − WCSS ( I ℓ ∖ { i }) = n ℓ − 1 n ℓ D i ℓ = R ℓ ( i ) ,
WCSS ( I ℓ ∪ { i } ) − WCSS ( I ℓ ) = n ℓ n ℓ + 1 D i ℓ = A ℓ ( i ) , \operatorname{WCSS}(I_\ell\cup\{i\})-\operatorname{WCSS}(I_\ell)=\frac{n_\ell}{n_\ell+1}D_{i\ell}=A_\ell(i), WCSS ( I ℓ ∪ { i }) − WCSS ( I ℓ ) = n ℓ + 1 n ℓ D i ℓ = A ℓ ( i ) ,
WCSS ( I ℓ ) − WCSS ( I ℓ ∖ { i , j } ) = n ℓ ( D i ℓ + D j ℓ ) − p i j n ℓ − 2 = R ℓ ( i , j ) , \operatorname{WCSS}(I_\ell)-\operatorname{WCSS}(I_\ell\setminus\{i,j\})=\frac{n_\ell(D_{i\ell}+D_{j\ell})-p_{ij}}{n_\ell-2}=R_\ell(i,j), WCSS ( I ℓ ) − WCSS ( I ℓ ∖ { i , j }) = n ℓ − 2 n ℓ ( D i ℓ + D j ℓ ) − p ij = R ℓ ( i , j ) ,
WCSS ( I ℓ ∪ { i , j } ) − WCSS ( I ℓ ) = n ℓ ( D i ℓ + D j ℓ ) + p i j n ℓ + 2 = A ℓ ( i , j ) , \operatorname{WCSS}(I_\ell\cup\{i,j\})-\operatorname{WCSS}(I_\ell)=\frac{n_\ell(D_{i\ell}+D_{j\ell})+p_{ij}}{n_\ell+2}=A_\ell(i,j), WCSS ( I ℓ ∪ { i , j }) − WCSS ( I ℓ ) = n ℓ + 2 n ℓ ( D i ℓ + D j ℓ ) + p ij = A ℓ ( i , j ) ,
WCSS ( I ℓ ) − WCSS ( ( I ℓ ∖ { i } ) ∪ { j } ) = D i ℓ − D j ℓ + p i j n ℓ = T ℓ ( i , j ) . \operatorname{WCSS}(I_\ell)-\operatorname{WCSS}((I_\ell\setminus\{i\})\cup\{j\})=D_{i\ell}-D_{j\ell}+\frac{p_{ij}}{n_\ell}=T_\ell(i,j). WCSS ( I ℓ ) − WCSS (( I ℓ ∖ { i }) ∪ { j }) = D i ℓ − D j ℓ + n ℓ p ij = T ℓ ( i , j ) .
Combining the contributions of the affected clusters yields the six gains in Table 1.
For u = ( i : z i → a ) u=(i:z_i\to a) u = ( i : z i → a ) , both same-source configurations require n z i > 2 n_{z_i}>2 n z i > 2 . In a different-source/same-destination move, neither source is replenished, so n z i > 1 n_{z_i}>1 n z i > 1 and n z j > 1 n_{z_j}>1 n z j > 1 are required. A forward chain has z j = a z_j=a z j = a and b ∉ { z i , a } b\notin\{z_i,a\} b ∈ / { z i , a } : cluster a a a receives x i x_i x i while losing x j x_j x j , and only n z i > 1 n_{z_i}>1 n z i > 1 is needed. In a backward chain, z j ∉ { z i , a } z_j\notin\{z_i,a\} z j ∈ / { z i , a } and b = z i b=z_i b = z i , so only n z j > 1 n_{z_j}>1 n z j > 1 is required. A swap has z j = a z_j=a z j = a and b = z i b=z_i b = z i and preserves both source sizes. These are exactly the size conditions in Table 1. Any case requiring an unavailable third label is omitted.
Exact Top-3 Destination Queries
We use max ∅ = − ∞ \max\varnothing=-\infty max ∅ = − ∞ and min ∅ = + ∞ \min\varnothing=+\infty min ∅ = + ∞ ; the search routine clips its returned gain at zero, and ties may be broken arbitrarily. The formula for A ℓ ( i ) A_\ell(i) A ℓ ( i ) defines a ranking score for every i , ℓ i,\ell i , ℓ ; its interpretation as an insertion cost requires i ∉ I ℓ i\notin I_\ell i ∈ / I ℓ . Computing the insertion-score matrix from D D D costs O ( n k ) O(nk) O ( nk ) time, and selecting each sample’s three smallest scores costs O ( k ) O(k) O ( k ) , hence O ( n k ) O(nk) O ( nk ) in total. Let K j K_j K j contain the min { 3 , k } \min\{3,k\} min { 3 , k } labels with the smallest insertion scores over all clusters, including z j z_j z j in the ranking. A query excludes { z i , a } \{z_i,a\} { z i , a } , which contains z j z_j z j in both configurations under consideration. If k ≤ 3 k\leq3 k ≤ 3 , all labels are cached. If k > 3 k>3 k > 3 , at most two of the three cached labels are excluded, so at least one remains. Whenever the admissible domain is nonempty, every uncached score is at least as large as each cached score; hence an admissible minimizer lies in K j K_j K j . This justifies constant-time destination queries using Top-3 lists, including ties. When the admissible domain is empty, the corresponding configuration is absent. The screening implementation obtains these lists by sorting each row of A A A , which costs O ( n k log k ) O(nk\log k) O ( nk log k ) rather than linear-time selection. Since k ≤ n k\leq n k ≤ n , this is covered by the O ( n k log n ) O(nk\log n) O ( nk log n ) screening bound.
Equivalent Sample-Pair Ordering
Algorithm 3 regroups the anchored search of § 5 by unordered sample pairs. Fix i < j i<j i < j in I I I and abbreviate their source labels as s = z i s=z_i s = z i and c = z j c=z_j c = z j . If s = c s=c s = c , the best distinct-destination insertion cost is
min a , b ∈ [ k ] ∖ { s } a ≠ b ( A a ( i ) + A b ( j ) ) . \min_{\substack{a,b\in[k]\setminus\{s\}\\a\ne b}}\left(A_a(i)+A_b(j)\right). a , b ∈ [ k ] ∖ { s } a = b min ( A a ( i ) + A b ( j ) ) .
This minimum can be recovered from the constant-size product ( K i ∖ { s } ) × ( K j ∖ { s } ) (K_i\setminus\{s\})\times(K_j\setminus\{s\}) ( K i ∖ { s }) × ( K j ∖ { s }) subject to a ≠ b a\ne b a = b . To see this, start with an optimal feasible pair ( a , b ) (a,b) ( a , b ) . With b b b fixed, the excluded labels for i i i are { s , b } \{s,b\} { s , b } , so the Top-3 query yields a ′ ∈ K i ∖ { s , b } a'\in K_i\setminus\{s,b\} a ′ ∈ K i ∖ { s , b } with A a ′ ( i ) ≤ A a ( i ) A_{a'}(i)\leq A_a(i) A a ′ ( i ) ≤ A a ( i ) . Fixing a ′ a' a ′ then yields b ′ ∈ K j ∖ { s , a ′ } b'\in K_j\setminus\{s,a'\} b ′ ∈ K j ∖ { s , a ′ } with A b ′ ( j ) ≤ A b ( j ) A_{b'}(j)\leq A_b(j) A b ′ ( j ) ≤ A b ( j ) . The pair ( a ′ , b ′ ) (a',b') ( a ′ , b ′ ) remains feasible and lies in the cached product without increasing the total cost. If no distinct pair exists, the minimum is + ∞ +\infty + ∞ .
For s = c s=c s = c , the two configuration optima are therefore
max { R s ( i , j ) − A a ( i , j ) , R s ( i , j ) − min a , b ∈ [ k ] ∖ { s } a ≠ b ( A a ( i ) + A b ( j ) ) } , \max\left\{R_s(i,j)-A_a(i,j),\quad R_s(i,j)-\min_{\substack{a,b\in[k]\setminus\{s\}\\a\ne b}}\left(A_a(i)+A_b(j)\right)\right\}, max ⎩ ⎨ ⎧ R s ( i , j ) − A a ( i , j ) , R s ( i , j ) − a , b ∈ [ k ] ∖ { s } a = b min ( A a ( i ) + A b ( j ) ) ⎭ ⎬ ⎫ ,
subject to n s > 2 n_s>2 n s > 2 . If s ≠ c s\ne c s = c , the common-destination optimum is
max a ∉ { s , c } { R s ( i ) + R c ( j ) − A a ( i , j ) } , (30) \max_{a\notin\{s,c\}}\left\{R_s(i)+R_c(j)-A_a(i,j)\right\}, \tag*{(30)} a ∈ / { s , c } max { R s ( i ) + R c ( j ) − A a ( i , j ) } , (30)
and the two chain orientations and swap have gains
R s ( i ) + T c ( j , i ) − min b ∉ { s , c } A b ( j ) , R c ( j ) + T s ( i , j ) − min a ∉ { s , c } A a ( i ) , T s ( i , j ) + T c ( j , i ) , \begin{aligned}
R_s(i) + T_c(j,i) - \min_{b\notin\{s,c\}} A_b(j),\\
R_c(j) + T_s(i,j) - \min_{a\notin\{s,c\}} A_a(i),\\
T_s(i,j) + T_c(j,i),
\end{aligned} R s ( i ) + T c ( j , i ) − b ∈ / { s , c } min A b ( j ) , R c ( j ) + T s ( i , j ) − a ∈ / { s , c } min A a ( i ) , T s ( i , j ) + T c ( j , i ) ,
respectively, subject to the joint feasibility conditions above. Each chain query excludes the two source labels { s , c } \{s,c\} { s , c } , so the same Top-3 argument applies. Only the common-destination cases scan O ( k ) O(k) O ( k ) labels; all other destination optimizations take constant time. Given p i j p_{ij} p ij , destination optimization therefore costs O ( k ) O(k) O ( k ) per unordered pair. Computing p i j p_{ij} p ij once adds O ( d ) O(d) O ( d ) , rather than multiplying the distance cost by the number of destinations. This ordering returns the same maximum positive gain as anchored enumeration for every I ⊆ [ n ] I \subseteq[n] I ⊆ [ n ] .
The implemented gain kernel instead scans the admissible labels for each chain and, for a same-source pair, records the two smallest insertion costs for each sample during the common-destination scan. If the two best labels coincide, it compares the two choices that use one runner-up. This computes the same distinct-destination minimum without requiring precomputed Top-3 lists in the pair-search routine, and still takes O ( k ) O(k) O ( k ) time per pair.
Exactness and Termination
At a D-local state, every improving exact two-point move is connected by Theorem 4.4. Choose either of its transfers as u = ( i : z i → a ) u=(i:z_i\to a) u = ( i : z i → a ) and write the other as v = ( j : z j → b ) v=(j:z_j\to b) v = ( j : z j → b ) . If z j = z i z_j=z_i z j = z i , then b = a b=a b = a or b ∉ { z i , a } b\notin\{z_i,a\} b ∈ / { z i , a } . If z j = a z_j=a z j = a , then b = z i b=z_i b = z i or b ∉ { z i , a } b\notin\{z_i,a\} b ∈ / { z i , a } . If z j ∉ { z i , a } z_j\notin\{z_i,a\} z j ∈ / { z i , a } , connectedness requires b ∈ { z i , a } b\in\{z_i,a\} b ∈ { z i , a } . These alternatives are exactly the six rows of Table 1, including their joint feasibility conditions.
Algorithm 3 with I = [ n ] I=[n] I = [ n ] visits every unordered sample pair. The destination optimizations in Appendix § 15 .§ 4 cover all six connected configurations, including both chain orientations, and return a feasible move with gain at least that of any other connected move for the pair. Hence the maximum positive gain returned equals the maximum gain over N = 2 ( z ) N_{=2}(z) N = 2 ( z ) , clipped at zero. If it returns zero, no improving exact two-point move exists, and D-locality already excludes improving one-point moves. The clustering is therefore two-point locally optimal by Definition 4.1 .
After an accepted pair, PD-2PLS (Algorithm 1) locally updates the affected cluster statistics and distance columns, then resumes Min-D-LO descent from that state. Every accepted one- or two-point move strictly decreases WCSS, and there are finitely many feasible clusterings. Hence the algorithm terminates. BPS-2PLS has the same guarantee because screening preserves every improving pair; its envelopes are rebuilt after one-point descent reaches the next D-local state.
Distance Evaluation, Time, and Memory
The sample–centroid cache D D D and the sample–sample distances p i j p_{ij} p ij have different roles. Lloyd initializes D D D and the cluster statistics, which are then maintained through local updates during Min-D-LO and after accepted pairs. Screening uses these quantities, the insertion scores, and Δ \Delta Δ ; it does not evaluate any p i j p_{ij} p ij . In particular, the diameter p max p_{\max} p m a x in § 7 is only an analysis quantity and is not computed by BPS. Sample–sample distances are needed only for exact gain evaluation after screening.
Full caching. One may compute all p i j p_{ij} p ij once in O ( n 2 d ) O(n^2d) O ( n 2 d ) time and store them in O ( n 2 ) O(n^2) O ( n 2 ) space. They remain valid across clustering updates because the samples do not change. Each later lookup costs O ( 1 ) O(1) O ( 1 ) , yielding O ( k 2 d + n k log n + m 2 k ) O(k^2d+nk\log n+m^2k) O ( k 2 d + nk log n + m 2 k ) screening-and-search time after one-point descent. The quadratic preprocessing and storage remain even when screening retains very few samples.
Lazy block evaluation. Algorithms 1–3 instead compute distances only within the current search set. For BPS-2PLS this set is B \mathbb{B} B , so at most ( m 2 ) \binom{m}{2} ( 2 m ) distinct pair distances are required. A block with at most w w w rows of retained samples and at most m m m retained columns uses O ( w m ) O(wm) O ( w m ) distance storage. Processing the blocks, reusing each distance across all destination choices and discarding a block after use, costs O ( m 2 d ) O(m^2d) O ( m 2 d ) time. The resulting screening-and-search cost after one-point descent is
O ( k 2 d + n k log n + m 2 ( d + k ) ) , m = ∣ B ∣ , (31) O(k^2d + nk \log n + m^2(d + k)), \qquad m = |\mathcal{B}|, \tag*{(31)} O ( k 2 d + nk log n + m 2 ( d + k )) , m = ∣ B ∣ , (31)
with no O ( n 2 d ) O(n^2d) O ( n 2 d ) preprocessing. Distances may be recomputed in later rounds; the per-round bound includes this work.
The common storage comprises the n d nd n d input coordinates, the n k nk nk sample–centroid and insertion-score entries, and the k 2 k^2 k 2 centroid-distance entries; storing all envelopes requires at most O ( n k ) O(nk) O ( nk ) additional space. A copied candidate-data array uses O ( m d ) ≤ O ( n d ) O(md) \leq O(nd) O ( m d ) ≤ O ( n d ) space, already covered in Table 5 . With fixed w w w , lazy evaluation avoids quadratic sample-pair storage even if m = n m = n m = n . The two policies evaluate the same gains and have the same exact-arithmetic optimality guarantee.
Table 5. Distance-policy costs for BPS-2PLS. Screening-and-search time excludes one-point descent and accepted-move state updates; peak memory includes the input data and clustering workspace. The block row limit is w w w .
Total runtime. Let T L T_L T L count Lloyd iterations, T 1 T_1 T 1 count complete one-point gain scans across all Min-D-LO phases, and T 2 T_2 T 2 count screening-and-search rounds. These counts include the unsuccessful scans and the final search used to certify termination. Initialization and construction of D D D take O ( n d k ) O(ndk) O ( n d k ) , absorbed into O ( T L n d k ) O(T_Lndk) O ( T L n d k ) since T L ≥ 1 T_L \geq1 T L ≥ 1 . Each one-point scan costs O ( n k ) O(nk) O ( nk ) and accepts at most one move, whose local update costs O ( n d ) O(nd) O ( n d ) . Each two-point round rebuilds the screening quantities in O ( k 2 d + n k log n ) O(k^2d + nk \log n) O ( k 2 d + nk log n ) time and, if successful, adds a local update costing O ( n d ) O(nd) O ( n d ) . If m t m_t m t samples survive in round t t t , the lazy implementation therefore takes
O ( T L n d k + T 1 ( n d + n k ) + ∑ t = 1 T 2 [ n d + k 2 d + n k log n + m t 2 ( d + k ) ] ) . (32) O\left(T_Lndk + T_1(nd + nk) + \sum_{t=1}^{T_2}\left[nd + k^2d + nk \log n + m_t^2(d + k)\right]\right). \tag*{(32)} O ( T L n d k + T 1 ( n d + nk ) + t = 1 ∑ T 2 [ n d + k 2 d + nk log n + m t 2 ( d + k ) ] ) . (32)
Setting m = max 1 ≤ t ≤ T 2 m t m = \max_{1 \leq t \leq T_2} m_t m = max 1 ≤ t ≤ T 2 m t gives equation (19) ; an average candidate count cannot replace this maximum in that worst-case bound. The O ( n d ) O(nd) O ( n d ) update allowance is unnecessary in unsuccessful scans or rounds but gives a uniform upper bound. These counts refer to individual scans and rounds, not to calls of a complete Min-D-LO solver; no convergence-rate bound on T L T_L T L , T 1 T_1 T 1 , T 2 T_2 T 2 is asserted.
Without screening, PD-2PLS uses all n n n samples and takes O ( T L n d k + T 1 ( n d + n k ) + T 2 n 2 ( d + k ) ) O(T_Lndk + T_1(nd + nk) + T_2n^2(d + k)) O ( T L n d k + T 1 ( n d + nk ) + T 2 n 2 ( d + k )) time with lazy distances. Under full caching, the bound includes the one-time O ( n 2 d ) O(n^2d) O ( n 2 d ) preprocessing term, with m t 2 ( d + k ) m_t^2(d + k) m t 2 ( d + k ) replaced by m t 2 k m_t^2k m t 2 k in the BPS-2PLS bound. Under Theorem 7.2 , the lazy-distance term is O P ( d log 2 n ) O_{\mathbb{P}}(d\log^2 n) O P ( d log 2 n ) , so the screening-and-search cost after one-point descent, including an accepted pair’s O ( n d ) O(nd) O ( n d ) update, remains O P ( n log n ) O_{\mathbb{P}}(n\log n) O P ( n log n ) for fixed d , k d,k d , k .
Details for Safe Boundary-Point Screening
Configuration Coefficients
Table 6 gives the coefficients in equation 14, obtained from the gains in Table 1 after optimizing any free partner destination. The first four configurations use e = ( τ , s , a ) e = (\tau,s,a) e = ( τ , s , a ) , different sources with the same destination use e = ( τ , a ) e = (\tau,a) e = ( τ , a ) , and the backward chain uses e = ( τ , s ) e = (\tau,s) e = ( τ , s ) .
Envelope Construction and Queries
We use a standard construction for line upper envelopes de Berg et al. [8 ] . For a fixed key e e e , we sort the ∣ J ~ e ∣ |\widetilde{\mathcal{J}}_e| ∣ J e ∣ lines by increasing slope, retaining only the largest intercept among lines with equal slope. We then scan the sorted lines while maintaining a stack of active lines and their intersection breakpoints, removing redundant lines until the breakpoints are strictly increasing. Each line is inserted and removed at most once, so sorting and envelope construction take O ( ∣ J ~ e ∣ log ∣ J ~ e ∣ ) O(|\widetilde{\mathcal{J}}_e|\log|\widetilde{\mathcal{J}}_e|) O ( ∣ J e ∣ log ∣ J e ∣ ) time and O ( ∣ J ~ e ∣ ) O(|\widetilde{\mathcal{J}}_e|) O ( ∣ J e ∣ ) space. An individual query at ρ e ( i ) \rho_e(i) ρ e ( i ) can use binary search on the breakpoints in O ( log ∣ J ~ e ∣ ) O(\log|\widetilde{\mathcal{J}}_e|) O ( log ∣ J e ∣ ) time, with constant-time handling of envelopes with at most one line. The implementation instead sorts the query radii for each envelope and scans its breakpoints monotonically, then restores the original query order. With q q q queries this takes O ( q log q + q + ∣ J ~ e ∣ ) O(q\log q+q+|\widetilde{\mathcal{J}}_e|) O ( q log q + q + ∣ J e ∣ ) time; the total number of queries and lines across families is O ( n k ) O(nk) O ( nk ) , so the same O ( n k log n ) O(nk\log n) O ( nk log n ) aggregate bound holds.
Cached Pivot Radii
The triangle and reverse triangle inequalities give
∣ ρ e ( i ) − ρ e ( j ) ∣ ≤ ∥ x i − x j ∥ ≤ ρ e ( i ) + ρ e ( j ) . |\rho_e(i)-\rho_e(j)|\le\lVert x_i-x_j\rVert\le\rho_e(i)+\rho_e(j). ∣ ρ e ( i ) − ρ e ( j ) ∣ ≤ ∥ x i − x j ∥ ≤ ρ e ( i ) + ρ e ( j ) .
Using the upper bound for η e > 0 \eta_e>0 η e > 0 and the lower bound for η e < 0 \eta_e<0 η e < 0 yields equation (15) . With these pivot choices, the radii needed for line construction and envelope queries can be computed from the cached distances D D D . We first compute the matrix Δ = ( Δ s a ) \Delta=(\Delta_{sa}) Δ = ( Δ s a ) , where Δ s a = ∥ μ s − μ a ∥ 2 \Delta_{sa}=\lVert\mu_s-\mu_a\rVert^2 Δ s a = ∥ μ s − μ a ∥ 2 , for all cluster pairs in O ( k 2 d ) O(k^2d) O ( k 2 d ) time. For any sample index h h h , the required squared radius is
ρ e ( h ) 2 = { D h ℓ , o e = μ ℓ , 1 2 D h s + 1 2 D h a − 1 4 Δ s a , o e = ( μ s + μ a ) / 2. (33) \rho_e(h)^2=
\begin{cases}
D_{h\ell}, & o_e=\mu_\ell,\\
\frac{1}{2}D_{hs}+\frac{1}{2}D_{ha}-\frac{1}{4}\Delta_{sa}, & o_e=(\mu_s+\mu_a)/2.
\end{cases} \tag*{(33)} ρ e ( h ) 2 = { D h ℓ , 2 1 D h s + 2 1 D ha − 4 1 Δ s a , o e = μ ℓ , o e = ( μ s + μ a ) /2. (33)
Proofs for Candidate-Set Size Guarantees
We first prove Proposition 7.1 and give the construction with m = n m=n m = n . We then bound the number of samples in U ( z ) U(z) U ( z ) using a cover by slabs and prove Theorem 7.2 for the two distribution classes.
Deterministic Localization of Retained Samples
Fix a D-local state z z z with n min = min ℓ n ℓ ≥ 4 n_{\min}=\min_\ell n_\ell\ge4 n m i n = min ℓ n ℓ ≥ 4 , and let p max = max i , j ∈ [ n ] p i j p_{\max}=\max_{i,j\in[n]}p_{ij} p m a x = max i , j ∈ [ n ] p ij . We analyze the exact-arithmetic certificate in equation (18) with the pivots and partner supersets in Table 2 . The localization argument is deterministic.
Proof of Proposition 7.1. Let g i max = max a ≠ z i g i ( a ) g_i^{\max}=\max_{a\ne z_i}g_i(a) g i m a x = max a = z i g i ( a ) be the best one-point gain for sample i i i . The condition n min ≥ 4 n_{\min}\ge4 n m i n ≥ 4 ensures that every constituent one-point move considered below is feasible, and D-locality makes its gain nonpositive. We first bound the screening certificate by g i max + 2 γ p max / n min g_i^{\max}+2\gamma p_{\max}/n_{\min} g i m a x + 2 γ p m a x / n m i n , then translate this bound into a squared-distance margin.
For a cluster ℓ \ell ℓ , define the interactions
I ℓ − ( i , j ) = n ℓ ( D i ℓ + D j ℓ ) ( n ℓ − 2 ) ( n ℓ − 1 ) − p i j n ℓ − 2 , I_\ell^{-}(i,j)=\frac{n_\ell(D_{i\ell}+D_{j\ell})}{(n_\ell-2)(n_\ell-1)}-\frac{p_{ij}}{n_\ell-2}, I ℓ − ( i , j ) = ( n ℓ − 2 ) ( n ℓ − 1 ) n ℓ ( D i ℓ + D j ℓ ) − n ℓ − 2 p ij ,
I ℓ + ( i , j ) = n ℓ ( D i ℓ + D j ℓ ) ( n ℓ + 1 ) ( n ℓ + 2 ) − p i j n ℓ + 2 , I_\ell^{+}(i,j)=\frac{n_\ell(D_{i\ell}+D_{j\ell})}{(n_\ell+1)(n_\ell+2)}-\frac{p_{ij}}{n_\ell+2}, I ℓ + ( i , j ) = ( n ℓ + 1 ) ( n ℓ + 2 ) n ℓ ( D i ℓ + D j ℓ ) − n ℓ + 2 p ij ,
J ℓ ( i , j ) = p i j n ℓ − D i ℓ n ℓ − 1 − D j ℓ n ℓ + 1 . (34) J_\ell(i,j)=\frac{p_{ij}}{n_\ell}-\frac{D_{i\ell}}{n_\ell-1}-\frac{D_{j\ell}}{n_\ell+1}. \tag*{(34)} J ℓ ( i , j ) = n ℓ p ij − n ℓ − 1 D i ℓ − n ℓ + 1 D j ℓ . (34)
The cluster-update identities in Proposition 5.1 give
I ℓ − = R ℓ ( i , j ) − R ℓ ( i ) − R ℓ ( j ) , I ℓ + = A ℓ ( i ) + A ℓ ( j ) − A ℓ ( i , j ) , I_\ell^{-}=R_\ell(i,j)-R_\ell(i)-R_\ell(j),\qquad I_\ell^{+}=A_\ell(i)+A_\ell(j)-A_\ell(i,j), I ℓ − = R ℓ ( i , j ) − R ℓ ( i ) − R ℓ ( j ) , I ℓ + = A ℓ ( i ) + A ℓ ( j ) − A ℓ ( i , j ) ,
and J ℓ ( i , j ) = T ℓ ( i , j ) − R ℓ ( i ) + A ℓ ( j ) J_\ell(i,j)=T_\ell(i,j)-R_\ell(i)+A_\ell(j) J ℓ ( i , j ) = T ℓ ( i , j ) − R ℓ ( i ) + A ℓ ( j ) . Therefore, for u = ( i : s → a ) u=(i:s\to a) u = ( i : s → a ) and v = ( j : c → b ) v=(j:c\to b) v = ( j : c → b ) with s = z i s=z_i s = z i and c = z j c=z_j c = z j , each exact gain has the form
G ( u , v ) = g i ( a ) + g j ( b ) + I ( u , v ) , (35) G(u,v)=g_i(a)+g_j(b)+I(u,v), \tag*{(35)} G ( u , v ) = g i ( a ) + g j ( b ) + I ( u , v ) , (35)
where Table 7 lists I ( u , v ) I(u,v) I ( u , v ) . When the partner destination is free, choose the optimizing destination from Section 5; the identity still holds.
Table 7. Interactions and their upper bounds after radial relaxation, for the anchor i : s → a i:s\to a i : s → a . The last column bounds the excess over the two one-point gains.
To verify the last column, recall that p max = max i , j ∈ [ n ] p i j p_{\max}=\max_{i,j\in[n]}p_{ij} p m a x = max i , j ∈ [ n ] p ij . Since each empirical center is a cluster mean, convexity gives
D i ℓ ≤ 1 n ℓ ∑ h ∈ I ℓ p i h ≤ p max . D_{i\ell}\le\frac{1}{n_\ell}\sum_{h\in I_\ell}p_{ih}\le p_{\max}. D i ℓ ≤ n ℓ 1 h ∈ I ℓ ∑ p ih ≤ p m a x .
The condition n ℓ ≥ n min ≥ 4 n_\ell\ge n_{\min}\ge4 n ℓ ≥ n m i n ≥ 4 ensures ( n ℓ − 1 ) − 1 ≤ 2 / n ℓ (n_\ell-1)^{-1}\le2/n_\ell ( n ℓ − 1 ) − 1 ≤ 2/ n ℓ and ( n ℓ − 2 ) − 1 ≤ 2 / n ℓ (n_\ell-2)^{-1}\le2/n_\ell ( n ℓ − 2 ) − 1 ≤ 2/ n ℓ . Using these inequalities and discarding negative terms in equation 33 gives
I ℓ − ≤ 8 p max n ℓ , I ℓ + ≤ 2 p max n ℓ , J ℓ ≤ p max n ℓ . I_\ell^{-}\le\frac{8p_{\max}}{n_\ell},\qquad I_\ell^{+}\le\frac{2p_{\max}}{n_\ell},\qquad J_\ell\le\frac{p_{\max}}{n_\ell}. I ℓ − ≤ n ℓ 8 p m a x , I ℓ + ≤ n ℓ 2 p m a x , J ℓ ≤ n ℓ p m a x .
Next, fix an envelope key e e e and abbreviate ρ h = ρ e ( h ) = ∥ x h − o e ∥ \rho_h=\rho_e(h)=\lVert x_h-o_e\rVert ρ h = ρ e ( h ) = ∥ x h − o e ∥ . A center pivot gives ρ h 2 = D h ℓ ≤ p max \rho_h^2=D_{h\ell}\le p_{\max} ρ h 2 = D h ℓ ≤ p m a x , while a midpoint pivot gives
ρ h 2 = ∥ x h − μ s + μ a 2 ∥ 2 ≤ D h s + D h a 2 ≤ p max . \rho_h^2=\left\lVert x_h-\frac{\mu_s+\mu_a}{2}\right\rVert^2\le\frac{D_{hs}+D_{ha}}{2}\le p_{\max}. ρ h 2 = x h − 2 μ s + μ a 2 ≤ 2 D h s + D ha ≤ p m a x .
The radial replacement of η e p i j \eta_ep_{ij} η e p ij has slack
ϵ e ( i , j ) = η e ( ρ i 2 + ρ j 2 − p i j ) + 2 ∣ η e ∣ ρ i ρ j , \epsilon_e(i,j)=\eta_e(\rho_i^2+\rho_j^2-p_{ij})+2\lvert\eta_e\rvert\rho_i\rho_j, ϵ e ( i , j ) = η e ( ρ i 2 + ρ j 2 − p ij ) + 2 ∣ η e ∣ ρ i ρ j ,
0 ≤ ϵ e ( i , j ) ≤ 4 ∣ η e ∣ ρ i ρ j ≤ 4 ∣ η e ∣ p max . (36) 0\le\epsilon_e(i,j)\le4\lvert\eta_e\rvert\rho_i\rho_j\le4\lvert\eta_e\rvert p_{\max}. \tag*{(36)} 0 ≤ ϵ e ( i , j ) ≤ 4 ∣ η e ∣ ρ i ρ j ≤ 4 ∣ η e ∣ p m a x . (36)
Indeed, ρ i 2 + ρ j 2 − p i j = 2 ( x i − o e ) T ( x j − o e ) \rho_i^2+\rho_j^2-p_{ij}=2(x_i-o_e)^{\mathsf T}(x_j-o_e) ρ i 2 + ρ j 2 − p ij = 2 ( x i − o e ) T ( x j − o e ) , so the bounds follow from Cauchy–Schwarz. Using the coefficients η e \eta_e η e in Table 6 and ( n ℓ − 2 ) − 1 ≤ 2 / n ℓ (n_\ell-2)^{-1}\le2/n_\ell ( n ℓ − 2 ) − 1 ≤ 2/ n ℓ yields the bound in every row of Table 7 . Each such bound is at most 22 p max / n min 22p_{\max}/n_{\min} 22 p m a x / n m i n .
The same bounds cover the extra partners introduced by envelope sharing. In the two same-source configurations, the self-line j = i j=i j = i satisfies the same algebraic identities with p i i = 0 p_{ii}=0 p ii = 0 . Its two one-point terms are g i ( a ) g_i(a) g i ( a ) and either g i ( a ) g_i(a) g i ( a ) or g i ( b ) g_i(b) g i ( b ) , where b ∉ { s , a } b\notin\{s,a\} b ∈ / { s , a } . For different sources with the same destination, the enlarged set also includes j ∈ I s j\in I_s j ∈ I s ; its partner term is g j ( a ) g_j(a) g j ( a ) . For a backward chain, the extra partners have j ∈ I a j \in\mathbb{I}_a j ∈ I a and partner term g j ( s ) g_j(s) g j ( s ) . All of these one-point gains are feasible and nonpositive. Configurations requiring a third label are omitted if that label is unavailable. Thus every relaxed gain C τ ( u ) + η ρ i 2 + L e , j ( ρ i ) C_{\tau}(u) + \eta\rho_i^2 + L_{e,j}(\rho_i) C τ ( u ) + η ρ i 2 + L e , j ( ρ i ) is at most g i max + 22 p max / n min g_i^{\max} + 22p_{\max}/n_{\min} g i m a x + 22 p m a x / n m i n . Taking maxima over partners, configurations, and anchor destinations yields
U i ≤ g i max + 22 p max n min . (37) U_i \leq g_i^{\max} + \frac{22p_{\max}}{n_{\min}}. \tag*{(37)} U i ≤ g i m a x + n m i n 22 p m a x . (37)
These algebraic checks are needed because a shared envelope also contains lines that do not represent feasible two-point moves.
If i ∈ B ( z ) i \in\mathbb{B}(z) i ∈ B ( z ) and s = z i s = z_i s = z i , there is an a ≠ s a \ne s a = s with g i ( a ) = g i max > − 22 p max / n min g_i(a) = g_i^{\max} > -22p_{\max}/n_{\min} g i ( a ) = g i m a x > − 22 p m a x / n m i n . The difference between this gain and the fixed-center squared-distance difference is
g i ( a ) − ( D i s − D i a ) = D i s n s − 1 + D i a n a + 1 ∈ [ 0 , 3 p max / n min ] . (38) g_i(a) - (D_{is} - D_{ia}) = \frac{D_{is}}{n_s - 1} + \frac{D_{ia}}{n_a + 1} \in[0, 3p_{\max}/n_{\min}]. \tag*{(38)} g i ( a ) − ( D i s − D ia ) = n s − 1 D i s + n a + 1 D ia ∈ [ 0 , 3 p m a x / n m i n ] . (38)
Applying equation 37 with any destination b ≠ s b \ne s b = s , D-locality gives
D i s − D i b ≤ g i ( b ) ≤ 0. D_{is} - D_{ib} \leq g_i(b) \leq0. D i s − D ib ≤ g i ( b ) ≤ 0.
Thus the assigned center is a nearest center, and D ( 1 ) ( x i ) = D i s D_{(1)}(x_i) = D_{is} D ( 1 ) ( x i ) = D i s . For the selected destination a a a , the lower gain bound and equation 37 give D i a − D i s < 25 p max / n min D_{ia} - D_{is} < 25p_{\max}/n_{\min} D ia − D i s < 25 p m a x / n m i n . Consequently,
D ( 2 ) ( x i ) − D ( 1 ) ( x i ) = min b ≠ s ( D i b − D i s ) ≤ D i a − D i s < 25 p max n min . \begin{aligned}
D_{(2)}(x_i) - D_{(1)}(x_i) = \min_{b \ne s}(D_{ib} - D_{is}) \\
&\leq D_{ia} - D_{is} < \frac{25p_{\max}}{n_{\min}}.
\end{aligned} D ( 2 ) ( x i ) − D ( 1 ) ( x i ) = b = s min ( D ib − D i s ) ≤ D ia − D i s < n m i n 25 p m a x .
Hence x i ∈ U ( z ) x_i \in\mathbb{U}(z) x i ∈ U ( z ) , proving Proposition 7.1. Taking the contrapositive, any sample outside this region has U i ≤ 0 U_i \leq0 U i ≤ 0 . The inclusion imposes a necessary condition for retention, so samples inside the region may still be discarded. □ \square □
A Worst-Case Construction
We construct a deterministic family of bounded, balanced D-local states with m = n m = n m = n . For every even N ≥ 4 N \geq4 N ≥ 4 , set a 2 = 1 / [ 2 ( N − 1 ) ] a^2 = 1/[2(N - 1)] a 2 = 1/ [ 2 ( N − 1 )] and form two clusters in R 2 \mathbb{R}^2 R 2 :
I 1 : N 2 copies each of ( − a , 1 ) and ( − a , − 1 ) , I 2 : N 2 copies each of ( a , 1 ) and ( a , − 1 ) . \mathbb{I}_1:\quad\frac{N}{2}\text{ copies each of }(-a,1)\text{ and }(-a,-1),\qquad
\mathbb{I}_2:\quad\frac{N}{2}\text{ copies each of }(a,1)\text{ and }(a,-1). I 1 : 2 N copies each of ( − a , 1 ) and ( − a , − 1 ) , I 2 : 2 N copies each of ( a , 1 ) and ( a , − 1 ) .
The instance is bounded, has k = 2 k = 2 k = 2 and n = 2 N n = 2N n = 2 N , and both cluster sizes equal N N N . The centroids are μ 1 = ( − a , 0 ) ⊤ \mu_1 = (-a,0)^\top μ 1 = ( − a , 0 ) ⊤ and μ 2 = ( a , 0 ) ⊤ \mu_2 = (a,0)^\top μ 2 = ( a , 0 ) ⊤ . Each sample has squared distance 1 1 1 to its own centroid and 1 + 4 a 2 1 + 4a^2 1 + 4 a 2 to the other, so every one-point gain is
N N − 1 − N N + 1 ( 1 + 4 a 2 ) = 0. \frac{N}{N - 1} - \frac{N}{N + 1}(1 + 4a^2) = 0. N − 1 N − N + 1 N ( 1 + 4 a 2 ) = 0.
The displayed state is therefore D-local. For samples x i = ( − a , 1 ) ⊤ x_i = (-a,1)^\top x i = ( − a , 1 ) ⊤ and x j = ( a , − 1 ) ⊤ x_j = (a,-1)^\top x j = ( a , − 1 ) ⊤ , the swap u = ( i : 1 → 2 ) , v = ( j : 2 → 1 ) u = (i : 1 \to2), v = (j : 2 \to1) u = ( i : 1 → 2 ) , v = ( j : 2 → 1 ) has gain
G ( u , v ) = 2 − 2 ( 1 + 4 a 2 ) + 2 N ( 4 + 4 a 2 ) = 4 N > 0. G(u,v) = 2 - 2(1 + 4a^2) + \frac{2}{N}(4 + 4a^2) = \frac{4}{N} > 0. G ( u , v ) = 2 − 2 ( 1 + 4 a 2 ) + N 2 ( 4 + 4 a 2 ) = N 4 > 0.
The same calculation applies with the second coordinates reversed. Every sample participates in an improving swap, so any sample-level screening rule preserving all improving pairs must retain all n n n samples. In particular, BPS has m = n m = n m = n on this sequence of instances. The support locations in this deterministic family vary with n n n . The construction rules out a distribution-free sublinear bound, while Theorem 7.2 concerns independent sampling from a fixed distribution satisfying its stated conditions.
Now let x 1 , … , x n x_1,\ldots,x_n x 1 , … , x n be i.i.d. random vectors from a fixed distribution P P P , and consider the state class Z n , α \mathcal{Z}_{n,\alpha} Z n , α in equation 21. We control sample counts in U ( z ) \mathbb{U}(z) U ( z ) by covering it with slabs. We first establish a counting bound that holds for all slabs simultaneously. This uniformity allows both the centers and the covering slabs to depend on the observations.
Let A d \mathcal{A}_d A d be the class of Euclidean slabs, let N n ( A ) = ∑ i = 1 n 1 { x i ∈ A } N_n(A)=\sum_{i=1}^n 1_{\{x_i\in A\}} N n ( A ) = ∑ i = 1 n 1 { x i ∈ A } , and set
Γ d ( n , δ ) = 1 + 2 ( d + 1 ) log ( 2 n + 1 ) + log ( 3 / δ ) . (39) \Gamma_d(n,\delta)=1+2(d+1)\log(2n+1)+\log(3/\delta). \tag*{(39)} Γ d ( n , δ ) = 1 + 2 ( d + 1 ) log ( 2 n + 1 ) + log ( 3/ δ ) . (39)
The following relative counting bound is uniform over slab locations, directions, and widths, including those chosen from the observations.
Proposition E.1 (Uniform slab counts). For i.i.d. random vectors from P P P and every δ ∈ ( 0 , 1 ) \delta\in(0,1) δ ∈ ( 0 , 1 ) , with probability at least 1 − δ 1-\delta 1 − δ ,
N n ( A ) ≤ 2 n P ( A ) + 100 Γ d ( n , δ ) for all A ∈ A d . (40) N_n(A)\le2nP(A)+100\Gamma_d(n,\delta)\qquad\text{for all }A\in\mathcal{A}_d. \tag*{(40)} N n ( A ) ≤ 2 n P ( A ) + 100 Γ d ( n , δ ) for all A ∈ A d . (40)
Proof. Affine halfspaces in R d \mathbb{R}^d R d have at most ( M + 1 ) d + 1 (M+1)^{d+1} ( M + 1 ) d + 1 distinct traces on M M M points. A slab is the intersection of two halfspaces, so A d \mathcal{A}_d A d has at most ( M + 1 ) 2 ( d + 1 ) (M+1)^{2(d+1)} ( M + 1 ) 2 ( d + 1 ) traces. Introduce an independent sample x 1 ′ , … , x n ′ x'_1,\ldots,x'_n x 1 ′ , … , x n ′ , and let c ′ c' c ′ count its observations in A A A . If a slab selected from the original sample satisfies c : = N n ( A ) > 2 n P ( A ) + t c:=N_n(A)>2nP(A)+t c := N n ( A ) > 2 n P ( A ) + t , then Markov’s inequality, conditional on this sample and the selected slab, gives
P { c ′ ≤ 3 c / 4 ∣ x 1 , … , x n } ≥ 1 − 4 n P ( A ) 3 c > 1 3 . \mathbb{P}\{c'\le3c/4\mid x_1,\ldots,x_n\}\ge1-\frac{4nP(A)}{3c}>\frac{1}{3}. P { c ′ ≤ 3 c /4 ∣ x 1 , … , x n } ≥ 1 − 3 c 4 n P ( A ) > 3 1 .
Hence
P { ∃ A : N n ( A ) > 2 n P ( A ) + t } ≤ 3 P { ∃ A : c > t , c ′ ≤ 3 c / 4 } . \mathbb{P}\{\exists A:N_n(A)>2nP(A)+t\}\le3\mathbb{P}\{\exists A:c>t,\ c'\le3c/4\}. P { ∃ A : N n ( A ) > 2 n P ( A ) + t } ≤ 3 P { ∃ A : c > t , c ′ ≤ 3 c /4 } .
Independently exchange x i x_i x i and x i ′ x'_i x i ′ with probability 1 / 2 1/2 1/2 for every i i i , which preserves their joint distribution. Conditional on the unordered pairs, a fixed trace of A A A on the pooled observations has fixed total S = c + c ′ S=c+c' S = c + c ′ . The difference c − c ′ c-c' c − c ′ is a sum of M A M_A M A independent symmetric signs, where M A ≤ S M_A\le S M A ≤ S counts pairs with exactly one point in A A A . The bound cosh u ≤ e u 2 / 2 \cosh u\le e^{u^2/2} cosh u ≤ e u 2 /2 therefore gives
P { c − c ′ ≥ x ∣ unordered pairs } ≤ exp ( − x 2 2 M A ) \mathbb{P}\{c-c'\ge x\mid\text{unordered pairs}\}\le\exp\left(-\frac{x^2}{2M_A}\right) P { c − c ′ ≥ x ∣ unordered pairs } ≤ exp ( − 2 M A x 2 )
if M A > 0 M_A>0 M A > 0 ; a positive deviation is impossible otherwise. On the event c > t c>t c > t , c ′ ≤ 3 c / 4 c'\le3c/4 c ′ ≤ 3 c /4 , we have S > t S>t S > t and c − c ′ ≥ S / 7 c-c'\ge S/7 c − c ′ ≥ S /7 . The conditional probability of this event for a fixed trace is at most e − t / 98 e^{-t/98} e − t /98 . A union bound over the pooled traces bounds the original failure probability by 3 ( 2 n + 1 ) 2 ( d + 1 ) e − t / 98 3(2n+1)^{2(d+1)}e^{-t/98} 3 ( 2 n + 1 ) 2 ( d + 1 ) e − t /98 . Taking t = 100 Γ d ( n , δ ) t=100\Gamma_d(n,\delta) t = 100 Γ d ( n , δ ) makes this at most δ \delta δ . □ \square □
Let x ∼ P x\sim P x ∼ P . Suppose every unit projection has a density satisfying
sup ∥ v ∥ = 1 ∥ f v T x ∥ ∞ ≤ κ < ∞ . (41) \sup_{\lVert v\rVert=1}\lVert f_{v^\mathsf{T}x}\rVert_\infty\le\kappa<\infty. \tag*{(41)} ∥ v ∥ = 1 sup ∥ f v T x ∥ ∞ ≤ κ < ∞. (41)
A slab of total width w w w then has probability at most κ w \kappa w κ w , uniformly over its location and direction. We use this property to derive empirical center separation from D-locality and the occupancy condition. Write h α = α / ( 8 κ ) h_\alpha=\alpha/(8\kappa) h α = α / ( 8 κ ) . For n n n such that α n ≥ 4 \alpha n\ge4 α n ≥ 4 and 100 Γ d ( n , δ ) / n ≤ α / 4 100\Gamma_d(n,\delta)/n\le\alpha/4 100 Γ d ( n , δ ) / n ≤ α /4 , we show that the event in equation 39 implies
min a ≠ b ∥ μ a − μ b ∥ ≥ h α for every z ∈ Z n , α . (42) \min_{a\ne b}\lVert\mu_a-\mu_b\rVert\ge h_\alpha\qquad\text{for every }z\in\mathcal{Z}_{n,\alpha}. \tag*{(42)} a = b min ∥ μ a − μ b ∥ ≥ h α for every z ∈ Z n , α . (42)
Bounded projection densities exclude point atoms, so all observations are distinct almost surely. If two centers coincided, then for each i ∈ I a i\in I_a i ∈ I a ,
g i ( b ) = ( 1 n a − 1 + 1 n b + 1 ) D i a . g_i(b)=\left(\frac{1}{n_a-1}+\frac{1}{n_b+1}\right)D_{ia}. g i ( b ) = ( n a − 1 1 + n b + 1 1 ) D ia .
D-locality would force all points in I a I_a I a to equal that center, contradicting distinctness and n a ≥ 4 n_a\ge4 n a ≥ 4 .
For distinct centers, put h = Δ a b h=\sqrt{\Delta_{ab}} h = Δ ab and v = ( μ b − μ a ) / h v=(\mu_b-\mu_a)/h v = ( μ b − μ a ) / h . By equation 37, D-locality makes each assigned center a nearest center, so v T ( x i − μ a ) ≤ h / 2 v^\mathsf{T}(x_i-\mu_a)\le h/2 v T ( x i − μ a ) ≤ h /2 for i ∈ I a i\in I_a i ∈ I a . The nonnegative distances h / 2 − v T ( x i − μ a ) h/2-v^\mathsf{T}(x_i-\mu_a) h /2 − v T ( x i − μ a ) average to h / 2 h/2 h /2 , because the cluster mean is μ a \mu_a μ a . At least n a / 2 n_a/2 n a /2 samples therefore lie in the slab
A = { x : ∣ v T ( x − μ a ) ∣ ≤ h / 2 } . (43) A=\{x:|v^\mathsf{T}(x-\mu_a)|\le h/2\}. \tag*{(43)} A = { x : ∣ v T ( x − μ a ) ∣ ≤ h /2 } . (43)
Its probability is at most κ h \kappa h κh by equation (41) . Applying equation (40) gives
α 2 ≤ N n ( A ) n ≤ 2 κ h + 100 Γ d ( n , δ ) n ≤ 2 κ h + α 4 , \frac{\alpha}{2} \le\frac{N_n(A)}{n} \le2\kappa h+\frac{100\Gamma_d(n,\delta)}{n} \le2\kappa h+\frac{\alpha}{4}, 2 α ≤ n N n ( A ) ≤ 2 κh + n 100 Γ d ( n , δ ) ≤ 2 κh + 4 α ,
which proves h ≥ h α h \ge h_\alpha h ≥ h α . All statements hold on a single event for every empirical state and every center pair.
On that event, define the auxiliary slabs
S a b ( z ) : = { x ∈ R d : ∣ ∥ x − μ a ∥ 2 − ∥ x − μ b ∥ 2 ∣ ≤ 25 p max n min } , a < b . S_{ab}(z) := \left\{x \in\mathbb{R}^d : \left|\lVert x-\mu_a\rVert^2-\lVert x-\mu_b\rVert^2\right| \le\frac{25p_{\max}}{n_{\min}}\right\}, \qquad a<b. S ab ( z ) := { x ∈ R d : ∥ x − μ a ∥ 2 − ∥ x − μ b ∥ 2 ≤ n m i n 25 p m a x } , a < b .
For any x ∈ U ( z ) x \in U(z) x ∈ U ( z ) , its nearest and second-nearest centers identify a pair whose squared-distance difference is at most 25 p max / n min 25p_{\max}/n_{\min} 25 p m a x / n m i n . Therefore,
U ( z ) ⊆ ⋃ 1 ≤ a < b ≤ k S a b ( z ) . (44) U(z) \subseteq\bigcup_{1\leq a<b\leq k} S_{ab}(z). \tag*{(44)} U ( z ) ⊆ 1 ≤ a < b ≤ k ⋃ S ab ( z ) . (44)
Combining this cover with Proposition 7.1 gives
m ( z ) ≤ N n ( U ( z ) ) ≤ ∑ a < b N n ( S a b ( z ) ) . m(z) \leq N_n(U(z)) \leq\sum_{a<b}N_n(S_{ab}(z)). m ( z ) ≤ N n ( U ( z )) ≤ a < b ∑ N n ( S ab ( z )) .
For v = ( μ b − μ a ) / Δ a b v=(\mu_b-\mu_a)/\sqrt{\Delta_{ab}} v = ( μ b − μ a ) / Δ ab ,
∥ x − μ a ∥ 2 − ∥ x − μ b ∥ 2 = 2 Δ a b v T ( x − μ a + μ b 2 ) . \lVert x-\mu_a\rVert^2-\lVert x-\mu_b\rVert^2=2\sqrt{\Delta_{ab}}v^{\mathsf T}\left(x-\frac{\mu_a+\mu_b}{2}\right). ∥ x − μ a ∥ 2 − ∥ x − μ b ∥ 2 = 2 Δ ab v T ( x − 2 μ a + μ b ) .
Thus S a b ( z ) S_{ab}(z) S ab ( z ) is a slab around the equal-distance hyperplane, with geometric half-width 25 p max / ( 2 n min Δ a b ) 25p_{\max}/(2n_{\min}\sqrt{\Delta_{ab}}) 25 p m a x / ( 2 n m i n Δ ab ) . Its total projection width is 25 p max / ( n min Δ a b ) 25p_{\max}/(n_{\min}\sqrt{\Delta_{ab}}) 25 p m a x / ( n m i n Δ ab ) , so its probability is at most 25 κ p max / ( n min Δ a b ) 25\kappa p_{\max}/(n_{\min}\sqrt{\Delta_{ab}}) 25 κ p m a x / ( n m i n Δ ab ) . The squared sample diameter p max p_{\max} p m a x is common to all empirical states, and n min ≥ α n n_{\min}\geq\alpha n n m i n ≥ α n throughout Z n , α Z_{n,\alpha} Z n , α . Summing equation (40) over the ( k 2 ) \binom{k}{2} ( 2 k ) slabs yields
m ‾ n ≤ ( k 2 ) [ 50 κ p max α h α + 100 Γ d ( n , δ ) ] . (45) \overline{m}_n \leq\binom{k}{2}\left[\frac{50\kappa p_{\max}}{\alpha h_\alpha}+100\Gamma_d(n,\delta)\right]. \tag*{(45)} m n ≤ ( 2 k ) [ α h α 50 κ p m a x + 100 Γ d ( n , δ ) ] . (45)
with probability at least 1 − δ 1-\delta 1 − δ , under the stated sample-size conditions. The bound holds even though p max p_{\max} p m a x and the empirical centers depend on the observations, because the counting event is uniform over all slabs. For fixed k k k , d d d , α \alpha α , P P P and δ \delta δ , its right-hand side is a term proportional to p max p_{\max} p m a x plus O ( log n ) O(\log n) O ( log n ) .
The Two Distribution Classes
Proof of Theorem 7.2. First suppose P P P is supported on a ball of radius R R R centered at x 0 x_0 x 0 and ∥ f ∥ ∞ < ∞ \lVert f\rVert_\infty<\infty ∥ f ∥ ∞ < ∞ . For a unit vector v v v , integration over v ⊥ v^\perp v ⊥ gives the projection density
f v T x ( t ) = ∫ v ⊥ f ( t v + y ) d y . f_{v^{\mathsf T}x}(t)=\int_{v^\perp}f(tv+y)\,dy. f v T x ( t ) = ∫ v ⊥ f ( t v + y ) d y .
Every nonempty slice of the support has ( d − 1 ) (d-1) ( d − 1 ) -dimensional volume at most V d − 1 ( R ) V_{d-1}(R) V d − 1 ( R ) , the volume of a radius-R R R ball in R d − 1 \mathbb{R}^{d-1} R d − 1 . Consequently, equation (41) holds with κ = V d − 1 ( R ) ∥ f ∥ ∞ \kappa=V_{d-1}(R)\lVert f\rVert_\infty κ = V d − 1 ( R ) ∥ f ∥ ∞ , using V 0 ( R ) = 1 V_0(R)=1 V 0 ( R ) = 1 when d = 1 d=1 d = 1 . Any two samples are at distance at most 2 R 2R 2 R , so p max ≤ 4 R 2 p_{\max}\leq4R^2 p m a x ≤ 4 R 2 . For every fixed δ ∈ ( 0 , 1 ) \delta\in(0,1) δ ∈ ( 0 , 1 ) , the sample-size conditions of Appendix E.3 hold eventually, and equation (45) is O ( log n ) O(\log n) O ( log n ) . This proves the first case.
Next suppose P P P is the fixed k k k -component Gaussian mixture in the theorem. Positive definiteness and finiteness give constants
σ − 2 = min ℓ ∈ [ k ] λ min ( Σ ℓ ) > 0 , σ + 2 = max ℓ ∈ [ k ] λ max ( Σ ℓ ) < ∞ . \sigma_-^2=\min_{\ell\in[k]}\lambda_{\min}(\Sigma_\ell)>0,\qquad\sigma_+^2=\max_{\ell\in[k]}\lambda_{\max}(\Sigma_\ell)<\infty. σ − 2 = ℓ ∈ [ k ] min λ m i n ( Σ ℓ ) > 0 , σ + 2 = ℓ ∈ [ k ] max λ m a x ( Σ ℓ ) < ∞.
For any unit v v v , the projection within component ℓ \ell ℓ is a univariate Gaussian with variance v T Σ ℓ v ≥ σ − 2 v^{\mathsf T}\Sigma_\ell v\geq\sigma_-^2 v T Σ ℓ v ≥ σ − 2 . Each component density is bounded by ( 2 π σ − ) − 1 (\sqrt{2\pi}\sigma_-)^{-1} ( 2 π σ − ) − 1 , and so is their convex mixture. Thus equation (41) holds with this value of κ \kappa κ .
To bound the distance scale, write x i = θ z i + ∑ z i Σ 1 / 2 w i x_i = \theta_{z_i} + \sum_{z_i} \Sigma^{1/2}w_i x i = θ z i + ∑ z i Σ 1/2 w i , where the w i w_i w i are independent standard Gaussian vectors, independent of the component labels z i ∈ [ k ] z_i \in[k] z i ∈ [ k ] , with P { z i = ℓ } = π ℓ \mathbb{P}\{z_i = \ell\} = \pi_\ell P { z i = ℓ } = π ℓ . Here upright symbols denote random draws, while x i x_i x i denotes a fixed realization. For any fixed x 0 x_0 x 0 , let R 0 = max ℓ ∈ [ k ] ∥ θ ℓ − x 0 ∥ R_0 = \max_{\ell\in[k]}\|\theta_\ell- x_0\| R 0 = max ℓ ∈ [ k ] ∥ θ ℓ − x 0 ∥ . Fix δ ∈ ( 0 , 1 ) \delta\in(0,1) δ ∈ ( 0 , 1 ) . The Gaussian identity E e ∥ w i ∥ 2 / 4 = 2 d / 2 \mathbb{E}e^{\|w_i\|^2/4} = 2^{d/2} E e ∥ w i ∥ 2 /4 = 2 d /2 , Markov’s inequality, and a union bound imply
P { max i ∥ w i ∥ 2 > 2 d log 2 + 4 log ( 2 n / δ ) } ≤ δ / 2. \mathbb{P}\left\{\max_i\|w_i\|^2 > 2d\log2 + 4\log(2n/\delta)\right\} \le\delta/2. P { i max ∥ w i ∥ 2 > 2 d log 2 + 4 log ( 2 n / δ ) } ≤ δ /2.
On the complementary event, the realized squared sample diameter satisfies
p max ≤ 4 max i ∥ x i − x 0 ∥ 2 ≤ 4 [ R 0 + σ + 2 d log 2 + 4 log ( 2 n / δ ) ] 2 . (46) p_{\max} \le4\max_i\|x_i-x_0\|^2 \le4\left[R_0+\sigma_+ \sqrt{2d\log2+4\log(2n/\delta)}\right]^2. \tag*{(46)} p m a x ≤ 4 i max ∥ x i − x 0 ∥ 2 ≤ 4 [ R 0 + σ + 2 d log 2 + 4 log ( 2 n / δ ) ] 2 . (46)
Intersect this event with the uniform counting event at confidence 1 − δ / 2 1-\delta/2 1 − δ /2 . Applying equation (45) with Γ d ( n , δ / 2 ) \Gamma_d(n,\delta/2) Γ d ( n , δ /2 ) gives m ‾ n = O ( log n ) \overline{m}_n = O(\log n) m n = O ( log n ) on an event of probability at least 1 − δ 1-\delta 1 − δ . Since δ \delta δ is arbitrary, this proves equation (22) for the second case. The argument requires neither separation of component means nor recovery of the mixture-component labels by the empirical clustering.
The supremum in equation (22) makes the result uniform over all qualifying states, including states selected adaptively from the observations. For a D-local algorithmic output z ^ n \widehat{z}_n z n and any C > 0 C>0 C > 0 ,
P { m ( z ^ n ) > C log n } ≤ P { z ^ n ∉ Z n , α } + P { m ‾ n > C log n } . \mathbb{P}\{m(\widehat{z}_n)>C\log n\}\le\mathbb{P}\{\widehat{z}_n\notin\mathcal{Z}_{n,\alpha}\}+\mathbb{P}\{\overline{m}_n>C\log n\}. P { m ( z n ) > C log n } ≤ P { z n ∈ / Z n , α } + P { m n > C log n } .
If the occupancy failure probability tends to zero, this proves m ( z ^ n ) = O P ( log n ) m(\widehat{z}_n)=O_{\mathbb{P}}(\log n) m ( z n ) = O P ( log n ) . The convention for an empty state class does not assume that a state in Z n , α \mathcal{Z}_{n,\alpha} Z n , α exists or is attained algorithmically.
Experimental Setup
Datasets. The clustering-quality comparison uses the twelve datasets in Table 8 . The dataset names in the table link to public benchmark source pages. The five marked datasets are used for the descent-trajectory study and heuristic comparisons; Table 4 reports the available heuristic results. For each real dataset, k k k is set to the number of reference classes, and the clustering algorithms receive only the feature vectors and k k k . Pixel representations are scaled to [ 0 , 1 ] [0,1] [ 0 , 1 ] , while CIFAR-10 and CIFAR-100 use pre-extracted DINOv2 features. 20News uses the supplied TF–IDF representation reduced to 100 dimensions by singular value decomposition, and Sensorless uses the supplied measurement features. All methods use the same representations, without additional normalization or dimensionality reduction. The candidate-set scaling study uses random subsets of six larger datasets, with its sampling and aggregation protocol specified in Appendix § 19 .§ 3 .
Table 8. Datasets used in the clustering-quality comparison. Here n n n , d d d , and k k k denote the number of samples, feature dimension, and number of reference classes, respectively. Dataset names link to benchmark source pages; the listed dimensions describe the representations used here. Datasets marked with † are used for the descent-trajectory study and heuristic comparisons.
DINOv2 features. For CIFAR-10 and CIFAR-100, we use the pretrained DINOv2 ViT-B/14 backbone without register tokens (dinov2_vitb14) from the official implementation, revision 7764ea0. We combine the original training and test sets and use the fine labels for CIFAR-100. Each RGB image is resized by bicubic interpolation to a shorter-side length of 256 pixels, center-cropped to 224 × 224 224 \times224 224 × 224 , converted to a tensor with pixel values in [ 0 , 1 ] [0,1] [ 0 , 1 ] , and normalized channelwise using ImageNet means ( 0.485 , 0.456 , 0.406 ) (0.485,0.456,0.406) ( 0.485 , 0.456 , 0.406 ) and standard deviations ( 0.229 , 0.224 , 0.225 ) (0.229,0.224,0.225) ( 0.229 , 0.224 , 0.225 ) . The 768-dimensional feature is the final CLS token after LayerNorm (x_norm_clstoken), with no subsequent samplewise ℓ 2 \ell_2 ℓ 2 normalization. Feature extraction uses PyTorch 2.11.0+cu128 in float32, with autocast and TF32 disabled; the saved features are converted to double precision for clustering. Feature extraction is performed before clustering and is excluded from the reported clustering runtimes.
Comparison methods. We organize the evaluated methods into two categories according to their update mechanisms.
Sample-reassignment-based methods. These methods update sample memberships through batch assignments or one- and two-point reassignments.
Hartigan (Telgarsky and Vattani, 2010): Sequentially scans samples and moves each sample to the destination with the largest positive gain after centroid recomputation, immediately updating the affected centroids.
BPS-2PLS (ours): After initial Lloyd convergence, alternates the best-improvement one-point descent of Min-D-LO with exact two-point search, maintaining cluster statistics and distance columns through local updates. Lloyd is not restarted between local moves. Safe boundary-point screening reduces the candidate set while preserving every improving two-point move (Algorithm 2).
Heuristic methods. These methods explore center replacements or cluster repartitions, which can change many sample memberships at once.
We evaluate the four heuristic methods with and without BPS-2PLS; the refinement insertion points are described in Appendix § 19 .§ 2 .
Heuristic search budgets. LocalSearch uses 20 sampled replacement attempts. MultiSwap samples two candidate points per outer step and runs for at most 10 steps. MergeSplit uses five random 2-means trials per cluster pair, while J-Means stops when no improving jump is found. Each baseline and its enhanced variants use the same method-specific budget and acceptance rule; refinement time is included in the reported runtime. Hartigan on COIL100, CIFAR-10, CIFAR-100, MNIST, and Fashion-MNIST, and all J-Means variants on COIL20 and MNIST-2000, were omitted because of excessive runtime; these runs are marked with dashes.
Initialization. For the quality and enhancement comparisons, we generate ten independent k k k -means++ initial center sets per dataset and share them across methods. Each randomized outer method and its enhanced variants use paired random seeds and the same outer search budgets.
Evaluation metrics. We report squared-error loss, clustering accuracy (ACC), and normalized mutual information (NMI). Loss is recomputed as ∑ i = 1 n ∥ x i − μ z i ∥ 2 \sum_{i=1}^{n}\lVert x_i-\mu_{z_i}\rVert^2 ∑ i = 1 n ∥ x i − μ z i ∥ 2 from each method’s returned assignments z z z and centers μ 1 , … , μ k \mu_1,\ldots,\mu_k μ 1 , … , μ k . ACC uses an optimal matching between cluster labels and reference labels, and NMI is defined as 2 I ( z ; y ) / ( H ( z ) + H ( y ) ) 2I(z;y)/(H(z)+H(y)) 2 I ( z ; y ) / ( H ( z ) + H ( y )) , where y y y is the reference-label vector, and I I I and H H H denote mutual information and entropy computed from empirical label frequencies. Across the ten initializations, we report the best value, mean, and standard deviation of each quality metric. Best means minimum loss or maximum ACC/NMI; these extrema are selected independently and need not come from the same initialization.
Timing. For the quality and enhancement comparisons, each fixed initialization is run five times, resetting any algorithm-specific random stream before each repetition. We first average the five runtimes for each initialization and then report the mean and standard deviation across the ten resulting averages; the repetitions do not constitute additional independent initializations. Quality metrics are recorded once per initialization. Each method is warmed up before measurement, and method order is rotated across repetitions. Reported runtimes include all algorithmic work, including distance calculations and screening, but exclude data loading, shared initial-center generation, quality evaluation, and result serialization. Phase diagnostics and MATLAB profiling are collected in separate runs to avoid adding their overhead to the ordinary timing measurements.
Implementation. All methods are implemented in MATLAB using double-precision arithmetic. We use the lazy policy in Appendix C.6: after screening, distances are evaluated only between retained samples, in blocks of at most 256 rows, and each block is discarded after its pairs are processed. A distance is reused across destination choices; no dataset-wide sample-pair cache is precomputed or retained across rounds. Remaining pairs whose certificates cannot exceed the best gain found so far may also be skipped, which can reduce work below the worst-case bound. Reported total runtimes include all distance calculations and state updates; the Search phase in Appendix G.6 includes candidate-pair distance computation. The clustering-quality and heuristic-enhancement experiments were run in MATLAB R2026a on an Intel Xeon Gold 6248R CPU at 3.00 GHz, with memory operating at 2666 MHz. The separate runtime-phase study is described in Appendix G.6.
Supplementary Experimental Discussion
WCSS Improvements in Larger Clusters
A plausible explanation is the diminishing influence of a few samples on well-populated clusters. For a sample with s = z i s=z_i s = z i and destination α \alpha α , rewriting equation 4 gives g i ( α ) = D i s − D i α + D i s / ( n s − 1 ) + D i α / ( n α + 1 ) g_i(\alpha)=D_{is}-D_{i\alpha}+D_{is}/(n_s-1)+D_{i\alpha}/(n_\alpha+1) g i ( α ) = D i s − D i α + D i s / ( n s − 1 ) + D i α / ( n α + 1 ) . At a Lloyd fixed point, D i s − D i α ≤ 0 D_{is}-D_{i\alpha}\le0 D i s − D i α ≤ 0 ; positive corrections remain on comparable scales, the two positive corrections shrink as the affected clusters grow, restricting improving relocations to samples with small assignment margins. Two-point moves similarly induce smaller centroid changes in larger clusters. Unless these moves trigger substantial subsequent descent, their gains can remain small relative to WCSS summed over all samples. This interpretation concerns the one- and two-point neighborhoods; larger coordinated rearrangements may still yield improvements.
Heuristic Refinement Insertion Points
For each baseline, the Post variant applies BPS-2PLS to its final clustering. This terminal refinement measures the residual improvement available after the original heuristic stops.
For MultiSwap, J-Means, and MergeSplit, we also consider an Inner variant that embeds BPS-2PLS within the search. In MultiSwap and J-Means, BPS-2PLS replaces the initial Lloyd refinement and the Lloyd refinement following each accepted outer move; candidate generation and scoring rules remain unchanged. In MergeSplit, BPS-2PLS is applied with k = 2 k = 2 k = 2 to every trial split of the selected cluster pair, before choosing the best trial and deciding whether to accept it; global Lloyd refinement is retained. LocalSearch is evaluated only with terminal enhancement. The comparison separates improvements available at termination from changes produced by refining intermediate states. Terminal refinement cannot increase WCSS for a given baseline output, whereas internal refinement changes the subsequent search trajectory and need not outperform the baseline on every initialization.
Candidate-Set Scaling Protocol and Interpretation
We study how the retained count m m m changes with n n n on 20News, Sensorless, CIFAR-10, CIFAR-100, MNIST, and Fashion-MNIST. For each dataset, we sample subsets uniformly without replacement at n ∈ { 200 , 500 , 1000 , 2000 , 5000 , 10000 , 20000 } n \in\{200, 500, 1000, 2000, 5000, 10000, 20000\} n ∈ { 200 , 500 , 1000 , 2000 , 5000 , 10000 , 20000 } ; 20News is evaluated only up to n = 10000 n = 10000 n = 10000 . At each size, we generate five independent subsets and run three k k k -means++ initializations per subset. For each subset, we first average m m m over the three initializations. Figure 3 then reports the mean and standard deviation of the five subset averages.
Implications for the theoretical bound. These observations raise the possibility that the O P ( log n ) \mathcal{O}_{\mathrm{P}}(\log n) O P ( log n ) upper bound in Theorem 7.2 is conservative for states reached by the algorithm. The theorem controls all D-local states satisfying the occupancy condition through global diameter bounds and uniform slab counting, which may overestimate the number of candidates at a typical computed state. It is therefore natural to investigate whether a sharper analysis can establish m = O P ( 1 ) m = \mathcal{O}_{\mathrm{P}}(1) m = O P ( 1 ) for algorithmic outputs under suitable distributional and occupancy assumptions. This remains a conjecture: averages from finite-dataset subsampling cannot establish an asymptotic rate or reliably distinguish constant behavior from slow logarithmic growth.
Additional Clustering Quality for Sample-Reassignment Methods
Tables 9 and 10 complement the WCSS and runtime comparison in Table 3 with ACC and NMI. Both metrics are expressed as percentages and summarized by their means and standard deviations across the same ten initializations; timing repetitions do not add independent quality measurements. The Yale results in these tables use 165 samples and 15 classes. The comparisons use the available results only, without imputing missing methods.
Table 9. ACC (%) for the sample-reassignment methods over ten shared initializations. Entries are mean ± standard deviation; higher is better. Bold marks the highest available mean on each dataset, including ties at the displayed precision. Dashes mark Hartigan runs omitted because of excessive runtime.
Improvements and their limits. BPS-2PLS improves both mean ACC and mean NMI over Lloyd on Yale, ORL, USPS-1000, COIL20, MNIST-2000, COIL100, and Sensorless. The ACC increases are 2.97 and 6.03 percentage points on Yale and ORL, respectively, and the corresponding NMI increases are 3.50 and 4.37 percentage points. BPS-2PLS has the highest available mean of both metrics on Yale, ORL, COIL20, and COIL100. However, lower WCSS need not yield better agreement with reference labels: on USPS-1000, Hartigan attains 47.67% ACC and 46.94% NMI, compared with 47.48% and 46.06% for BPS-2PLS, despite the lower WCSS of BPS-2PLS in Table 3 .
Table 10. NMI (%) for the sample-reassignment methods over ten shared initializations. Entries are mean ± standard deviation; higher is better. Bold marks the highest available mean on each dataset, including ties at the displayed precision. Dashes mark Hartigan runs omitted because of excessive runtime.
On the six larger datasets from 20News through Fashion-MNIST, the absolute changes in mean ACC and NMI between BPS-2PLS and D-LO are below 0.01 percentage points before rounding. Thus, the additional WCSS reduction on these datasets is accompanied by nearly unchanged label agreement. The local-optimality guarantee concerns WCSS and does not imply an improvement in ACC or NMI.
Additional Clustering Quality for Heuristic Enhancement
Tables 11 and 12 supplement Table 4 with ACC and NMI on the five datasets, using the same ten shared initializations. The Post and Inner variants are defined in Appendix G.2. The Min-D-LO reference block uses Min-D-LO as Baseline and BPS-2PLS as Inner . J-Means was omitted on COIL20 and MNIST-2000 because of excessive runtime.
Table 11. ACC (%) for heuristic enhancement: mean ± standard deviation over ten initializations. Bold marks the highest mean within each method and dataset, including ties at the displayed precision. Dashes mark J-Means runs omitted because of excessive runtime. For Min-D-LO, Inner reports BPS-2PLS.
Table 12. NMI (%) for heuristic enhancement: mean ± \pm ± standard deviation over ten initializations. Bold marks the highest mean within each method and dataset, including ties at the displayed precision. Dashes mark J-Means runs omitted because of excessive runtime. For Min-D-LO, Inner reports BPS-2PLS.
Terminal refinement. Among the four heuristic methods, Post improves mean ACC in sixteen of eighteen available method–dataset comparisons and mean NMI in all eighteen. ACC changes range from −0.03 to 10.27 percentage points, and NMI increases range from 0.04 to 13.55 percentage points. The two ACC decreases occur for MultiSwap and MergeSplit on MNIST-2000. The largest gains occur for LocalSearch on USPS-1000, where ACC rises from 37.59% to 47.86% and NMI from 33.05% to 46.60%. These results show that the WCSS improvements reported in the main text can also improve agreement with reference labels, although label agreement is not part of the refinement objective.
Internal refinement. Among the three heuristic methods with an Inner variant, Inner improves mean ACC in eleven of thirteen comparisons with the corresponding baseline and likewise improves mean NMI in eleven of thirteen comparisons. Its relative performance against Post depends on the dataset and metric. For example, MergeSplit–Inner on Yale attains 42.18% ACC and 50.74% NMI, compared with 39.94% and 49.56% for Post. On ORL, however, MergeSplit–Inner has lower mean ACC than both the baseline and Post (58.33%, versus 58.75% and 58.90%), even though it has the lowest mean WCSS among the three variants. For MergeSplit on USPS-1000, Inner has the highest ACC but lower NMI than the other variants. On COIL20, MergeSplit–Inner has higher mean ACC and NMI than Post despite a higher mean WCSS. These differences reflect changes in the search trajectory and the distinction between optimizing WCSS and matching reference classes. The tables provide descriptive comparisons across initializations; they do not establish statistical significance.
Runtime by Algorithmic Phase
We measure the runtime composition of BPS-2PLS on all twelve datasets in Table 8 with screening enabled. This separate timing study was run in MATLAB R2026b.
Measurement protocol. We use three k k k -means++ initializations per dataset and five timed repetitions per initialization after warm-up. All four phase timers and the total wall-clock time are collected from the same instrumented run, with MATLAB’s function-level Profiler disabled. We first average repetitions within each initialization, then compute means and sample standard deviations across the three initialization averages. A phase’s percentage is its mean runtime divided by the mean total runtime. These measurements characterize this timing batch and are not pooled with the ten-initialization quality experiments.
Phase definitions. Descent includes Lloyd iterations and one-point local descent throughout the run. Screen constructs and evaluates the screening bounds, and Search performs the exact search over the retained sample pairs, including their distance calculations. Other includes initialization of the clustering state, updates for accepted two-point moves, and remaining overhead. The four phases partition the measured total; pair-distance computation is included in Search and is not counted again in Other.
Table 13. Runtime by phase with screening enabled. Times are in seconds, reported as mean ± \pm ± standard deviation across three initializations after averaging five repetitions within each initialization. Parentheses give each phase’s percentage of the mean total time; percentages below 0.1% are shown to two decimal places. Bold marks the largest mean phase time for each dataset.
Dominant costs. Descent is the largest phase on eleven of the twelve datasets, accounting for 52.2%–96.7% of total runtime on those datasets. ORL is the exception, where screening accounts for 60.7% of runtime compared with 33.3% for descent. Screening is also substantial on COIL100, Sensorless, CIFAR-100, and Yale, where it accounts for 44.3%, 35.3%, 31.1%, and 28.9% of runtime, respectively. Exact pair search remains relatively small: it accounts for at most 13.5% on Yale and no more than 4.8% on any other dataset; on Sensorless, CIFAR-10, MNIST, and Fashion-MNIST it is below 0.05%. Other overhead remains at or below 2.1% across all datasets. These phase shares suggest that further runtime reductions on the evaluated workloads depend primarily on accelerating descent and screening rather than the remaining exact pair search. Because the timing study contains only screening-enabled runs, the breakdown characterizes runtime composition rather than the net speedup attributable to screening.