Skip to main content

fastwlk is a Python package that implements a fast version of the Weisfeiler-Lehman kernel.

Project description

https://github.com/pjhartout/fastwlk/actions/workflows/main.yml/badge.svg https://img.shields.io/pypi/v/fastwlk.svg https://codecov.io/gh/pjhartout/fastwlk/branch/main/graph/badge.svg?token=U054MJONED https://img.shields.io/website-up-down-green-red/http/shields.io.svg

What does fastwlk do?

fastwlk is a Python package that implements a fast version of the Weisfeiler-Lehman kernel. It manages to outperform current state-of-the-art implementations on sparse graphs by implementing a number of improvements compared to vanilla implementations:

  1. It parallelizes the execution of Weisfeiler-Lehman hash computations since each graph’s hash can be computed independently prior to computing the kernel.

  2. It parallelizes the computation of similarity of graphs in RKHS by computing batches of the inner products independently.

  3. On sparse graphs, lots of computations are spent processing positions/hashes that do not actually overlap between graph representations. As such, we manually loop over the overlapping keys, outperforming numpy dot product-based implementations.

This implementation works best when graphs have relatively few connections and are reasonably dissimilar from one another. If you are not sure the graphs you are using are either sparse or dissimilar enough, try to benchmark this package with others out there.

How fast is fastwlk?

Running the benchmark script in examples/benchmark.py shows that for the graphs in data/graphs.pkl, we get an approximately 80% speed improvement over other implementations like grakel.

To see how much faster this implementation is for your use case:

$ git clone git://github.com/pjhartout/fastwlk
$ poetry install
$ poetry run python examples/benchmark.py

You will need to swap out the provided graphs.pkl with with an iterable of graphs of your own.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastwlk-0.2.4.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

fastwlk-0.2.4-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page