Abstract
The choice of good distances and similarity measures between objects is important for many machine learning methods. Therefore, many metric learning algorithms have been developed in recent years, mainly for Euclidean data in order to improve performance of classification or clustering methods. However, due to difficulties in establishing computable, efficient and differentiable distances between attributed graphs, few metric learning algorithms adapted to graphs have been developed despite the strong interest of the community. In this paper, we address this issue by proposing a new Simple Graph Metric Learning - SGML - model with few trainable parameters based on Simple Convolutional Neural Networks - SGCN - and elements of optimal transport theory. This model allows us to build an appropriate distance from a database of labeled (attributed) graphs to improve the performance of simple classification algorithms such as $k$-NN. This distance can be quickly trained while maintaining good performances as illustrated by the experimental study presented in this paper.
Introduction
In machine learning, defining a good distance or similarity measure between objects (metric learning) is crucial for tasks like clustering and classification. While metric learning is well-established for Euclidean data, doing it for attributed graphs—where nodes have features and are connected by a specific topology—is notoriously difficult.
Existing methods face severe bottlenecks. Traditional metrics like Graph Edit Distance (GED) or Fused-Gromov-Wasserstein (FGW) have cubic or quadratic complexity, making them too slow to compute across large datasets. Furthermore, many graph comparison algorithms rely on non-differentiable procedures, making it impossible to optimize the metric using gradient descent. The SGML framework aims to bridge this gap by creating a similarity measure that is fast, fully differentiable, and capable of adapting to specific datasets to improve the performance of lightweight classifiers like k-NN.
Methodology
The SGML framework consists of three core innovations:
- From Graph to Distribution (Simple GCN): Instead of a heavy neural network, the authors use a Simple Graph Convolutional Network (SGCN) with no intermediate non-linearities. This network combines graph topology and node attributes to output a discrete distribution of node features with very few trainable parameters.
- The Metric ($\mathcal{RPW}_2$): To compare these distributions, standard Optimal Transport (Wasserstein distance) is too slow. The authors introduce Restricted Projected Wasserstein ($\mathcal{RPW}_2$). By restricting projections strictly to the canonical basis vectors of the feature space, they create a metric that is deterministic, differentiable, and scales quasi-linearly.
- The Training Loss (NCCML): To optimize the SGCN weights, they introduce Nearest Class Cloud Metric Learning (NCCML). This loss function calculates the probability of a graph belonging to a class based on its distance to the entire "cloud" of graphs sharing that label, specifically optimizing the metric for k-NN classification.
Experimental Results
The authors evaluate their method on a standard panel of benchmark datasets from the TU Dortmund repository, including MUTAG, NCI1, PROTEINS, and ENZYMES.
Computational Efficiency
A primary advantage of the $\mathcal{RPW}_2$ metric is its scalability. It scales at $O(n \log n)$, where $n$ is the number of nodes. In empirical tests, it computed distances between distributions several orders of magnitude faster than standard Wasserstein ($W_2$) as the number of nodes increased.
Classification Performance
SGML combined with k-NN significantly outperformed existing graph distances like NetLSD and FGSD. For example, it achieved 90.00% accuracy on MUTAG and 70.18% on PROTEINS. When used to build a custom kernel for an SVM, it proved highly competitive with state-of-the-art, computationally heavy methods like WWL, beating it on several datasets (e.g., 88.95% vs 87.27% on MUTAG) despite having a fraction of the computational cost.
Key Insights and Conclusion
By stripping non-linearities from the GCN and restricting Optimal Transport projections to canonical axes, the authors achieved massive computational speedups while maintaining representational power. Furthermore, the deterministic nature of $\mathcal{RPW}_2$ makes the training loop more stable than stochastic alternatives like Sliced Wasserstein.
While massive Graph Neural Networks dominate current literature, this work shows that a well-learned metric combined with a simple k-NN classifier can achieve highly competitive results. Future work will involve investigating the theoretical properties of $\mathcal{RPW}_2$ and adapting the SGML framework to tasks beyond classification, such as graph clustering or regression.
Summary updated