Skip to contents

Constructs G0 with create.iknn.graphs(), then constructs G1, G2, ..., Gm by repeatedly applying create.geodesic.iknn.graph() to each graph in the k.values sequence. This implements the iterated nerve rule

$$\{i,j\} \in E(G_{t+1}) \iff kNN_{G_t}(i) \cap kNN_{G_t}(j) \ne \emptyset,$$

with edge length

$$\ell_{t+1}(i,j) = d_{G_t}(i,j).$$

Usage

create.iterated.iknn.graphs(
  X,
  k.values,
  n.iterations = 3L,
  small.component = c("error", "truncate"),
  max.path.edge.ratio.deviation.thld = 0,
  path.edge.ratio.percentile = 0.5,
  threshold.percentile = 0,
  pca.dim = 100,
  variance.explained = 0.99,
  verbose = TRUE,
  knn.cache.path = NULL,
  knn.cache.mode = c("none", "read", "write", "readwrite")
)

Arguments

X

Numeric matrix with rows as observations and columns as features.

k.values

Strictly increasing integer vector of neighborhood sizes, each between 1 and n - 1.

n.iterations

Non-negative integer number of geodesic rebuilds after G0. The default 3 returns G0, G1, G2, and G3.

small.component

Component-size policy forwarded to every geodesic rebuild.

max.path.edge.ratio.deviation.thld, path.edge.ratio.percentile, threshold.percentile

Initial G0 pruning arguments forwarded to create.iknn.graphs(). The default deviation and quantile thresholds are zero so that G0 is the unpruned iKNN 1-skeleton.

pca.dim, variance.explained, verbose, knn.cache.path, knn.cache.mode

Additional arguments forwarded to create.iknn.graphs() for the initial G0 construction.

Value

A list of class "iterated_iknn_graphs" with entries:

k.values

Integer vector of requested k values.

n_iterations

Number of geodesic rebuilds after G0.

initial_graphs

The "iknn_graphs" object returned by create.iknn.graphs() for G0.

graphs

Nested list named G0, G1, ...; each entry is a named list of graph objects for k.values.

summary

Data frame with one row per iteration and k.

Examples

set.seed(1)
X <- matrix(rnorm(30), ncol = 2)
out <- create.iterated.iknn.graphs(X, k.values = seq.int(2, 3), n.iterations = 1,
    verbose = FALSE)
out$summary
#>   iteration graph k n_vertices n_edges n_ccomp mean_degree min_degree
#> 1         0    G0 2         15      37       1    4.933333          3
#> 2         0    G0 3         15      58       1    7.733333          5
#> 3         1    G1 2         15      37       1    4.933333          3
#> 4         1    G1 3         15      58       1    7.733333          5
#>   max_degree
#> 1          8
#> 2         10
#> 3          8
#> 4         10