arXiv:2610.40956cs.LGOct 2026

Manuscript Offprint

arXiv:2610.40956

Monte Carlo Random Walk Kernel

Arslan Iamaletdinov, Elfat Sabitov, Konstantin Sorokin

Abstract

We introduce the Monte Carlo Random Walk Kernel (MCRWK), an estimator whose per-pair cost is independent of graph size and derived directly from the random walk kernel (RWK) expansion. By normalizing the kernel coefficients, MCRWK samples a shared walk length and estimates its contribution using random walks on the input graphs. This gives a simple way to approximate RWK without constructing the product graph. For a fixed expected walk length and efficient neighbor sampling, each pairwise estimate takes O(m)O(m) time for mm Monte Carlo samples, allowing the sample budget to control the trade-off between runtime and accuracy. We evaluate MCRWK against Graph Voyagers and classical RWK methods on synthetic and real graph datasets. In the reported experiments on large synthetic graphs, MCRWK is faster than Graph Voyagers and, at matched runtime, more accurate. It also has the lowest Gram-matrix runtime on the five real datasets studied. Code and experiments are available at https://github.com/arslan-yam/random_walk_kernels_computations

1 Introduction

Graphs are universal data structures that model relational information across diverse domains, including chemoinformatics (molecular graphs), bioinformatics (protein-protein interaction networks), neuroscience (connectomes), and social network analysis. A central task in these settings is to measure graph similarity for downstream problems including classification, clustering, and regression. Kernel methods address this task by defining a positive semi-definite kernel K(G1,G2)K(G_1, G_2), which implicitly embeds graphs into a Hilbert space where inner products encode similarity.

In this paper, we consider Random Walk Graph Kernels (RWK). Given two unweighted graphs G1G_1 and G2G_2, with vertices V(G1)={v11,...,vN11}V(G_1) = \{v_1^1, ..., v_{N_1}^1\} and V(G2)={v12,...,vN22}V(G_2) = \{v_1^2, ..., v_{N_2}^2\} respectively, their product graph G1×G2G_1 \times G_2 is the direct product of vertices and edges of G1G_1 and G2G_2:

V(G1×G2)=V(G1)×V(G2),V(G_1 \times G_2) = V(G_1) \times V(G_2), E(G1×G2)={((u1,u2),(v1,v2)):E(G_1 \times G_2) = \left\{ \left( (u_1, u_2), (v_1, v_2) \right) : \right. (u1,v1)∈E(G1),(u2,v2)∈E(G2)}.\left( u_1, v_1 \right) \in E(G_1), \quad (u_2, v_2) \in E(G_2) \Big\}.

Then, general RWK on G1×G2G_1 \times G_2 can be computed as:

k(G1,G2)=v⊤[∑k=0∞μkA×k]w.(1)k(G_1, G_2) = \mathbf{v}^\top \left[ \sum_{k=0}^{\infty} \mu_k \mathbf{A}_\times^k \right] \mathbf{w}. \tag{1}

Here A×\mathbf{A}_\times is the normalized adjacency matrix of the product graph, {μk}k=0∞\{\mu_k\}_{k=0}^\infty is a non-negative coefficient sequence that defines kernel type, and v,w∈RN1N2v, w \in \mathbb{R}^{N_1 N_2} denote starting and stopping distributions over the product graph. These distributions are typically v=v1⊗v2\mathbf{v} = v_1 \otimes v_2 and w=w1⊗w2\mathbf{w} = w_1 \otimes w_2, where ⊗\otimes is Kronecker product.

The main computational bottleneck of RWKs is the product graph: for two NN-vertex graphs, it has N2N^2 vertices, and direct computation costs O(N6)O(N^6). Vishwanathan et al. (2010) reduced this to O(N3)O(N^3) using Sylvester equations. More recently, Choromanski et al. (2025b) introduced Graph Voyagers (GVoys), the first linear-time algorithm for general RWKs on sparse graphs. GVoys avoid constructing the product graph by correlating random walks on the two input graphs through shared random variables, yielding unbiased estimates for labeled and unlabeled graphs.

We propose Monte Carlo Random Walk Kernel (MCRWK), a simpler O(m)O(m)-time estimator for RWKs, where mm denotes the number of Monte Carlo samples. Like GVoys, MCRWK relies on synchronized random walks, but it samples the shared walk length directly from the normalized kernel coefficient distribution. This removes the need for auxiliary Rademacher variables and avoids anchor-point selection while preserving unbiasedness. The resulting algorithm is empirically faster on large graphs, while maintaining comparable approximation error to GVoys and unbiasedness. Our contributions are as follows: (i) We introduce MCRWK, a Monte Carlo estimator for random walk graph kernels with O(m)O(m)-time scaling; (ii) its derivation for unlabeled and labeled graphs, including geometric and exponential kernels; (iii) proofs of unbiasedness and variance bounds showing that the sample complexity does not depend on graph size; and (iv) an empirical comparison with classical RWK baselines and GVoys, demonstrating faster and more accurate computation on large graphs, complemented by evaluations of Gram-matrix construction and downstream classification and regression on real graph datasets.