Creates a sequence of adaptive-radius graphs by varying the k.scale
parameter passed to create.rknn.graph(type = "adaptive.radius"). By
default, ANN-backed construction uses the batched C++ backend while the
direct all-pairs reference path uses the scalar R loop. Set backend = "r"
to force the scalar loop for ANN parity checks.
Usage
create.rknn.graphs(X, k.values, ..., backend = c("auto", "cpp", "r"))Arguments
- X
Numeric matrix or data frame with observations in rows.
- k.values
Strictly increasing integer vector, each between 1 and n - 1. Returned graphs follow this order.
- ...
Additional arguments forwarded to
create.rknn.graph()withtype = "adaptive.radius". The argumentstype,k.scale, andradiusare reserved by this plural constructor.- backend
Character scalar.
"auto"uses the batched C++ ANN backend whenradius.search = "ann"and the scalar R loop whenradius.search = "all.pairs"."cpp"forces the batched C++ ANN backend and therefore requiresradius.search = "ann"."r"forces the scalar R loop and is retained as a reference parity backend.
Value
A list of class "rknn_graphs" with components:
- graphs
A named list of adaptive-radius graph objects, one per k.
- k_statistics
A data frame with one row per k containing edge, component, and MST-repair counts.
- timing
Present only when forwarded options request graph timing; contains backend-specific construction timing rows.
Attributes include k.values and n_vertices.
Examples
X <- matrix(c(0, 1, 3, 4), ncol = 1)
result <- create.rknn.graphs(X, k.values = seq.int(1, 2), radius.search = "all.pairs",
graph.detail = "minimal",
prune.method = "none")
names(result$graphs)
#> [1] "1" "2"
result$k_statistics
#> idx k n_edges n_edges_before_pruning n_edges_after_pruning
#> 1 1 1 2 2 2
#> 2 2 2 5 5 5
#> n_components_before n_components_after n_mst_edges_added
#> 1 2 2 0
#> 2 1 1 0