This project presents an optimized computational geometry algorithm to solve the Alpha-Euclidean Minimum Spanning Tree (
Applications of threshold-constrained spanning trees are prevalent in fields such as spatial clustering, wireless sensor network topology control, and agglomerative hierarchical clustering, where connection costs beyond a certain distance are physically or economically prohibitive [1, 2].
Let
The weight function
The
-
Minimality: The total weight
$W(T) = \sum_{e \in T} w(e)$ is globally minimized. -
$\alpha$ -Constraint:$\forall e \in T, w(e) \le \alpha$ .
If the subgraph
The naive approach to finding an EMST on
The solution leverages a heavily optimized variant of Prim's Algorithm integrating spatial data structures:
-
Spatial Grid Hashing: The
$\mathbb{R}^2$ space is partitioned into a uniform grid where the cell width$C = \max(\alpha, 1.0)$ . Points are hashed into these cells. During the vertex relaxation phase of Prim's algorithm, edge evaluations are strictly localized to the current vertex's cell and its 8 adjacent Moore neighborhood cells. This geometric pruning reduces the effective degree of each vertex, dynamically bypassing the full$\mathcal{O}(n^2)$ distance evaluations. -
Index Minimum Priority Queue (
IndexMinPQ): A custom-built binary heap maintaining the minimum distance mapping to non-tree vertices in$\mathcal{O}(\log n)$ extraction and decrease-key time. -
Primitive Mapping: To prevent cache misses and object allocation overhead (common in JVM environments), Euclidean distances are evaluated dynamically using squared integer arithmetic (
$d^2 \le \alpha^2$ ), completely circumventing expensive floating-point functions inside the hot loop.
-
Expected Time Complexity:
$\mathcal{O}(n \log n)$ . Under the assumption of uniform spatial distribution, the number of neighbors within distance$\alpha$ bounded by spatial hashing is effectively constant$\mathcal{O}(1)$ . Extracting the minimum edge operations thus dominates at$\mathcal{O}(n \log n)$ [4]. -
Worst-Case Time Complexity:
$\mathcal{O}(n^2 \log n)$ . Occurs only when the dataset is hyper-densely packed into a singular spatial hash threshold area. -
Space Complexity:
$\Theta(n)$ . Maintained strictly via flattened parallel primitive arrays representing grids, priority queues, and parent pointers.
Requires a Java Development Kit (JDK 8+).
mkdir -p bin
javac -d bin src/EMST.javaThe target accepts the dataset file path and the
java -cp bin EMST <input_file_path> <alpha_value>Example:
java -cp bin EMST data/input_points1.txt 1.5Points must be defined with integer coordinates, one point per line, comma-separated.
x1, y1
x2, y2
...
The program guarantees canonical, deterministic output by breaking vertex selection ties based on Y-major coordinate ordering and strictly tracking chronological grid encounters.
- Total Weight: Printed first, formatted strictly to 10 decimal places.
-
Topology Sequence: If
$n \le 10$ , the subset edges are printed lexicographically formatted as(x1, y1)(x2, y2). -
Disconnected Graph: Outputs
FAILif the subgraph under threshold$\alpha$ cannot yield a valid MST.
Sample Valid Run:
3.0000000000
(0, 0)(0, 1)
(0, 0)(1, 0)
(1, 0)(1, 1)
- Zahn, C. T. (1971). Graph-theoretical methods for detecting and describing gestalt clusters. IEEE Transactions on Computers, 100(1), 68-86.
- Penrose, M. (2003). Random Geometric Graphs (Vol. 5). Oxford university press.
- Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2022). Introduction to Algorithms (4th ed.). MIT press.
- Bentley, J. L., & Friedman, J. H. (1979). Data structures for range searching. ACM Computing Surveys (CSUR), 11(4), 397-409.