dgl.laplacian_pe¶
-
dgl.
laplacian_pe
(g, k)[source]¶ Laplacian Positional Encoding, as introduced in Benchmarking Graph Neural Networks
This function computes the laplacian positional encodings as the k smallest non-trivial eigenvectors (k << n). k and n are the positional encoding dimensions and the number of nodes in the given graph.
- Parameters
- Returns
The laplacian positional encodings of shape \((N, k)\), where \(N\) is the number of nodes in the input graph.
- Return type
Tensor
Example
>>> import dgl >>> g = dgl.rand_graph(6, 12) >>> dgl.laplacian_pe(g, 2) tensor([[-0.8931, -0.7713], [-0.0000, 0.6198], [ 0.2704, -0.0138], [-0.0000, 0.0554], [ 0.3595, -0.0477], [-0.0000, 0.1240]])