Papers
Topics
Authors
Recent
Search
2000 character limit reached

Weisfeiler-Lehman Subtree Kernel Overview

Updated 23 February 2026
  • Weisfeiler-Lehman subtree kernel is a graph similarity measure that counts matching subtree patterns generated by iterative neighborhood relabeling.
  • It constructs a feature map by aggregating counts of rooted subtree patterns across multiple iterations and computes similarity via an inner product.
  • Extensions, including weighted and soft variants, enhance its expressiveness and interpretability, achieving state-of-the-art performance across domains.

The Weisfeiler-Lehman (WL) subtree kernel is a graph similarity measure grounded in the iterative neighborhood aggregation procedure of the WL isomorphism test. This kernel assesses the similarity of graphs by counting matching subtree patterns, generated via repeated relabeling (color refinement) of vertices based on their neighbors’ labels. Expressly efficient and applicable to diverse domains—including molecules, social networks, and point-cloud structures—the WL subtree kernel achieves state-of-the-art accuracy in graph classification while maintaining computational tractability. Numerous extensions, such as parametric weighting of subtree patterns and relaxations to soft subtree similarity, have been introduced to augment its expressiveness and interpretability.

1. Weisfeiler-Lehman Relabeling and Subtree Pattern Extraction

Given a graph G=(V,E)G = (V, E) with initial node labels ℓ0(v)\ell_0(v), the WL labeling scheme iteratively refines node labels over HH rounds. At each iteration hh, for each node vv, the multiset of labels Mh(v)={ℓh(u):u∈N(v)}M_h(v) = \{ \ell_h(u) : u \in N(v) \} (with N(v)N(v) the neighbors of vv) is collected, sorted, and concatenated with ℓh(v)\ell_h(v) to form a string sh(v)=(ℓh(v),Mh(v))s_h(v)=(\ell_h(v), M_h(v)). A perfect hash compresses ℓ0(v)\ell_0(v)0 into a new integer label ℓ0(v)\ell_0(v)1.

After â„“0(v)\ell_0(v)2 rounds, each node possesses a sequence of labels â„“0(v)\ell_0(v)3, each encoding the subtree structure rooted at â„“0(v)\ell_0(v)4 up to depth â„“0(v)\ell_0(v)5 through signature-style label propagation. Each WL label at iteration â„“0(v)\ell_0(v)6 bijectively encodes an isomorphism class of rooted subtrees of height â„“0(v)\ell_0(v)7, mirroring the distinguishing power of the 1-dimensional WL test and its connection to rooted tree unfolding (Kriege, 2022, Nguyen et al., 2021).

2. Feature Map Construction and Kernel Definition

For each round â„“0(v)\ell_0(v)8, define â„“0(v)\ell_0(v)9 as the set of distinct node labels at iteration HH0. The rooted subtree feature map is

HH1

The full graph feature vector HH2 is the concatenation HH3, such that each coordinate counts the occurrences of a specific subtree pattern.

The WL subtree kernel of height HH4 is the sum of inner products across all rounds:

HH5

where the dot product quantifies the shared occurrence of each rooted subtree pattern in HH6 and HH7. This formulation ensures the kernel is positive-semidefinite and histograms the multi-scale topology of the graph neighborhood structure (Nguyen et al., 2021, Ting et al., 2023, Kriege, 2022).

3. Computational Complexity and Implementation

Each WL refinement iteration requires HH8 time for sorting (with HH9), or hh0 if radix sort is used. Label counting per iteration is hh1. For hh2 graphs, computing all kernel matrix entries is hh3, where hh4 is the typical number of distinct subtree patterns per feature map. Space complexity is hh5 per graph. Notable implementation optimizations include sparse storage of histograms and subsampling, where relabeling only a fraction of nodes per iteration can substantially accelerate computation with minimal accuracy loss (Ting et al., 2023).

4. Extensions: Weighted and Soft Subtree Kernels

Weighted WWL Kernel

Standard WL subtree kernels treat every subtree pattern as equally important. This is suboptimal in domains such as molecular classification, where certain substructures (e.g., nitro groups, aromatic rings) are highly predictive. The WWL kernel (Weisfeiler-Lehman–Wasserstein) introduces nonnegative weights hh6 for each pattern hh7 and defines a weighted distance:

hh8

where hh9 aggregates vv0 across all heights vv1 and vv2. The weights vv3 are optimized, subject to convex constraints, through a projected stochastic gradient algorithm on a pairwise hinge-style loss. This approach enables supervised learning of structural relevance while preserving kernel validity and scalability via sparse computation. The learned weights focus the kernel on informative graph substructures, improving both prediction and interpretability, as validated on synthetic and large-scale molecular datasets (Nguyen et al., 2021).

Soft/Relaxed WL Kernels

The original WL kernel uses a hard combinatorial test—subtree patterns only contribute if they are isomorphic. For dense or highly diverse graphs, this restrictiveness leads to sparse feature overlaps and reduced discriminative power. The relaxed WL kernel (Schulz et al., 2021) generalizes by applying a structure-and-depth-preserving tree edit distance (SdTed) to unfolding trees before constructing feature buckets via Wasserstein k-means. This enables clustering of similar but non-identical local neighborhoods, thus capturing graded notions of subtree similarity. Empirical results show that these relaxed variants yield improved performance on structurally complex, dense datasets.

5. Expressiveness and Relations to Other Kernels

The expressivity of the WL subtree kernel is formally equivalent to counting rooted subtrees up to height vv4. This matches the distinguishing power of the 1-WL test. The kernel can also be interpreted as a special case of walk-based kernels, with iterated relabeling serving as non-linear aggregation of walk counts. By tuning parameters in generalized walk kernels, one can interpolate between (a) strict matching (WL), (b) soft matching (relaxed WL), and (c) full walk-count similarity, spanning the spectrum from powers of adjacency matrices (random walk kernels) to structure-aware subtree aggregation (Kriege, 2022). The softness of label comparison and subtree weighting are independent axes of enhancement.

6. Empirical Performance and Application Domains

The WL subtree kernel and its extensions have demonstrated strong performance across molecular, biological, social network, and even point-cloud domains. For molecular graphs, learning subtree weights leads to statistically significant accuracy gains over non-weighted WWL and baseline kernels. Notably, the weighted WWL achieves 88.37% on MUTAG, 65.44% on PTC-MR, 75.73% on PROTEIN, and 86.45% on NCI1, each outperforming WWL by 0.5–1.5 points or more (Nguyen et al., 2021).

In chemical tagging, the WL kernel, coupled with Gaussian Process regression, achieves robust identification of cluster-mass-function parameters with training data reduced by two orders of magnitude compared to GNNs. The kernel also offers clear interpretability of features, which is advantageous in scientific applications (Ting et al., 2023).

7. Limitations and Future Directions

Although computationally efficient and empirically robust, classic WL subtree kernels do not natively handle continuous attributes or soft structural similarity. The strict isomorphism-based pattern comparison yields sparse feature overlaps for dense graphs, as nearly every local neighborhood is unique (Schulz et al., 2021). Weighted and tree-edit-based relaxations address some of these issues and offer promising avenues for further research. Future extensions target efficient handling of attributes, hybridizations with differentiable graph neural architectures, and further advances in interpretable graph learning.


Key References:

  • "Learning subtree pattern importance for Weisfeiler-Lehmanbased graph kernels" (Nguyen et al., 2021)
  • "Weisfeiler-Lehman Graph Kernel Method: A New Approach to Weak Chemical Tagging" (Ting et al., 2023)
  • "Weisfeiler and Leman Go Walking: Random Walk Kernels Revisited" (Kriege, 2022)
  • "A Generalized Weisfeiler-Lehman Graph Kernel" (Schulz et al., 2021)

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Weisfeiler-Lehman Subtree Kernel.