dgl.node_homophily๏
- dgl.node_homophily(graph, y)[source]๏
Homophily measure from Geom-GCN: Geometric Graph Convolutional Networks
We follow the practice of a later paper Large Scale Learning on Non-Homophilous Graphs: New Benchmarks and Strong Simple Methods to call it node homophily.
Mathematically it is defined as follows:
where
is the set of nodes, is the predecessors of node , and is the class of node .- Parameters:
- Returns:
The node homophily value.
- Return type:
Examples
>>> import dgl >>> import torch
>>> graph = dgl.graph(([1, 2, 0, 4], [0, 1, 2, 3])) >>> y = torch.tensor([0, 0, 0, 0, 1]) >>> dgl.node_homophily(graph, y) 0.6000000238418579