Abstract
The Weisfeiler-Lehman (WL) subtree kernel is a cornerstone of graph-based machine learning, prized for its efficiency and discriminative power. However, its reliance on exact neighborhood isomorphism makes it brittle, particularly in dense or structurally complex graphs where minor variations lead to a "label explosion." We present the Relaxed Weisfeiler-Lehman (R-WL) graph kernel, which generalizes the WL framework by replacing rigid isomorphism tests with a flexible similarity measure. By leveraging a specialized tree edit distance and Wasserstein clustering, R-WL identifies meaningful structural patterns that standard WL misses. Experimental results on dense social network benchmarks demonstrate significant performance gains, including a 20% accuracy improvement on the EGONETS-4 dataset.
Introduction
Graph kernels are indispensable for tasks ranging from molecular property prediction to social network analysis. Among these, the Weisfeiler-Lehman (WL) subtree kernel has emerged as the gold standard due to its linear-time complexity and strong performance on sparse graphs. However, the WL framework suffers from a fundamental limitation: it is binary. It compares node neighborhoods—represented as "unfolding trees"—based on strict isomorphism (exact equality).
In many real-world scenarios, particularly in dense social networks, neighborhoods are rarely identical but often structurally similar. Standard WL treats a "slightly different" neighborhood the same as a "completely different" one. This leads to a "label explosion" where almost every node is assigned a unique label, preventing the model from identifying shared structural motifs. To address this, we propose "relaxing" the strictness of WL by quantifying the similarity between neighborhoods rather than requiring exact equality.
Methods
The Relaxed Weisfeiler-Lehman (R-WL) kernel generalizes the traditional WL framework through a multi-step process. First, we define a specialized Structure and Depth Preserving Tree Edit Distance (SdTed). While general tree edit distance is NP-hard, SdTed enforces constraints that preserve the root and node depth—key properties of WL unfolding trees—allowing for efficient polynomial-time calculation.
Second, we prove that SdTed can be reformulated as a Wasserstein distance (Earth Mover's Distance) between sets of subtrees. This connection enables the use of efficient clustering algorithms. Instead of unique labels for every unique tree, we employ Wasserstein k-means clustering to group similar unfolding trees. Nodes are then considered equivalent if their unfolding trees fall into the same cluster, allowing for "soft-matching" of similar structures. A faster variant, R-WL*, uses cluster centers to approximate distances, enhancing scalability.
Key Insights
The core innovation of this research is the realization that in dense graphs, the probability of two nodes having identical depth-$h$ neighborhoods is near zero. By clustering similar neighborhoods, the R-WL kernel recovers the "shared vocabulary" that standard WL loses. The SdTed algorithm utilizes a recursive structure mirroring the WL iteration itself. As illustrated in Figure 4, the distance between depth-$i$ trees is computed via a minimum cost perfect bipartite matching of their depth-$(i-1)$ subtrees.
Evaluation and Results
We evaluated R-WL on several benchmarks, including traditional social network datasets (IMDB-BINARY, REDDIT-BINARY) and a new set of "ego network" benchmarks (EGONETS-1 to EGONETS-4) designed to test structural complexity and density.
The results highlight a clear correlation between graph density and the performance gap between R-WL and standard WL. On the densest dataset, EGONETS-4, R-WL achieved 77.50% accuracy, a staggering 20% improvement over the standard WL kernel's 57.00%. On REDDIT-BINARY, R-WL reached 87.02%, significantly outperforming modern kernels like Persistent WL (78.82%) and Wasserstein WL.
Conclusion
The R-WL kernel provides a robust solution for graph classification in dense and noisy environments where standard WL fails. By shifting from equality to similarity, it recovers the "shared vocabulary" of structural patterns. While more computationally intensive than simple hashing, the gains in predictive performance on complex graphs are substantial. Future work will explore extensions to attributed graphs and alternative clustering methods to further optimize scalability.
Summary updated