Hierarchical Shortest-Path Graph Kernel Network

Jiaxin Wang, Wenxuan Tu, Jieren ChengNeurIPS 2025

Graph machine learning has traditionally been divided into two dominant paradigms: structurally-rich but rigid Graph Kernels, and flexible but structurally-limited Graph Neural Networks (GNNs). A recent paper introduces the Hierarchical Shortest-Path Graph Kernel Network (HSP-GKN), a novel framework that bridges this gap by making graph kernels "learnable" within an end-to-end neural network.

The Problem: Fixed Kernels vs. Limited GNNs

In graph machine learning, capturing the underlying topology of a network is crucial.

  1. Graph Kernels excel at capturing complex structural patterns (like shortest paths or subgraphs) through handcrafted similarity functions. However, they are typically "fixed"—they cannot be trained to prioritize specific patterns for a given task. Furthermore, expressive kernels like the Shortest-Path (SP) kernel are computationally expensive, often scaling at $O(n^4)$.
  2. Graph Neural Networks (GNNs) are highly flexible and learnable. Yet, most rely on "message passing" mechanisms. Theoretical research has shown that standard message-passing GNNs are bounded by the 1-Weisfeiler-Lehman (1-WL) test, meaning they struggle to distinguish certain complex, non-local graph structures.

The authors of HSP-GKN aim to combine the structural expressiveness of shortest-path kernels with the end-to-end optimization capabilities of deep neural networks, all while maintaining computational efficiency.

Proposed Methodology

HSP-GKN introduces two major innovations to achieve a learnable, efficient graph kernel framework:

1. The Hierarchical Shortest-Path (HSP) Kernel

Traditional shortest-path kernels compare every path in Graph A to every path in Graph B, leading to massive computational overhead. The proposed HSP kernel simplifies this by:

  • Grouping by Length: It groups all shortest paths of the same length $l$ together.
  • Cohesive Mapping: It aggregates node attributes along these paths into a single "cohesive" feature vector for each length.
  • Explicit Mapping: Instead of relying on an implicit kernel trick, it maps the graph into a vector space where similarity is computed via a simple inner product. This reduces the computational complexity from $O(n^4)$ to $O(n^2 \log n)$.

2. Learnable "Hidden" Graph Features

This is the core of the "Network" aspect of HSP-GKN. Instead of merely comparing two input graphs, the model compares an input graph against a set of trainable parameters acting as "hidden graph features."

HSP-GKN Architecture

Think of these hidden features as "structural prototypes" that the network learns over time. The model calculates a similarity vector between the input graph and these prototypes. This similarity vector serves as the graph embedding, which is then fed into a Multi-Layer Perceptron (MLP) for final classification. Because the entire pipeline is differentiable, these prototypes are updated during training to focus on the topological structures most relevant to the specific task.

Key Insights

  • Breaking the 1-WL Ceiling: By utilizing shortest paths rather than just immediate neighborhood aggregation (message passing), HSP-GKN captures global topological information that standard GNNs frequently miss.
  • Task-Specific Kernels: Traditional kernels are "blind" to downstream labels. By making the kernel features learnable, HSP-GKN can adaptively learn that certain path lengths (e.g., 3-step paths) are more predictive for a specific task (like toxicity prediction) than others.
  • Efficiency via Matrix Operations: The hierarchical mapping can be computed using highly optimized matrix multiplications ($X^\top M_l$), making it significantly faster than previous path-based kernels on modern hardware.

Experimental Results

The model was rigorously evaluated on 12 datasets from the TUDataset collection, spanning small molecules (e.g., MUTAG, NCI1), bioinformatics (e.g., PROTEINS), and social networks (e.g., COLLAB, REDDIT).

Experimental Results Table
  • State-of-the-Art Accuracy: HSP-GKN achieved the highest accuracy on 9 out of 12 datasets. Notably, on the MUTAG and PTC_MR datasets, it improved absolute accuracy by 6.0% and 7.5%, respectively, over the next best competitor.
  • Significant Speedups: Compared to traditional kernels like the GraphHopper (GH) kernel, HSP is orders of magnitude faster. On the NCI1 dataset, for instance, GH took nearly 3,000 seconds to compute, whereas HSP required only 12.7 seconds.
  • Efficiency vs. GNNs: While GNNs are generally fast, HSP-GKN's per-epoch training time was often lower (e.g., 0.011s on REDDIT-M-5K vs. 5.193s for GIN) because the graph is pre-processed into a compact vector before entering the neural network.

Limitations and Future Work

While highly effective, the current HSP-GKN framework has a few limitations. Currently, the HSP kernel focuses on node attributes and graph topology but ignores edge attributes (such as bond types in molecular graphs). Concatenating edge attributes into the path features is a logical next step. Additionally, while training is fast, the initial shortest-path calculation (via Dijkstra’s algorithm) is a required preprocessing step that can be time-consuming for extremely large, dense graphs. Future work will also explore extending this framework beyond graph classification to graph regression and other complex graph-level tasks.

Summary updated

BibTeX
@inproceedings{wang2025hierarchical,
  author = {Jiaxin Wang and Wenxuan Tu and Jieren Cheng},
  title = {{Hierarchical Shortest-Path Graph Kernel Network}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=721bDIvjen},
}
Figure