cpp.create.rknn.graphs: Compute Adaptive Radius-kNN Graphs With Batched ANN Search

View source: R/radius_graphs.R

cpp.create.rknn.graphsR Documentation

Compute Adaptive Radius-kNN Graphs With Batched ANN Search

Description

Tentative C++-backed counterpart to create.rknn.graphs(). It builds one ANN kd-tree, computes nearest-neighbor distances through the maximal requested k value once, derives each requested k.scale from that shared result, and materializes adaptive-radius edge tables for all k values in C++. The existing R finalization path is then used for pruning, lifecycle branches, and optional component repair.

This function is exported as a diagnostic helper while the native backend is being benchmarked and validated. Ordinary callers should use create.rknn.graphs() with the default backend = "auto" or with backend = "cpp" to request this native backend explicitly.

Usage

cpp.create.rknn.graphs(X, kmin = NULL, kmax = NULL, ..., k.values = NULL)

Arguments

X

Numeric matrix or data frame with observations in rows.

kmin, kmax

Optional integer scalars defining the inclusive k range. Required when k.values is NULL.

...

Additional arguments forwarded to create.rknn.graph() with type = "adaptive.radius". The arguments type, k.scale, and radius are reserved by this plural constructor.

k.values

Optional integer vector of k values to evaluate. When supplied, k.values is used instead of kmin:kmax, and the returned graph order follows the supplied vector.

Value

A "rknn_graphs" object with the same default structure as create.rknn.graphs(). When return.timing = TRUE, timing is attached at the graph-sequence level because the ANN setup and max-k scale search are shared across k values.

See Also

create.rknn.graphs()

Examples

X <- matrix(c(0, 1, 3, 4), ncol = 1)
result <- cpp.create.rknn.graphs(
  X,
  k.values = c(1, 2),
  graph.detail = "minimal",
  prune.method = "none"
)
names(result$graphs)


dgraphs documentation built on Aug. 21, 2026, 1:08 a.m.