Homophily-Heterophily Graph Filter

The graph signal propagation filter is changed to improve node classification accuracy across homophilic and heterophilic graphs.

Structured & Causal ReasoningChebNetII
graph-signal-propagation

Description

Graph Signal Propagation: Spectral / Spatial Graph Filters

Research Question

Design a novel graph signal propagation filter for node feature aggregation in graph neural networks. The filter should effectively handle both homophilic graphs (where connected nodes share labels) and heterophilic graphs (where connected nodes often differ).

Background

GNNs propagate node features through graph structure using graph filters. The choice of filter is critical: simple low-pass filters such as GCN's first-order approximation work well on homophilic graphs but fail on heterophilic graphs, where useful information may live in higher-frequency components. Modern spectral methods learn polynomial filters in various bases:

  • Monomial basis (GPRGNN): h(A) = sum_k gamma_k A^k. Simple but can be numerically unstable. Chien, Peng, Li & Milenkovic, "Adaptive Universal Generalized PageRank Graph Neural Network," ICLR 2021 (arXiv:2006.07988).
  • Bernstein basis (BernNet): non-negative, excellent controllability, but O(K^2) complexity. He, Wei, Huang & Xu, "BernNet: Learning Arbitrary Graph Spectral Filters via Bernstein Approximation," NeurIPS 2021 (arXiv:2106.10994).
  • Chebyshev interpolation (ChebNetII): avoids the Runge phenomenon, O(K) complexity. He, Wei & Wen, "Convolutional Neural Networks on Graphs with Chebyshev Approximation, Revisited," NeurIPS 2022 (arXiv:2202.03580).
  • Jacobi polynomials (JacobiConv): orthogonal, fast convergence, generalizes Chebyshev / Legendre. Wang & Zhang, "How Powerful are Spectral Graph Neural Networks?", ICML 2022.

Key design axes include: polynomial basis choice, coefficient initialization and constraints, normalization (GCN vs Laplacian), and interaction with the MLP encoder.

Task

Modify the CustomProp (propagation layer) and CustomFilter (full model) classes in custom_filter.py. The propagation layer defines how node features are filtered across the graph; the model wraps it with an MLP encoder and output head.

class CustomProp(MessagePassing):
    def __init__(self, K, alpha=0.1, **kwargs):
        # K: polynomial order, alpha: teleport probability
        ...
    def forward(self, x, edge_index, edge_weight=None):
        # x: [num_nodes, channels], edge_index: [2, num_edges]
        # returns filtered features [num_nodes, channels]
        ...


class CustomFilter(nn.Module):
    def __init__(self, num_features, num_classes, hidden=64, K=10,
                 alpha=0.1, dropout=0.5, dprate=0.5):
        ...
    def forward(self, data):
        # data: PyG Data object with data.x, data.edge_index
        # returns log_softmax predictions [num_nodes, num_classes]
        ...

Available utilities:

  • gcn_norm(edge_index) -- GCN normalization D^{-1/2} A D^{-1/2}.
  • get_laplacian(edge_index, normalization='sym') -- symmetric normalized Laplacian L = I - D^{-1/2} A D^{-1/2}.
  • add_self_loops(edge_index, edge_weight, fill_value) -- add self loops.
  • self.propagate(edge_index, x=x, norm=norm) -- single-step message passing.
  • cheby(i, x) -- evaluate the Chebyshev polynomial T_i(x).
  • comb(n, k) -- binomial coefficient (from scipy).
  • Constants: K, ALPHA, HIDDEN, DROPOUT, DPRATE.

Evaluation

Datasets (a mix of homophilic and heterophilic graphs):

LabelNodesClassesTypeSource
cora2,7087homophiliccitation network
citeseer3,3276homophiliccitation network
texas1835heterophilicWebKB webpage network
cornell1835heterophilicWebKB webpage network

Fixed pipeline: each dataset runs 10 random 60/20/20 train/val/test splits with early stopping.

Metric: mean test accuracy over the 10 runs, higher-is-better.

The contribution should remain a modular graph filter paired with the fixed classification pipeline, rather than changing the data split or evaluation target.

Code

custom_filter.py
EditableRead-only
1# Custom graph signal propagation filter for MLS-Bench
2#
3# EDITABLE section: CustomProp (propagation layer) + CustomFilter (full model).
4# FIXED sections: everything else (config, data loading, training loop, evaluation).
5
6import os
7import math
8import random
9import time
10from typing import Optional
11
12import numpy as np
13import torch
14import torch.nn as nn
15import torch.nn.functional as F

Method Summary

Auto-summarized from each method's code by an LLM reviewer — not the model's original output. Browse via the picker below; the Code section is independent.
Baselines
Agents
Claude Opus 4.6·Formulahigh

Dual-Path Polynomial + Residual Gate

Two GPRGNN-style monomial filters (uniform-init + PPR-init) mixed by a learnable scalar, with a sigmoid residual gate to the unfiltered features.

h1(A^)=k=0Kθk(1)A^k,h2(A^)=k=0Kθk(2)A^k,A^=D1/2AD1/2,h_1(\hat A) = \sum_{k=0}^{K}\theta^{(1)}_k \hat A^k,\quad h_2(\hat A) = \sum_{k=0}^{K}\theta^{(2)}_k \hat A^k,\quad \hat A = D^{-1/2}AD^{-1/2},
y=(1σ(g))[σ(w)h1(A^)x+(1σ(w))h2(A^)x]+σ(g)x,y = (1-\sigma(g))\,\big[\sigma(w)\,h_1(\hat A)x + (1-\sigma(w))\,h_2(\hat A)x\big] + \sigma(g)\,x,
with $\theta^{(1)}_k = 1/(K+1)$ (uniform), $\theta^{(2)}_k = \alpha(1-\alpha)^k$ (PPR).
Δ vs. baselineVersus GPRGNN, runs two independent monomial filters in parallel (uniform-init and PPR-init), convex-combines them with one learnable scalar, and adds a sigmoid skip-connection that pulls the output back toward x.
KK=10alpha=0.1theta^(1)_k=1/(K+1) (init)learnabletheta^(2)_k=PPR (init)learnablemix_weight w=0.5 (init)learnableres_gate g=0.0 (init)learnablelr / prop_lr / wd / prop_wd=0.05 / 0.05 / 5e-4 / 0.0Recovers GPRGNN-uniform when σ(w)→1 and σ(g)→0

Results