A Single-Swap Local Search Algorithm for k-Means of Lines

Ting Liang, Xiaoliang Wu, Junyu Huang, Jianxin Wang, Qilong FengNeurIPS 2025

Introduction

Standard $k$-means clustering is a foundational tool in data science, designed to find $k$ points (centers) that minimize the sum of squared distances to a set of data points. However, many real-world applications—such as tracking moving objects in computer vision, analyzing missing data, or mapping road networks—deal with data better represented as lines rather than points.

Clustering lines is fundamentally more difficult than clustering points. To address this, researchers have developed SLS-$k$-ML (Single-Swap Local Search for $k$-Means of Lines), the first single-swap local search algorithm for this problem, providing a provable $(500 + \varepsilon)$-approximation guarantee.

The Challenges of Line Clustering

Extending traditional point-based clustering to lines presents two major mathematical hurdles:

  1. The Distance Dilemma: The distance from a point to a line does not satisfy the triangle inequality. This geometric law is the backbone of almost all proofs for point-based clustering; without it, standard analytical frameworks fall apart.
  2. The Search Space Problem: Lines extend infinitely in space. In point-based clustering, good candidate centers are usually located near the data points themselves. For lines, it is unclear where a "good" center should be located within a continuous, infinite space.

Methodology: CrossLine and Proportional Capture

To overcome these obstacles, the authors propose an algorithm that operates in two main stages: initialization and local search.

The initialization phase uses a CENTROID-SET procedure to generate a finite set of candidate points from the intersections or closest points of the input lines, sampling $k$ points to start. The algorithm then iteratively attempts to improve the solution by swapping a current center for a better one.

Finding these better centers relies on two novel theoretical contributions:

  • The CrossLine Structure: This method samples two lines and creates a principled grid of candidate points around their closest proximity. This guarantees that even though the search space is infinite, the algorithm only needs to evaluate a small, high-quality set of points.
  • Proportional Capture Relation: To bypass the lack of triangle inequality, the authors redefine how a current center "captures" an optimal center. Instead of relying on geometric distance, they define capture based on the proportion of lines assigned. If a current center handles the largest share of an optimal center's lines, it is considered to capture it. This shift enables a refined analysis and establishes the algorithm's approximation bound.

Experimental Results

The researchers evaluated SLS-$k$-ML on both synthetic datasets (up to 10,000 lines in 5D and 10D spaces) and real-world OpenStreetMap datasets representing trajectories and road segments in 2D space. The algorithm was compared against coreset-based methods, which compress data before clustering.

  • Theoretical Guarantee: The algorithm achieves a $(500 + \varepsilon)$-approximation in polynomial time. While 500 is a large constant, it represents a major theoretical milestone as the first provable bound for a single-swap local search in this domain.
  • Superior Speed: On datasets with more than 5,000 lines, SLS-$k$-ML ran at least 43 times faster than the coreset-based baselines. Coreset methods often require exhaustive searches over candidate sets that can take over 12 hours, whereas the local search approach finds high-quality solutions in seconds or minutes.
  • Better Accuracy: Across all experiments, the proposed algorithm achieved a lower clustering cost than the baselines, sometimes by several orders of magnitude.

Limitations and Future Work

While highly effective, the algorithm faces a "dimensionality curse." The CrossLine structure involves a $9^d$ complexity term, making it exceptionally efficient for low-dimensional data (like 2D or 3D) but potentially slow as dimensions increase. Additionally, while the 500-approximation is a breakthrough, it remains a loose upper bound. Future research will likely focus on tightening this constant factor and extending the framework to "flats" (higher-dimensional affine subspaces like planes).

Summary updated

BibTeX
@inproceedings{liang2025single,
  author = {Ting Liang and Xiaoliang Wu and Junyu Huang and Jianxin Wang and Qilong Feng},
  title = {{A Single-Swap Local Search Algorithm for k-Means of Lines}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=oo9IrVWcFL},
}
Figure