Create iterated graph-geodesic iKNN graphs
Source:R/geodesic_iknn_graphs.R
create.iterated.iknn.graphs.RdConstructs 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 default3returnsG0,G1,G2, andG3.- small.component
Component-size policy forwarded to every geodesic rebuild.
- max.path.edge.ratio.deviation.thld, path.edge.ratio.percentile, threshold.percentile
Initial
G0pruning arguments forwarded tocreate.iknn.graphs(). The default deviation and quantile thresholds are zero so thatG0is 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 initialG0construction.
Value
A list of class "iterated_iknn_graphs" with entries:
- k.values
Integer vector of requested
kvalues.- n_iterations
Number of geodesic rebuilds after
G0.- initial_graphs
The
"iknn_graphs"object returned bycreate.iknn.graphs()forG0.- graphs
Nested list named
G0,G1, ...; each entry is a named list of graph objects fork.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