Skip to main content

A fast maximum weight bipartite matching algorithm from 'A Faster Algorithm for Maximum Weight Matching on Unrestricted Bipartite Graphs'

Project description

Kwok

A Cython-based implementation of "A Faster Algorithm for Maximum Weight Matching on Unrestricted Bipartite Graphs" that supports multiple Python versions and platforms.

About

Kwok implements a fast maximum weight bipartite matching algorithm based on the paper "A Faster Algorithm for Maximum Weight Matching on Unrestricted Bipartite Graphs" (https://arxiv.org/abs/2502.20889). The algorithm achieves runtime O(E^1.4 + LR) estimated from experimental tests on random graphs where |L| <= |R|.

Installation

pip install kwok

Usage

import kwok

# Example usage
L_size = 3  # Number of vertices in left partition
R_size = 3  # Number of vertices in right partition
adj = [
    [(0, 10), (1, 5), (2, 1)],  # Edges from left vertex 0
    [(0, 2), (1, 15), (2, 0)],  # Edges from left vertex 1
    [(0, 0), (1, 8), (2, 12)]   # Edges from left vertex 2
]

# Solve the matching problem
matching = kwok.kwok(L_size, R_size, adj)
print("Left pairs:", matching.left_pairs)
print("Right pairs:", matching.right_pairs)
print("Total weight:", matching.total_weight)

API Reference

kwok(l_size, r_size, adj, keeps_virtual_matching)

Computes the maximum weight matching in a bipartite graph.

Parameters:

  • l_size (int): Number of vertices in left partition (L)
  • r_size (int): Number of vertices in right partition (R)
  • adj (list): Adjacency list where each element is a list of (vertex, weight) tuples representing edges from a vertex in L to vertices in R
  • keeps_virtual_matching (bool) : The algorithm's output is mathematically equivalent to the solution obtained by computing matches on a complete bipartite graph augmented with zero-weight virtual edges. However, for computational efficiency, the implementation operates directly on the original sparse graph structure. When the keeps_virtual_matching parameter is disabled (false), the algorithm automatically filters out any zero-weight matches from the final results.

Returns:

  • Matching: A dataclass with the following attributes:
    • left_pairs (list): Maps L vertices to their matched R vertices (-1 if unmatched)
    • right_pairs (list): Maps R vertices to their matched L vertices (-1 if unmatched)
    • total_weight (int|float): Total weight of the matching

Note: Integer weights are not required, but using integers may improve performance.

Development

To build the package locally:

pip install -e .

Building wheels with cibuildwheel

To build wheels for multiple Python versions and platforms, we use cibuildwheel.

cibuildwheel is a powerful tool that:

  • Builds wheels for CPython and PyPy on Windows, macOS, and Linux
  • Handles platform-specific wheels (including manylinux)
  • Tests the built wheels in isolated environments
  • Integrates with CI services like GitHub Actions

Local testing with cibuildwheel

To test cibuildwheel locally:

pip install cibuildwheel
python -m cibuildwheel --platform linux

Available platforms are: linux, windows, and macos.

CI integration

This project is configured to automatically build wheels using GitHub Actions. See the .github/workflows/build_wheels.yml file for the configuration.

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

kwok-1.1.4.tar.gz (80.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kwok-1.1.4-cp313-cp313-win_amd64.whl (39.9 kB view details)

Uploaded CPython 3.13Windows x86-64

kwok-1.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (358.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

kwok-1.1.4-cp313-cp313-macosx_11_0_arm64.whl (38.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kwok-1.1.4-cp312-cp312-win_amd64.whl (40.4 kB view details)

Uploaded CPython 3.12Windows x86-64

kwok-1.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (362.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

kwok-1.1.4-cp312-cp312-macosx_11_0_arm64.whl (39.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kwok-1.1.4-cp311-cp311-win_amd64.whl (39.9 kB view details)

Uploaded CPython 3.11Windows x86-64

kwok-1.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (350.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

kwok-1.1.4-cp311-cp311-macosx_11_0_arm64.whl (38.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kwok-1.1.4-cp310-cp310-win_amd64.whl (39.9 kB view details)

Uploaded CPython 3.10Windows x86-64

kwok-1.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (338.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

kwok-1.1.4-cp310-cp310-macosx_11_0_arm64.whl (38.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kwok-1.1.4-cp39-cp39-win_amd64.whl (40.0 kB view details)

Uploaded CPython 3.9Windows x86-64

kwok-1.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (337.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

kwok-1.1.4-cp39-cp39-macosx_11_0_arm64.whl (38.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

kwok-1.1.4-cp38-cp38-win_amd64.whl (40.4 kB view details)

Uploaded CPython 3.8Windows x86-64

kwok-1.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (342.2 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

kwok-1.1.4-cp38-cp38-macosx_11_0_arm64.whl (39.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

kwok-1.1.4-cp37-cp37m-win_amd64.whl (41.8 kB view details)

Uploaded CPython 3.7mWindows x86-64

kwok-1.1.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (330.0 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

kwok-1.1.4-cp36-cp36m-win_amd64.whl (40.0 kB view details)

Uploaded CPython 3.6mWindows x86-64

kwok-1.1.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (316.9 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

Details for the file kwok-1.1.4.tar.gz.

File metadata

  • Download URL: kwok-1.1.4.tar.gz
  • Upload date:
  • Size: 80.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4.tar.gz
Algorithm Hash digest
SHA256 54a26beaf2fbd8ac3942e03dc35a788d27395d1b10a3c4ef58ecc003aab586f9
MD5 cf2659ddfe30c10e12680904ee3dce52
BLAKE2b-256 ea366137bab35e13af5e098a1b784e355c1f649ef020ffcd2e2b82f09ea0678b

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5bbe3ad5d75a5ec1e2cd5afe9bc0b2df72daf0739d419f0ddc1f93c6f86f3a0c
MD5 e8f655ba23958a21bf4cf6aafda6c43c
BLAKE2b-256 0b26ae28794f086c9f20a8338ab6d9155bb304db6545551cf4adbf302dec1471

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8be13a9033d3a1833b060d420d8ff70e39cd12aaac42ae2ebab62fbd238efa50
MD5 8327b7b724a7f5aaab6d2c7d05c3727c
BLAKE2b-256 22eacc3a8f943986acbe7e726b98c99c0f1aa6444fddd02068b9c333b7599753

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e527cbdfc0e8df35f6fa29364ba88e22f10436538a7c43e4f8bf799c09243a98
MD5 2b7ec98cbddf2032ca78281f1a986f03
BLAKE2b-256 20240f681e4a7723da1b02f8a5cf27d97fe19726cf51f69c91ef2e9aea53e2f4

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 40.4 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 add32d0879240b50523a5865b5000f433e505e4d92473256c4522f2089ed31ba
MD5 d6358fa0d14f41c016b17bad4a9b9884
BLAKE2b-256 af459f5a93caee82b7890303c4d3da0eb90d37d557499f4a6039c07a22c79f10

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a24e4d17853c57572358742d315a724b036f117a7ab12076245e7f241cb483e
MD5 4d407f5e42f62ad9764d67b064518f52
BLAKE2b-256 5a724b29f68edc54e8b82bab186fefc51088f37ad5bc150014d98e722d109a4e

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6cf7300d903fde2dadb196c426b1419139957ee1db4970de87d73e54ef1a56c0
MD5 8ce7ca2682d5cfed7ab8a274aac63704
BLAKE2b-256 79486daa1ae4ea04dc167930dbb75a98faed597fd25dd174eac54a51e719fbb9

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fc58b71b9f74f28de29431d5b6e9e0822977d41450827031f0db720e487e0011
MD5 7d3a04f5043953b3e47f4b1312dd60b6
BLAKE2b-256 02280cc353bea1763eaf34053a0e6638879ce78cbe0a834bd6474236f66ce2a2

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1e3d3474fcaba89bc01a96e02bc1217750fb67b97f951a050699eff945b690c
MD5 2ccd64f24171ccb211ef361cd1b97c70
BLAKE2b-256 e02e23e815b8d14ee1d6d9a564618499327390e4ebcda87dde3579af808e0020

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d43dfc4f225c856d1d964bc9d0f36035ea6e0a950d4df1d67bbccf1ea5c4295
MD5 5fcf7813199c56f8889e8b70d28cdab0
BLAKE2b-256 cfeccd677b3c5f82e9ac45d77085d1b660b25123139e6483157a8bc15a1e3ac5

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 39.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4eedddfcac744d7fa665924342ec2c3a6658bbd50861bbdfd32b3e0bf506fb7d
MD5 3e3cef9f5db1c82a33403d775165b8cc
BLAKE2b-256 e5c4f6137e46c8227faf7ccf9d22dd50a5224c4a180a307b315eb17dd6a090fe

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d68f287bf9dbcc8aead0c282b9d750ebf87c406b15f45c2504b6ffb4ccb4bd89
MD5 e75110d2c2915f3093bbf0d09dd845d2
BLAKE2b-256 941eb636faf2788917b107f8e9a3ba8a042314a6540253fae7b680c8ab6c0d0b

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dfc90be4699bf62d0d522b982dac7cd8392038e2ca4b76437619c4d1ec35484d
MD5 66f254da800a0dd27c1f8eb8d193fc5d
BLAKE2b-256 a28f887e1535a2cf9c70e9c19390a6a08b136f8a71242c13b8c9863d6a5f02b5

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 d428acf318669190b201f55ee049cbe80e6b1eb4d97e9c8048019b391605d687
MD5 1046c1f92f16ee059c2fedf9c9a6c39c
BLAKE2b-256 c4441235267b747af655622dc8b31ed823a11d6e3f59f6c49618b37996bec61f

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c57c62b992e58d38f3e0435e9925a5edbfd3b5d2dc8cee8dc715144f5984ffa7
MD5 8e28ca60ac8e0979bdb0edc9e9f3ec24
BLAKE2b-256 c77d1cb56b63de3964e54371642139de0c8f4093b039621595aa6921d78628f5

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1802ab9345375fcdc19d5d7d77d51ad8cf41860b0f431c4a1d5b1533c7354e8f
MD5 92bc9bae731ec7fb15f207e5fcf9d728
BLAKE2b-256 e6fe10f832e860f80f56d6c88623bba9bc095719f6476cb2d60f0df5dfa356c7

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 40.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 c8f4a5111fc4de4ab7486f0464e656d661ef1c98625c8f74b7e78a98a01ee8ea
MD5 acd8d723bec7143258bdbe86812b4cac
BLAKE2b-256 030e48670d47785ed50976ae1b2e81c560ff0ef64e46fbaeda6ec15075bc7746

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e7f5fa3c6009871d2e721e33b645b49ace193599016f2b13acfe0a8e832906a
MD5 9c3bb78bd7c4212efd6d3a96cb941f01
BLAKE2b-256 c07487a75852062934c491a0f40e970a2f516923214b4300aa096e6d3464c5a0

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9ed6a0cef6c6b892ec01402061d6d43c8323a1e29fd41594b2e802421158446
MD5 c3a8f7e3b5bc06d6494d6a47f07bbacd
BLAKE2b-256 a80c876dbd0293d8da8209b5707847c6d4d0cae47fc3689e93b5ef6e8235e29e

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 41.8 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a9ef2e9cfad1d4f8b65be1a99f9780a9f010f89128df970be3b0a6a7c972331d
MD5 86bb73291ad041381bc483c10b965241
BLAKE2b-256 903d99a4de5e6647e81d2f93f2c7e0f576813aa71a7a25fd01ffa6d6a4c85d83

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5c9ebd56d41bf8621c41e676507e951fb1001bba87e66d4a9b479c5574e40eb8
MD5 d2bc9771317f7f07a0f9fc48b690df58
BLAKE2b-256 3501cf2d46dad9f92e79f2d93424c502f092e414dbf6f734df8de2803a6c65bc

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: kwok-1.1.4-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 40.0 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for kwok-1.1.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 197c339e8620535343676c4e7ae4dacf518b74d37d7ff317f73a8a9840aa4902
MD5 d2bd57d3a6627ad1ca33a2300332f720
BLAKE2b-256 723af2538114f7bb642d8de9ae17f89185799b7900f953d098cb7ac0a90cd0dd

See more details on using hashes here.

File details

Details for the file kwok-1.1.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for kwok-1.1.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58472aefdff88682487f30da6e56f8fa1ced3d1117ffcc98e9d239bccf87bb9a
MD5 546d5bb9cbe5d49341296d624421cb0b
BLAKE2b-256 e08a590fdaf78b341098c8df0f5c7147112c75e1aff032e669b53c3e966350b0

See more details on using hashes here.

Supported by

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