Welcome to the documentation of PyWLGK

PyWLGK is a Python implementation of the Weisfeiler-Lehman Graph Kernels (WLKs). It is based on the paper by ? et al. The main improvement over other tools is that PyWLGK can be installed from PyPI and Anaconda for any current python version, i.e. Python 3.8 and newer.

Installation

PyWLGK can be installed from PyPI using pip:

pip install pywlgk

or from Anaconda using conda:

conda install -c conda-forge pywlgk

Usage

After installation, PyWLGK can be used as follows:

from pywlgk import wlk
import numpy as np

adjs = np.random.randint(0, 1, size=(2, 10, 10))
adjs = np.array(adjs + adjs.transpose(0, 2, 1), dtype=np.int32)
labels = np.ones((2, 10), dtype=np.int32)
wlk(adjs, labels, k=4)

PyWLGK takes as input a stack of adjacency matrices (adjs) and a stack of node labels (labels). The adjacency matrices must be symmetric, whereas the labels can have any type. Additionally, one can specify a k to control how many iterations of the kernel will be computed.