Skip to main content

wl_subtree_kernel

Function wl_subtree_kernel 

Source
pub fn wl_subtree_kernel(
    adj1: &[Vec<usize>],
    labels1: &[u64],
    adj2: &[Vec<usize>],
    labels2: &[u64],
    max_depth: usize,
) -> f64
Expand description

Weisfeiler-Leman subtree kernel (1-WL).

Counts matching subtree patterns at each depth up to max_depth. At each iteration, node labels are refined by hashing the multiset of neighbor labels, capturing increasingly large subtree structure.

The kernel value is the inner product of the aggregated label histograms across all depths.

§Arguments

  • adj1 - Adjacency list for graph 1
  • labels1 - Initial node labels for graph 1
  • adj2 - Adjacency list for graph 2
  • labels2 - Initial node labels for graph 2
  • max_depth - Number of WL refinement iterations

§Example

use graphops::wl_subtree_kernel;

// Triangle graph
let adj = vec![vec![1, 2], vec![0, 2], vec![0, 1]];
let labels = vec![1, 1, 1];

let k = wl_subtree_kernel(&adj, &labels, &adj, &labels, 2);
assert!(k > 0.0);