dgl.edge_homophily
- dgl.edge_homophily(graph, y)[source]
Homophily measure from Beyond Homophily in Graph Neural Networks: Current Limitations and Effective Designs
Mathematically it is defined as follows:
where
is the set of edges, and is the class of node .- Parameters:
- Returns:
The edge homophily ratio 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.edge_homophily(graph, y) 0.75