SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.14274 · NeurIPS · 2023

When Do Graph Neural Networks Help with Node Classification? Investigating the Impact of Homophily Principle on Node Distinguishability

Jure Leskovec, Doina Precup, Minkai Xu, Jie Fu, Sitao Luan, Chenqing Hua, Xiao-Wen Chang, Qincheng Lu, Jiaqi Zhu

arXiv · PDF · Open in the Atlas

Code that ran

8 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 1 violated it and 3 have no contract verdict; 3 failures of our instrument; 2 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2304.14274.json · badge: /api/ran/2304.14274.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
SitaoLuan/When-Do-GNNs-Help canonical (classifier label)
classifier basis: census
4 ran · 2 no recorded run
sitaoluan/when-do-gnns-help canonical (classifier label)
classifier basis: classifier_2025
4 ran · 0 no recorded run
FunctionStatusWhere it lives
Negative_Wasserstein Ran
ran, violated the contract we drafted
sitaoluan/when-do-gnns-help/csbm-h.py
code served (permissive licence) · get_code("649c31cd268c2c76")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Set random seed for reproducibility
np.random.seed(0)

# Define dimensions
dim = 4
n0 = 2
n1 = 3
d0 = 5
d1 = 6

# Create arguments
mu0 = np.random.randn(dim)
mu1 = np.random.randn(dim)
sigma0 = np.abs(np.random.randn(dim)) + 0.1  # Ensure positive for sqrt
sigma1 = np.abs(np.random.randn(dim)) + 0.1  # Ensure positive for sqrt
h = 0.5

ARGS = {
    "n0": n0,
    "n1": n1,
    "mu0": mu0,
    "mu1": mu1,
    "sigma0": sigma0,
    "sigma1": sigma1,
    "d0": d0,
    "d1": d1,
    "h": h,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
edge_homophily Ran
ran; our contract draft was wrong, not the code
sitaoluan/when-do-gnns-help/utils/homophily_metrics.py
code served (permissive licence) · get_code("efb38a666950076c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create a small sparse adjacency matrix A
# The function calls A.coalesce().indices() to get edge indices
# We need a 2D sparse tensor with shape (num_nodes, num_nodes)
num_nodes = 5
indices = torch.tensor([[0, 1, 2, 3], [1, 2, 3, 4]], dtype=torch.long)
values = torch.ones(4)
A = torch.sparse_coo_tensor(indices, values, (num_nodes, num_nodes))

# Create labels tensor
# The function indexes into labels with src_node and targ_node indices
# Labels should have length >= num_nodes
# We'll use some class labels (0, 1, 2) and one negative label (-1) for testing
labels = torch.tensor([0, 0, 1, 1, 2], dtype=torch.long)

ARGS = {
    "A": A,
    "labels": labels,
    "ignore_negative": False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
edge_homophily Ran
ran on a synthesized input
SitaoLuan/When-Do-GNNs-Help/utils/homophily_plot.py
code served (permissive licence) · get_code("b899267fb2690ba4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small adjacency matrix (4x4)
# This represents edges between 4 nodes
adj = torch.tensor([
    [0.0, 1.0, 1.0, 0.0],
    [1.0, 0.0, 0.0, 1.0],
    [1.0, 0.0, 0.0, 1.0],
    [0.0, 1.0, 1.0, 0.0]
])

# Create label matrix (4x3)
# One-hot encoded labels for 4 nodes, 3 classes
label = torch.tensor([
    [1.0, 0.0, 0.0],
    [1.0, 0.0, 0.0],
    [0.0, 1.0, 0.0],
    [0.0, 1.0, 0.0]
])

ARGS = {
    "adj": adj,
    "label": label
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
node_homophily Ran
ran; our contract draft was wrong, not the code
sitaoluan/when-do-gnns-help/utils/homophily_metrics.py
code served (permissive licence) · get_code("dd69d9df00c63031")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# Create a small sparse adjacency matrix A
# A should be a sparse tensor with shape (num_nodes, num_nodes)
num_nodes = 4
# Create edge indices for a simple graph
edge_indices = torch.tensor([
    [0, 1, 1, 2, 2, 3],  # source nodes
    [1, 0, 2, 1, 3, 2]   # target nodes
], dtype=torch.long)

# Create a sparse tensor (COO format)
edge_values = torch.ones(edge_indices.shape[1])
A = torch.sparse_coo_tensor(edge_indices, edge_values, (num_nodes, num_nodes))

# Create labels for nodes
labels = [0, 0, 1, 1]

ARGS = {
    "A": A,
    "labels": labels
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
normalize Ran
ran; our contract draft was wrong, not the code
SitaoLuan/When-Do-GNNs-Help/utils/util_funcs.py
code served (permissive licence) · get_code("7864a49a3e2da4fd")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned csr_matrix. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import scipy.sparse as sp

# Create a small sparse matrix for testing
# Using a 4x3 sparse matrix with some non-zero values
data = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
row = np.array([0, 1, 2, 3, 1])
col = np.array([0, 1, 2, 0, 2])
mx = sp.csr_matrix((data, (row, col)), shape=(4, 3))

ARGS = {
    "mx": mx
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type csr_matrix — a csr_matrix output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a csr_matrix output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
preprocess_features Ran
ran on a synthesized input
SitaoLuan/When-Do-GNNs-Help/utils/util_funcs.py
code served (permissive licence) · get_code("658057a59a7acc1a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned csr_matrix. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import scipy.sparse as sp

# Create a small sparse feature matrix
# Shape: 4 samples x 3 features
# Using a sparse matrix format since the function expects sparse matrix operations
data = np.array([1.0, 2.0, 3.0, 1.0, 4.0, 2.0])
row = np.array([0, 0, 1, 2, 2, 3])
col = np.array([0, 1, 2, 0, 1, 2])
features = sp.csr_matrix((data, (row, col)), shape=(4, 3))

ARGS = {
    "features": features
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type csr_matrix — a csr_matrix output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a csr_matrix output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
remove_self_loops Ran
ran, honoured the contract we drafted
sitaoluan/when-do-gnns-help/utils/homophily_metrics.py
code served (permissive licence) · get_code("ef90ba6dacfae5eb")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create edge_index with some self-loops and some regular edges
# Shape: (2, num_edges)
# Edges: (0,0), (0,1), (1,1), (1,2), (2,0)
# Self-loops are at indices 0 and 2
edge_index = torch.tensor([
    [0, 0, 1, 1, 2],
    [0, 1, 1, 2, 0]
], dtype=torch.long)

# Create edge_attr with features for each edge
# Shape: (num_edges, feature_dim)
edge_attr = torch.tensor([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0],
    [9.0, 10.0, 11.0, 12.0],
    [13.0, 14.0, 15.0, 16.0],
    [17.0, 18.0, 19.0, 20.0]
], dtype=torch.float)

ARGS = {
    "edge_index": edge_index,
    "edge_attr": edge_attr
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
remove_self_loops Ran
ran on a synthesized input
SitaoLuan/When-Do-GNNs-Help/utils/homophily_plot.py
code served (permissive licence) · get_code("cbeb665d00a9d64a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create edge_index: a 2xN LongTensor representing edges
# Include some self-loops (where row == col) that should be removed
edge_index = torch.tensor([
    [0, 1, 2, 2, 3],  # source nodes
    [1, 2, 2, 3, 3]   # target nodes
], dtype=torch.long)

# Create edge_attr: edge features/weights
# Shape: (5, 4) - 5 edges, 4 feature dimensions
edge_attr = torch.randn(5, 4)

ARGS = {
    "edge_index": edge_index,
    "edge_attr": edge_attr
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_data Not yet run
unverified (harvested, no recorded run)
SitaoLuan/When-Do-GNNs-Help/utils/util_funcs.py
code served (permissive licence) · get_code("fceebdd88c1663c9")
How it ran

no invocation recorded.

load_fb100_dataset Not yet run
unverified (harvested, no recorded run)
SitaoLuan/When-Do-GNNs-Help/utils/datasets.py
code served (permissive licence) · get_code("c2e2b91095918676")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 3 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 3 later) and 7 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
node_homophily 1 other paper
1 later
2406.18854 (2024-06)
What Is Missing In Homophily? Disentangling Graph Homophily For Graph Neural Networks
normalize 1 other paper
1 later
2406.18854 (2024-06)
What Is Missing In Homophily? Disentangling Graph Homophily For Graph Neural Networks
remove_self_loops 1 other paper
1 later
2406.18854 (2024-06)
What Is Missing In Homophily? Disentangling Graph Homophily For Graph Neural Networks

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Homophily principle, i.e., nodes with the same labels are more likely to be connected, has been believed to be the main reason for the performance superiority of Graph Neural Networks (GNNs) over Neural Networks on node classification tasks. Recent research suggests that, even in the absence of homophily, the advantage of GNNs still exists as long as nodes from the same class share similar neighborhood patterns [38]. However, this argument only considers intra-class Node Distinguishability (ND) but neglects inter-class ND, which provides incomplete understanding of homophily on GNNs. In this paper, we first demonstrate such deficiency with examples and argue that an ideal situation for ND is to have smaller intra-class ND than inter-class ND. To formulate this idea and study ND deeply, we propose Contextual Stochastic Block Model for Homophily (CSBM-H) and define two metrics, Probabilistic Bayes Error (PBE) and negative generalized Jeffreys divergence, to quantify ND. With the metrics, we visualize and analyze how graph filters, node degree distributions and class variances influence ND, and investigate the combined effect of intra-and inter-class ND. Besides, we discovered the mid-homophily pitfall, which occurs widely in graph datasets. Furthermore, we verified that, in real-work tasks, the superiority of GNNs is indeed closely related to both intraand inter-class ND regardless of homophily levels. Grounded in this observation, we propose a new hypothesis-testing based performance metric beyond homophily, which is non-linear, feature-based and can provide statistical threshold value for GNNs' the superiority. Experiments indicate that it is significantly more effective than the existing homophily metrics on revealing the advantage and disadvantage of graph-aware modes on both synthetic and benchmark real-world datasets. 37th Conference on Neural Information Processing Systems (NeurIPS 2023).

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2304.14274")
get_code_for_paper("2304.14274")
have("2304.14274")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2304.14274.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2304.14274.svg)](https://syntology.ai/paper/2304.14274)

Connect an agent — have() is free.