The smallest non-trivial eigenvectors of the Laplacian: on a path
graph these are sinusoids, so the NLP positional encoding is the
special case.
Usage
morie_gtrf_lap_pe(adj, n, dim = 2L, normalized = TRUE)
Arguments
- adj
Adjacency list.
- n
Number of nodes.
- dim
Encoding dimension (number of eigenvectors).
- normalized
Use the symmetric normalised Laplacian.
Value
A list with encoding (n x dim), eigenvalues
and the sign caveat.
References
Dwivedi, V. P. and Bresson, X. (2020).
Examples
adj <- list(`0` = 1L, `1` = c(0L, 2L), `2` = c(1L, 3L), `3` = 2L) # path graph, 0-based
round(morie_gtrf_lap_pe(adj, n = 4, dim = 2L)$encoding, 3)
#> [,1] [,2]
#> [1,] -0.577 0.577
#> [2,] -0.408 -0.408
#> [3,] 0.408 -0.408
#> [4,] 0.577 0.577