knn_graph() converts a data matrix, a fastEmbedR_embedding, or a
precomputed KNN object into a native undirected edge graph. When neighbors
must be computed, the function uses fastEmbedR's existing native KNN route;
it does not expose a second nearest-neighbor tuning API.
Arguments
- x
Numeric data matrix, a
fastEmbedR_embedding, a list containingindicesanddistances, or an existingfastEmbedR_graph.- k
Number of non-self neighbors retained.
- backend
KNN-search backend used only when
xis data:"cpu","cuda", or"metal".- metric
Distance metric used only when KNN must be computed:
"euclidean","cosine", or"correlation".- weight
Edge weighting: shared-neighbor Jaccard (
"snn"), inverse distance ("distance"), or unit weights ("binary").- mutual
Keep only reciprocal KNN edges.
- prune
Remove edges whose final weight is less than or equal to this non-negative threshold.
- n.cores
CPU cores used by KNN search and graph construction.