Matching Node Embeddings for Graph Similarity

Giannis Nikolentzos, Polykarpos Meladianos, Michalis Vazirgiannis

Abstract

Graph classification is a fundamental task in machine learning, yet traditional graph kernels often struggle to capture global structural information or scale to large datasets. This paper introduces a novel approach that represents graphs as "bags-of-vectors" using spectral node embeddings. By leveraging Earth Mover's Distance (EMD) and the Pyramid Match (PM) kernel, the authors provide a framework that effectively captures global topology while maintaining computational efficiency. Experimental results on standard bioinformatics benchmarks demonstrate that these methods achieve state-of-the-art accuracy and significantly better scalability than traditional local-feature-based kernels.

Introduction

In machine learning, comparing graphs—such as molecules, social networks, or protein structures—is typically performed using graph kernels. Traditionally, these kernels measure similarity by counting shared local substructures, such as short paths, subtrees, or small cycles. However, this "myopic" approach often ignores the global structure of the graph. For larger graphs, two networks might share many local features but possess entirely different global topologies.

Furthermore, recent attempts to build global graph kernels by matching node embeddings have faced a mathematical hurdle: the resulting similarity matrices are often not positive semidefinite (PSD). Standard Support Vector Machines (SVMs) require PSD matrices to guarantee an optimal solution. This paper addresses both challenges by proposing a method to capture global graph structure using node embeddings while providing mathematically sound comparison techniques for classification.

Methodology

The authors propose a pipeline that shifts graph comparison from topological matching to point-cloud comparison:

  1. Spectral Node Embeddings: Instead of analyzing local neighborhoods, each node is embedded into a $d$-dimensional vector space using the top $d$ eigenvectors of the graph's adjacency matrix. Since eigenvectors capture global connectivity (e.g., eigenvector centrality), these embeddings inherently describe the node's role within the entire graph.
  2. Bag-of-Vectors Representation: A graph is treated as a set (or "bag") of these $d$-dimensional node vectors, abstracting away the original explicit edges.
  3. Graph Comparison Approaches:
    • Earth Mover’s Distance (EMD): This calculates the minimum "travel cost" to transform the point cloud of one graph into another. To handle the non-PSD nature of EMD, the authors utilize a specialized SVM formulation that learns classifier weights alongside a proxy PSD kernel matrix.
  4. Pyramid Match (PM) Kernel: Adapted from computer vision, this method maps vectors into multi-resolution histograms and compares them using a weighted intersection metric. Unlike EMD, the PM kernel guarantees a valid PSD matrix and offers superior scalability.

Experimental Setup

The methods were evaluated on six standard bioinformatics benchmark datasets for graph classification, ranging from small chemical compounds to large protein structures.

Summary of the benchmark datasets used in the evaluation, highlighting the scale and diversity of the graphs.

Key Results and Discussion

The proposed methods (EMD, PM, and their Weisfeiler-Lehman extensions) outperformed or matched state-of-the-art local graph kernels on almost all datasets.

Accuracy and Scalability

On the labeled MUTAG dataset, EMD achieved a peak accuracy of 89.44%. On NCI1, the WL-PM variant achieved 86.40%. Beyond accuracy, the Pyramid Match (PM) kernel demonstrated exceptional efficiency. On the D&D dataset—which contains massive graphs averaging 284 vertices—half of the baseline methods (including EMD) failed to compute the kernel matrix within a 24-hour limit. In contrast, the PM kernel completed the computation in just 4 minutes and 30 seconds while maintaining a competitive accuracy of 77.78%.

Classification accuracy and computation time for various graph kernels across datasets, demonstrating the performance of EMD and PM methods.

The EMD vs. PM Trade-off

While EMD is highly intuitive and accurate for finding optimal alignments, its $O(n^3 \log n)$ complexity makes it prohibitive for large graphs. The Pyramid Match kernel provides a powerful alternative, approximating the matching process in $O(dnL)$ time and guaranteeing a PSD matrix, making it the preferred choice for large-scale applications.

Conclusion

By treating graphs as point clouds of spectral embeddings, this research successfully bridges the gap between graph theory and efficient set-comparison algorithms from computer vision. The results suggest that global structural information is a vital component of graph similarity, and the Pyramid Match kernel, in particular, offers a scalable path forward for analyzing complex, large-scale networks.

Summary updated

BibTeX
@inproceedings{nikolentzos2017matching,
  author = {Giannis Nikolentzos and Polykarpos Meladianos and Michalis Vazirgiannis},
  title = {{Matching Node Embeddings for Graph Similarity}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2017},
  doi = {10.1609/aaai.v31i1.10839},
}
Figure