create.rknn.graphs: Compute Adaptive Radius-kNN Graphs Across k Values

View source: R/radius_graphs.R

create.rknn.graphsR Documentation

Compute Adaptive Radius-kNN Graphs Across k Values

Description

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,
  kmin = NULL,
  kmax = NULL,
  ...,
  k.values = NULL,
  backend = c("auto", "cpp", "r")
)

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.

backend

Character scalar. "auto" uses the batched C++ ANN backend when radius.search = "ann" and the scalar R loop when radius.search = "all.pairs". "cpp" forces the batched C++ ANN backend and therefore requires radius.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 kmin, kmax, k.values, and n_vertices.

See Also

create.rknn.graph()

Examples

X <- matrix(c(0, 1, 3, 4), ncol = 1)
result <- create.rknn.graphs(
  X,
  kmin = 1,
  kmax = 2,
  radius.search = "all.pairs",
  graph.detail = "minimal",
  prune.method = "none"
)
names(result$graphs)
result$k_statistics


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