dis2connec_sparse
dis2connec_sparse.Rd
Convert Sparse Distance Matrix to Sparse Connectivity Matrix
Value
A sparse matrix of connectivities (class `dgCMatrix`) where weights represent local affinities.
Details
Transforms a sparse distance matrix into a Gaussian kernel-based connectivity matrix using a locally adaptive bandwidth. The resulting matrix can be interpreted as a similarity graph.
Examples
library(Matrix)
D <- rsparsematrix(100, 100, density = 0.05)
D <- 0.5 * (D + t(D)) # ensure symmetry
C <- dis2connec_sparse(D)
print(C[1:5, 1:5])
#> 5 x 5 sparse Matrix of class "dgCMatrix"
#> 1 2 3 4 5
#> 1 . 1.981971e-03 . . .
#> 2 0.001981971 1.374195e-23 . . .
#> 3 . . . . .
#> 4 . . . . .
#> 5 . . . . .