dgl.random_walk_peΒΆ
-
dgl.
random_walk_pe
(g, k, eweight_name=None)[source]ΒΆ Random Walk Positional Encoding, as introduced in Graph Neural Networks with Learnable Structural and Positional Representations
This function computes the random walk positional encodings as landing probabilities from 1-step to k-step, starting from each node to itself.
- Parameters
- Returns
The random walk 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.graph(([0,1,1], [1,1,0])) >>> dgl.random_walk_pe(g, 2) tensor([[0.0000, 0.5000], [0.5000, 0.7500]])