Berlin Tech Meetup: The Future of Relational Foundation Models, Systems, and Real-World Applications

Register now:
PyG/Guide7 min read

Homophily: When Connected Nodes Share the Same Label

Homophily is the assumption baked into most GNN architectures: that neighbors are similar. When this assumption holds, GNNs excel. When it breaks, performance degrades sharply.

PyTorch Geometric

TL;DR

  • 1Homophily means connected nodes tend to share labels or features. Edge homophily ratio = fraction of same-label edges. Cora has h=0.81, meaning 81% of edges connect same-class nodes.
  • 2Standard GNN layers (GCNConv, GATConv) implicitly assume homophily. Neighbor aggregation averages features, reinforcing correct signals when neighbors share the target label.
  • 3Enterprise relational data has mixed homophily. Customer similarity graphs are often homophilous. Customer-product bipartite graphs can be heterophilous. Measure homophily before choosing your architecture.
  • 4High homophily (h > 0.7): GCNConv works well. Moderate (0.5-0.7): GATConv's attention helps. Low (< 0.5): use heterophily-aware architectures or graph transformers.
  • 5Homophily is not static. In temporal enterprise graphs, homophily can change over time as customer behavior evolves, requiring models that adapt to shifting graph properties.

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

measure_homophily.py
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

  1. 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.
  2. 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.
  3. 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.

Frequently asked questions

What is homophily in graphs?

Homophily is the property where connected nodes tend to share the same label or have similar features. In a citation network, papers cite papers in the same field. In a social network, friends tend to share demographics. The homophily ratio (fraction of edges connecting same-label nodes) ranges from 0 to 1. Values above 0.5 indicate homophily. Most standard GNN benchmarks (Cora, CiteSeer, PubMed) have high homophily (0.8+).

Why does homophily matter for GNN performance?

Standard GNN layers like GCNConv and GATConv aggregate neighbor features, effectively averaging them with the node's own features. Under homophily, neighbors have similar labels and features, so aggregation reinforces the correct signal. Under heterophily, neighbors have different labels, and aggregation mixes conflicting signals, degrading performance. Most GNN architectures were designed and tested on homophilous graphs.

How do you measure homophily?

The most common metric is edge homophily: the fraction of edges that connect nodes with the same label. h = (same-label edges) / (total edges). Cora has h=0.81, meaning 81% of citation edges connect same-field papers. Values above 0.5 are homophilous, below 0.5 are heterophilous. Node homophily (average per-node same-label neighbor fraction) is an alternative metric less sensitive to class imbalance.

Is enterprise relational data homophilous or heterophilous?

It depends on the specific relationship. Customer-to-customer similarity graphs tend to be homophilous (similar customers connect). Customer-to-product bipartite graphs can be heterophilous (a customer buying diverse products). Transaction graphs where fraud tends to cluster show homophily for fraud labels. Understanding the homophily level of your specific graph helps you choose the right GNN architecture.

Which GNN layers work well under homophily?

GCNConv, GATConv, and SAGEConv all perform well on homophilous graphs because their neighbor aggregation reinforces same-label signals. GCNConv is often the best choice for strongly homophilous graphs (h > 0.7) because its simple averaging works when neighbors are informative. For moderate homophily (0.5-0.7), GATConv's attention can help by weighting more similar neighbors higher.

Learn more about graph ML

PyTorch Geometric is the open-source foundation for graph neural networks. Explore more layers, concepts, and production patterns.