| create.single.iknn.graph | R Documentation |
Creates and prunes an intersection-weighted k-nearest neighbors (IWD-kNN) graph from input data. The graph is constructed based on feature space distances and intersection sizes between neighbor sets.
create.single.iknn.graph(
X,
k,
max.path.edge.ratio.deviation.thld = 0.1,
prune.method = c("global.geodesic", "none", "local.geodesic", "global.geodesic.ratio"),
prune.tau = NULL,
prune.local.k = NULL,
path.edge.ratio.percentile = 0.5,
threshold.percentile = 0,
compute.full = FALSE,
with.isize.pruning = FALSE,
with.edge.pruning.stats = FALSE,
pca.dim = 100,
variance.explained = 0.99,
knn.metric = c("euclidean", "linf.simplex"),
linf.tol = sqrt(.Machine$double.eps),
connect.components = FALSE,
connect.method = c("component.mst", "component.mst.ann", "global.mst"),
bridge.k = NULL,
bridge.k.max = NULL,
bridge.growth = 2,
with.lifecycle.branches = FALSE,
verbose = TRUE,
knn.cache.path = NULL,
knn.cache.mode = c("none", "read", "write", "readwrite")
)
X |
A numeric matrix where rows represent data points and columns represent features. Data frames will be coerced to matrices. |
k |
Integer scalar. The number of nearest neighbors to consider for each point. Must be positive and less than the number of data points. |
max.path.edge.ratio.deviation.thld |
Numeric in |
prune.method |
Character scalar. |
prune.tau |
Numeric scalar greater than 1, or |
prune.local.k |
Integer scalar or |
path.edge.ratio.percentile |
Numeric in |
threshold.percentile |
Numeric in |
compute.full |
Logical scalar controlling additional full-payload outputs.
If TRUE, keeps legacy original-graph components |
with.isize.pruning |
Logical scalar. If TRUE, compute intersection-size pruning outputs and related statistics. Default is FALSE. |
with.edge.pruning.stats |
Logical scalar. If TRUE, compute edge-level pruning statistics. Default is FALSE. |
pca.dim |
Maximum number of principal components to use if dimensionality reduction is applied (default: 100). Set to NULL to skip dimensionality reduction. |
variance.explained |
Percentage of variance to be explained by the principal components (default: 0.99). If this threshold can be met with fewer components than pca.dim, the smaller number will be used. Set to NULL to use exactly pca.dim components. |
knn.metric |
Character scalar specifying the geometry used for kNN search.
|
linf.tol |
Positive numeric tolerance used only when
|
connect.components |
Logical scalar. If TRUE, add MST bridge edges to
the final pruned graph so it is connected whenever possible. Currently
supported only with |
connect.method |
Character scalar. |
bridge.k |
Integer scalar or NULL. Initial ANN bridge neighborhood size
for |
bridge.k.max |
Integer scalar or NULL. Maximum ANN bridge neighborhood size before exact fallback. |
bridge.growth |
Numeric scalar greater than 1. Multiplicative growth factor for ANN bridge neighborhoods. |
with.lifecycle.branches |
Logical scalar. If TRUE, compute the
additional repaired lifecycle branches
|
verbose |
Logical. If TRUE, print progress messages. Default is TRUE. |
knn.cache.path |
Optional character scalar path to a binary kNN cache file.
Used only when |
knn.cache.mode |
Character cache mode:
|
adj_list and weight_list always contain the final graph used by downstream
algorithms. raw_* fields contain the native graph before pruning, and
pruned_* fields contain the graph after pruning but before optional MST
component repair. If pruning is disabled, pruned_* is identical to raw_*.
The repaired lifecycle branches allow direct comparison of raw, prune-first,
and repair-first graph geodesic distances from a single constructor call.
An object of class "IkNN" (inheriting from "list") containing:
Adjacency lists for the final graph after optional MST repair
Edge weights for the final graph
Adjacency lists for the native graph before pruning
Edge weights for the native graph before pruning
Adjacency lists after pruning and before MST repair
Edge weights after pruning and before MST repair
The native graph after MST component repair.
The prune-first branch after MST component repair.
The repair-first branch after applying the selected pruning method to the repaired raw graph.
Total number of edges in original graph
Number of edges after pruning
Number of edges removed by pruning
Proportion of edges removed
The matched function call
Number of nearest neighbors used
Number of data points
Number of features
If compute.full = TRUE, additional components include:
Intersection sizes for original edges
Connected components identification
Alternative format of connected components
# Create sample data
set.seed(123)
X <- matrix(rnorm(100), ncol = 2)
result <- create.single.iknn.graph(X, k = 3)
summary(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.