Three backends compute alpha complexes; AlphaShapes(points, backend) (alpha/AlphaShapes.scala) chooses between them. Two triangulate (BowyerWatsonDelaunay, HelixDelaunay, both DelaunayAlphaShapes); AlphaComplexDQP does not. This page is the developer-facing view. For the user-facing framing (which one to pick, and the tradeoffs), see the User's Guide.
Dispatch
object AlphaShapes:
def apply(
points: PointCloud,
backend: AlphaBackend = AlphaBackend.Default,
requireValidTriangulation: Boolean = false,
maxRadius: Optional[Double] = Optional.empty,
maxDimension: Optional[Int] = Optional.empty
)(using factor: EpsilonFactor): AlphaShapes // default EpsilonFactor(1e-5), a fraction of the extent of the points
With a maxRadius, every backend returns the simplices of alpha value at most maxRadius, with the same values (in general position; on cospherical points DQP keeps the simplex they span where a triangulation splits it): BowyerWatson and Helix build the whole triangulation and filter it (RadiusLimitedAlphaShapes); DQP builds only up to the radius, dimension by dimension, up to maxDimension + 1 (AlphaComplexDQPStream). AlphaBackend.Default resolves to BowyerWatson for points at most 4 coordinates wide and Helix above, unless a radius is given and AlphaShapes.prefersDQP expects DQP to be faster: it estimates the mean number of points within 2 maxRadius of a point (64 sample points) and compares a per-point cost model fitted to measurements (DQP about c_d k^1.6, BowyerWatson about b_d (n/1000)^0.2, Helix in 5-D about 150 (n/1000)^0.4; in ambient dimension 6 and up DQP whenever a radius is given). AlphaShapes.fromPoints (the Persistence verb) and the MATLAB/CLI maxFiltrationValue pass the radius through. Without one the verb calls AlphaShapes.upToEnclosingRadius, which cuts at metricSpace.minimumEnclosingRadius, past which the union of balls is contractible, and chooses by the degree cap instead of the radius (every point is in every neighbourhood there): DQP when the ambient dimension is at least AlphaShapes.dqpMinAmbientDimension (8) and maxDimension is at most 2 below it (AlphaShapes.prefersDQPAtEnclosingRadius), else the triangulation (BowyerWatson or Helix). DQP's cost follows the cap (it builds simplices up to dimension maxDimension + 1) and a triangulation's does not: at 40 points with maxDimension = 4 DQP is 3 times faster in 8 dimensions, 8 times in 10 and 28 times in 12, and the only backend that finishes in 15; the top degree d - 1 stays on the triangulation, where DQP needs up to 2.5 times the memory (the caps between 4 and d - 2 are interpolated, not measured). The MATLAB/CLI complex=alpha does the same. maxFiltrationValue = Infinity gives the whole complex, and engine=fast-alpha needs a whole triangulation and refuses a radius. The facade's alphaBackend string goes through AlphaBackend.parse (default default). All backends extend the common AlphaShapes abstract class, so they are interchangeable for any code consuming the stream: AlphaComplexSpec runs identical property checks against both, and AlphaDispatchSpec checks that the radius-limited complexes and the verb's bars agree.
DelaunayAlphaShapes — the alpha complex of a triangulation
The shared base of the two triangulating backends: a subclass supplies the top simplices, their values and any exactly repeated points; the base enumerates the faces (a hash table of sorted vertex rows per dimension, each face found from its immediate cofaces), assigns values top-down by the Gabriel rule below, and sorts each dimension in the filtration order. Circumspheres come from a Householder QR of the edge vectors (the Gram system squares the condition number and lost digits on slivers).
The geometry it works with is public. Hyperplane(normal, offset) is { x : normal . x = offset }, with isLight telling which side a point is on. Hypersphere(center, radius) (given an Epsilon) has contains and onSphere, and Hypersphere(points) is the sphere through a point set (a least-squares solve by singular value decomposition). DelaunaySimplex(simplex, circumsphere) pairs a simplex of the triangulation with its circumsphere. LimitedAlphaShapesStream(helix, maxDim) is the alpha complex without its simplices above maxDim, with the same values and order; FastAlphaHomologyEngine uses it for the degrees between H_0 and H_{d-1}.
BowyerWatsonDelaunay — incremental Delaunay with exact predicates, 1 to 4 dimensions
alpha/BowyerWatson.scala, predicates in alpha/DelaunayPredicates.scala. Bowyer–Watson on flat arrays (cell vertices and neighbours, d + 1 each, a free list), with a symbolic vertex at infinity so the hull needs no special case; points are inserted in BRIO order (random rounds, Z-order within a round) and located by a visibility walk from the last new cell. Orientation and in-sphere are determinants expanded over permutations, evaluated in floating point with a conservative error bound and redone in exact BigDecimal arithmetic when the bound does not settle the sign. An exact in-sphere tie is broken by a symbolic perturbation of the lifted coordinate in descending point index, so the result is the Delaunay triangulation of an infinitesimally perturbed point set: valid on grids and cospherical input, and identical for every insertion order (BowyerWatsonSpec). Exactly repeated points keep the smallest index in the triangulation and join it by an edge of value 0. The input is first projected onto its affine span; a span of more than 4 dimensions is refused (the determinant expansion is n! terms; Helix and DQP cover higher dimensions).
HelixDelaunay — an actual Delaunay triangulation
Builds an actual Delaunay triangulation incrementally: finds a bootstrap simplex, then walks the frontier of facets, testing candidate points against each facet's supporting hyperplane and circumsphere. filtrationValue returns unsquared radii, matching DQP's own units after radiusOf. Values are assigned top-down: a top-dimensional simplex gets its circumradius; a lower simplex gets the radius of its own smallest circumsphere (centre in its affine hull) if it is Gabriel -- no vertex of a coface strictly inside that sphere -- and otherwise the smallest value among its immediate cofaces. For points in general position this is the alpha filtration exactly, and HelixDqpAgreementSpec checks that Helix and DQP give the same barcode in dimensions 2, 3 and 4.
Cost. A triangulation pays for the whole Delaunay complex, while the barcode up to degree 2 needs only its 3-skeleton: for 40 uniform points the complex has 577,257 simplices in R^8 and about 6.4 million in R^10, the 3-skeleton at most 102,000. DelaunayAlphaShapes therefore keeps the faces and their values in flat arrays (a face table per dimension, each face found from its immediate cofaces) and makes the Simplex objects of a dimension only when that dimension is read: the Persistence verb reads the dimensions up to maxDimension + 1 and pays arrays, not objects, for the ones above. filtrationValue looks a simplex up in its face table. Forty points in R^10 take about a minute on four cores (GUDHI, which builds the same face lattice top-down, takes 56 s); AlphaProfileDriver (src/test/scalajvm) prints the phases of one input: triangulation, faces and values, sort, reduction.
Known limitation: HelixDelaunay's greedy walk can produce an invalid triangulation on near-cospherical point configurations. Every result is checked, and an invalid one is repaired by retriangulating slightly perturbed points (see Triangulation repair below). At a very small tolerance (1e-9) a 3-D grid can still fail to repair.
For this reason, broad randomized DQP-vs-Helix cross-validation is kept out of the default test suite; Helix should not be treated as an unconditional oracle on near-degenerate inputs.
FastAlphaHomologyEngine
FastAlphaHomologyEngine applies the dual-graph union-find strategy used by FastCubicalHomologyEngine to a Delaunay triangulation (BowyerWatsonDelaunay or HelixDelaunay).
It requires a full triangulation in which every codimension-1 facet has one or two top-dimensional cofaces. BowyerWatsonDelaunay's exact predicates guarantee this. Because HelixDelaunay can violate it on rare degenerate inputs, the engine validates the triangulation and throws FastAlphaTriangulationException rather than constructing an invalid dual graph.
For ambient dimension d >= 3, H_0 and H_{d-1} use the fast union-find paths while intermediate dimensions are delegated to CellularCohomologyEngine (cycles by the involution).
The engine is exposed as engine="fast-alpha" and is available with the triangulating alpha backends (default, bowyer-watson, helix), not DQP.
Triangulation repair
When requireValidTriangulation is enabled, a Helix triangulation that violates the facet-multiplicity requirement is retriangulated after a small perturbation of the near-degenerate points. Filtration values are then recomputed from the original coordinates. Without the option, a cheaper structural check runs on every triangulation, and a failure is repaired the same way.
This option is mainly intended for FastAlphaHomologyEngine, whose dual graph requires a valid triangulation.
AlphaComplexDQP — dual active-set QP, never builds Delaunay at all
Implements Erik Carlsson & John Carlsson, Computing the alpha complex using dual active set quadratic programming, Scientific Reports 14:19824 (2024), https://doi.org/10.1038/s41598-024-63971-3. Instead of building the Delaunay complex and reading off which simplices survive, it answers a per-simplex feasibility query directly — "is this Voronoi/power face nonempty, and does it meet the ball of radius r?" — posed as a convex QP and answered in the Lagrangian dual, which is what lets it scale to very high ambient dimension where Delaunay is infeasible.
The QP solver follows DAQP (Arnström, Bemporad & Axehill, IEEE TAC 67(8):4362-4369, 2022), collapsed to Cholesky update/downdate of the active working set (CholeskyWorkspace) since the paper's problem is already in DAQP's canonical least-distance inner form.
Math cheat sheet
Base vertex x, neighbours x_i, power weights p. Filtration values are squared radii (powers) per the paper's Definition 10 — AlphaComplexDQP.radiusOf takes the square root, and AlphaShapeDQP.filtrationValue goes through radiusOf (not the raw squared value) so it matches HelixDelaunay.filtrationValue's units. The dual objective only needs squared distances: B_ij = (d²(i,x) + d²(j,x) - d²(i,j))/2 — which is why PowerDistance sits on squared distance rather than extending FiniteMetricSpace directly, bridging via PowerDistance.toMetricSpace only where interop is needed (e.g. cechNeighbours()'s VP-tree spatial index). Caveat: B is PSD only for Euclidean-embeddable metrics.
AlphaShapeDQP always computes the complete, untruncated alpha complex, matching HelixDelaunay's own always-untruncated behavior (a finite radius bound would silently exclude the arbitrarily-large-circumradius simplices degenerate configurations legitimately produce — see Degeneracies). Callers who want a radius-truncated alpha complex should call AlphaComplexDQP.euclidean(points, maxRadius, maxDimension, settings) directly.
Storage
The simplices of each dimension are kept in an open-addressing table of int arrays (DelaunayAlphaShapes.FaceTable, the same as the triangulation backends use), with the value of each simplex in a parallel Double row; lookups probe the table instead of hashing a Simplex. By default each simplex also keeps its witness, the point of its restricted Voronoi cell that the value comes from (AlphaComplexDQP.witness), which costs one row of the ambient dimension per simplex. AlphaDQPSettings(keepWitnesses = false) drops it; AlphaShapes builds its streams that way, because they never read it. In high ambient dimension the witnesses and the Simplex objects are most of the memory of a DQP complex, which is one reason Helix is the better backend from about ten dimensions on.
Numerical robustness
rankTolerancedefaults to1e-6; smaller tolerances can destabilize the active-set Cholesky updates, while substantially larger values can reject valid directions.- Ratio-test ties use the constraint's global index (Bland-style ordering).
- When a small Schur complement cannot be handled safely,
DualQP.solvedoes not commit to it. Valid simplices of large circumradius, which are common in high ambient dimension, have such pivots, so the candidate is solved again withrescueRankTolerance(default1e-11) and kept only if the multipliers it ends with satisfy the optimality conditions of the dual against the data (a garbage answer from a poisoned factor fails them). The cells then agree with Helix's within the radius, up to a circumradius of about a hundred times the point spacing; past that the values are approximate, so givemaxRadius(or useupToEnclosingRadius) rather than building the whole complex with DQP. - Vertex filtration values must use
space.weight(x); hard-coding0.0breaks weighted alpha filtrations.
Parallelism
The alpha complex shares its work between the threads of the JVM's common ForkJoinPool, and gives the same answer whatever the number of threads: the same simplices, values to the last bit, and stream order.
AlphaDQPSettings.parallel(on by default) solves the QPs of different vertices at the same time.- The Helix walk evaluates the next queued frontier facets together: for each, the Delaunay cofacet, the points on its circumsphere and the hyperplanes of its other facets depend on the points alone. The walk then takes the facets in queue order, as it always did, and uses what was computed; a facet that is cancelled or visited before its turn was evaluated for nothing. The batch is eight facets per thread, and only for clouds with at least 500 coordinates.
- The face tables of each dimension are numbered in the order the faces first occur, as a sequential pass would, but the faces are found by one thread per partition of their hash, and the numbers are the ranks of the first occurrences.
- Circumspheres, the Gabriel test, alpha values, the
Simplexobjects and the sort of each dimension run on ranges of the faces. - The Bowyer-Watson insertion is sequential: each insertion changes the triangulation the next one walks in. Its time is the triangulation and no more than a few seconds for 100,000 points in R^3; the rest of the pipeline is shared.
-Djava.util.concurrent.ForkJoinPool.common.parallelism=0 runs everything on the calling thread. On Scala.js there is one thread and the same code runs in order.
Backend tradeoffs
DQP is primarily valuable for high ambient dimension and direct alpha-complex construction, not as a universal speed improvement over Delaunay-based methods. See the User's Guide for user-facing tradeoffs.