dgl.double_radius_node_labelingο
- dgl.double_radius_node_labeling(g, src, dst)[source]ο
Double Radius Node Labeling, as introduced in Link Prediction Based on Graph Neural Networks.
This function computes the double radius node labeling for each node to mark nodesβ different roles in an enclosing subgraph, given a target link.
The node labels of source
and destination are set to 1 and those of unreachable nodes from source or destination are set to 0. The labels of other nodes are defined according to the following hash function:where
and denote the shortest distance to the source and the target, respectively. .- Parameters:
- Returns:
Labels of all nodes. The tensor is of shape
, where is the number of nodes in the input graph.- Return type:
Tensor
Example
>>> import dgl
>>> g = dgl.graph(([0,0,0,0,1,1,2,4], [1,2,3,6,3,4,4,5])) >>> dgl.double_radius_node_labeling(g, 0, 1) tensor([1, 1, 3, 2, 3, 7, 0])