Efficient Construction of Neighborhood Graphs by the Multiple Sorting Method

Takeaki Uno, Masashi Sugiyama, Koji TsudaarXiv 2009 · arXiv

Abstract

Building $\epsilon$-neighbor graphs for massive datasets is a fundamental yet computationally expensive task in machine learning. This paper introduces a highly efficient approach that combines Locality Sensitive Hashing (LSH) with a specialized "Multiple Sorting Method" (MSM). By mapping high-dimensional vectors to bit strings and employing masked radix sorts, the proposed method achieves near-linear time complexity. Experimental results on a dataset of 1.6 million images demonstrate that MSM significantly outperforms traditional tree-based methods, providing a scalable solution for constructing neighborhood graphs in "big data" applications.

Introduction

Neighborhood graphs, where data points are connected to their closest peers, serve as the foundation for various algorithms, including manifold learning, spectral clustering, and semi-supervised learning. However, the construction of these graphs presents a significant computational challenge. A naive "all-pairs" approach requires $O(n^2)$ distance calculations, which becomes prohibitive for datasets with millions of points. While tree-based structures like KD-trees or Cover Trees offer improvements, their performance often degrades in high-dimensional spaces or fails to scale efficiently to massive datasets.

This paper addresses the problem of constructing $\epsilon$-neighbor graphs—graphs that connect all pairs of points within a fixed distance $\epsilon$. The authors propose a pipeline that transforms this geometric proximity problem into an efficient string-sorting task, enabling the processing of millions of points in a matter of hours.

Methodology

The proposed system utilizes a two-step process to identify neighbors efficiently:

  1. Vector-to-String Mapping (LSH): The algorithm first uses Cosine Locality Sensitive Hashing to project high-dimensional vectors into short bit strings. This mapping ensures that vectors close in the original space are likely to result in strings with a small Hamming distance.
  2. Multiple Sorting Method (MSM): The core innovation is the MSM, which identifies all pairs of strings differing by at most $d$ bits. Unlike standard LSH, which requires exact matches, MSM uses masked radix sorts. By "masking" specific bit positions and sorting the remaining bits, identical strings in the reduced space are grouped together, effectively finding "near-miss" pairs.
  3. Blockwise Masking: To prevent a combinatorial explosion in the number of sorting passes, the authors implement blockwise masking. This groups bits into blocks, drastically reducing the required number of iterations while maintaining the ability to detect neighbors.
The Multiple Sorting Method (MSM) utilizes character masking and blockwise strategies to efficiently detect close pairs in a string pool.

Experimental Evaluation

The algorithm was evaluated using a massive dataset of 1.6 million small images (Torralba et al., 2008). These images were converted into 1024-dimensional grayscale vectors. The authors tested the MSM approach against various subset sizes to observe computational growth rates and compared its performance to state-of-the-art exact methods like Cover Trees.

Results and Discussion

The MSM approach demonstrated significant speedups over traditional methods. For the full 1.6 million image dataset, the algorithm completed the graph construction in approximately 2.09 hours, identifying 1.5 million edges. This performance is attributed to several key factors:

  • The "Similar, Not Identical" Advantage: Standard LSH requires many independent hash tables (replicates) because it relies on neighbors colliding into the exact same bucket. By allowing for a Hamming distance $d > 0$, MSM enables neighbors to fall into similar buckets, which drastically reduces the number of replicates needed to maintain high accuracy.
  • Output Sensitivity: The runtime of the algorithm is proportional to the number of actual neighbors found ($m$), making it exceptionally fast for sparse graphs.
  • Accuracy: Despite being an approximate method, MSM can achieve a "missing edge ratio" as low as $1.0 \times 10^{-6}$, making it practically indistinguishable from exact methods for most machine learning tasks.
The relationship between the number of replicates and the missing edge ratio across different Hamming distance thresholds (d). Higher values of d allow for significantly fewer replicates while maintaining high accuracy.

Conclusion

The Multiple Sorting Method provides a robust and scalable framework for neighborhood graph construction. By shifting the focus from individual point queries to batch "all-pairs" discovery, the authors achieve performance levels that make large-scale manifold learning feasible. Future work may involve the implementation of MSM on GPUs to leverage the parallel nature of radix sort and exploring non-random hashing techniques to further improve accuracy and efficiency.

Summary updated

Abstract

Neighborhood graphs are gaining popularity as a concise data representation in machine learning. However, naive graph construction by pairwise distance calculation takes $O(n^2)$ runtime for $n$ data points and this is prohibitively slow for millions of data points. For strings of equal length, the multiple sorting method (Uno, 2008) can construct an $\epsilon$-neighbor graph in $O(n+m)$ time, where $m$ is the number of $\epsilon$-neighbor pairs in the data. To introduce this remarkably efficient algorithm to continuous domains such as images, signals and texts, we employ a random projection method to convert vectors to strings. Theoretical results are presented to elucidate the trade-off between approximation quality and computation time. Empirical results show the efficiency of our method in comparison to fast nearest neighbor alternatives.
BibTeX
@misc{uno2009efficient,
  author = {Takeaki Uno and Masashi Sugiyama and Koji Tsuda},
  title = {{Efficient Construction of Neighborhood Graphs by the Multiple Sorting Method}},
  year = {2009},
  eprint = {0904.3151},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/0904.3151},
}
Figure