Skip to main content

random_walk_kernel

Function random_walk_kernel 

Source
pub fn random_walk_kernel(
    adj1: &[Vec<usize>],
    adj2: &[Vec<usize>],
    max_len: usize,
    lambda: f64,
) -> f64
Expand description

Random walk kernel via direct product graph.

Counts matching random walks between two graphs with geometric decay. k(G1, G2) = sum_{l=0}^{max_len} lambda^l * (matching walks of length l)

A matching walk of length l is a sequence of node pairs (u0,v0), (u1,v1), ..., (ul,vl) where each (ui, ui+1) is an edge in G1 and (vi, vi+1) is an edge in G2.

§Arguments

  • adj1 - Adjacency list for graph 1
  • adj2 - Adjacency list for graph 2
  • max_len - Maximum walk length
  • lambda - Decay factor per step (should be < 1 / max(degree) for convergence)

§Example

use graphops::random_walk_kernel;

// Two edges
let adj1 = vec![vec![1], vec![0]];
let adj2 = vec![vec![1], vec![0]];

let k = random_walk_kernel(&adj1, &adj2, 3, 0.1);
assert!(k > 0.0);