Homophily is the tendency for connected nodes in a graph to share the same label or have similar features, and it is the implicit assumption underlying most standard GNN architectures. When homophily holds, neighbor aggregation acts as a denoising operation: averaging similar neighbors reinforces the true signal. When homophily breaks (heterophily), the same aggregation mixes conflicting signals and degrades prediction accuracy. Understanding the homophily level of your graph is essential for choosing the right GNN architecture.
Why it matters for enterprise data
Enterprise relational databases exhibit varying levels of homophily depending on the relationship type:
- High homophily: Fraud detection graphs where fraudulent accounts cluster together, connected through shared devices, IPs, or beneficiaries. A fraudster's neighbors are often other fraudsters.
- Moderate homophily: Customer segments in retail where similar customers buy from similar product categories. Some cross-segment edges exist but within-segment edges dominate.
- Low homophily: Customer-product bipartite graphs where a single customer buys products from diverse categories. The customer's product neighbors may have very different properties.
Choosing a GNN architecture without understanding your graph's homophily level is like choosing a regression model without looking at the data distribution.
How to measure homophily
from torch_geometric.utils import homophily
# Edge homophily: fraction of edges connecting same-label nodes
h_edge = homophily(data.edge_index, data.y, method='edge')
print(f"Edge homophily: {h_edge:.3f}")
# Node homophily: average fraction of same-label neighbors per node
h_node = homophily(data.edge_index, data.y, method='node')
print(f"Node homophily: {h_node:.3f}")
# Interpretation:
# h > 0.7: strongly homophilous (GCNConv will work well)
# 0.5 < h < 0.7: moderate (GATConv or SAGE recommended)
# h < 0.5: heterophilous (need specialized architecture)Always measure homophily before choosing your GNN architecture. PyG provides built-in functions for both edge and node homophily.
Concrete example: churn prediction in a telecom graph
Consider a telecom network where customers are connected by call frequency:
- Nodes: 100,000 customers with features [tenure, plan_type, monthly_charge, support_calls]
- Edges: top 10 most-called contacts per customer
- Labels: churned (1) vs. retained (0)
Measured edge homophily: 0.73. This is strongly homophilous because churn is socially contagious. When a customer churns, their frequent contacts are more likely to churn too (network effect). A GCNConv layer averaging these neighbors will naturally pick up the “my contacts are churning” signal.
How homophily affects GNN architecture choice
- GCNConv under high homophily: Degree-normalized mean aggregation works as intended. Averaging same-label neighbors reinforces the correct signal. On Cora (h=0.81), GCN achieves ~81.5% accuracy.
- GATConv under moderate homophily: Attention learns to upweight same-label neighbors and downweight different-label ones. This selective aggregation preserves signal even when some neighbors have different labels.
- GCNConv under heterophily: Averaging different-label neighbors mixes conflicting signals. The node's own signal gets diluted. Performance can drop below a simple MLP that ignores graph structure entirely.
Limitations and what comes next
- Homophily is global, not local: A graph can be globally homophilous (h=0.75) while having local pockets of heterophily. Per-node homophily metrics capture this better but are harder to use for architecture selection.
- Homophily is label-dependent: The same graph might be homophilous for one prediction target and heterophilous for another. Churn labels might cluster, but spending-level labels might not.
- Real graphs are not purely one or the other: Enterprise graphs often have mixed homophily levels across different edge types (customer-customer edges may be homophilous while customer-product edges are heterophilous).
Heterophily-aware architectures and graph transformers handle both regimes by learning whether to smooth or differentiate for each edge, adapting to local homophily patterns.