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
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(adj)
print("Left pairs:", matching.left_pairs)
print("Right pairs:", matching.right_pairs)
print("Total weight:", matching.total_weight)

API Reference

kwok(adj, keeps_virtual_matching)

Computes the maximum weight matching in a bipartite graph.

Parameters:

  • 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. Note that |L| <= |R| is required.
  • keeps_virtual_matching (bool) : Default is true. 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.6.tar.gz (82.9 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.6-cp313-cp313-win_amd64.whl (41.4 kB view details)

Uploaded CPython 3.13Windows x86-64

kwok-1.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (369.3 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

kwok-1.1.6-cp313-cp313-macosx_11_0_arm64.whl (40.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

kwok-1.1.6-cp312-cp312-win_amd64.whl (41.8 kB view details)

Uploaded CPython 3.12Windows x86-64

kwok-1.1.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (372.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

kwok-1.1.6-cp312-cp312-macosx_11_0_arm64.whl (40.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

kwok-1.1.6-cp311-cp311-win_amd64.whl (41.4 kB view details)

Uploaded CPython 3.11Windows x86-64

kwok-1.1.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (361.1 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

kwok-1.1.6-cp311-cp311-macosx_11_0_arm64.whl (39.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

kwok-1.1.6-cp310-cp310-win_amd64.whl (41.3 kB view details)

Uploaded CPython 3.10Windows x86-64

kwok-1.1.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (347.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

kwok-1.1.6-cp310-cp310-macosx_11_0_arm64.whl (39.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

kwok-1.1.6-cp39-cp39-win_amd64.whl (41.3 kB view details)

Uploaded CPython 3.9Windows x86-64

kwok-1.1.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (346.1 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

kwok-1.1.6-cp39-cp39-macosx_11_0_arm64.whl (39.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

kwok-1.1.6-cp38-cp38-win_amd64.whl (41.7 kB view details)

Uploaded CPython 3.8Windows x86-64

kwok-1.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (346.8 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

kwok-1.1.6-cp38-cp38-macosx_11_0_arm64.whl (40.3 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

kwok-1.1.6-cp37-cp37m-win_amd64.whl (42.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

kwok-1.1.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (330.2 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

kwok-1.1.6-cp36-cp36m-win_amd64.whl (41.0 kB view details)

Uploaded CPython 3.6mWindows x86-64

kwok-1.1.6-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (319.0 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: kwok-1.1.6.tar.gz
  • Upload date:
  • Size: 82.9 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.6.tar.gz
Algorithm Hash digest
SHA256 7f0070211ef7a941e9643b891e1df33f07ca6b806302a10b631267c3c9def8a9
MD5 17b7e857c5637ac54fde3bd4677fe3fa
BLAKE2b-256 e48d44ffad1cd06bf3ae5085a81a2811a1009c6d36057c0ef3b758272347ff0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 41.4 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6de2b60aa25a9fb6f1ca5698f577a2e4cbe6ebc81f1a101b9add7a5efe4f4ef4
MD5 4a8c99227cbe2cee08423d1e699fd68f
BLAKE2b-256 cb884907601ccda48f2e955ec33a9606755d735c57784947952ac6bb85127229

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f5eb948421f5bb5b8e86a53c57b33a22eee729e6a13c5eb0ee788a28731c29ac
MD5 ddc82a0a1433bdcde828617d5db23eab
BLAKE2b-256 4116e02c8ad9b8a17cef11d0929b9efa709a5ca85ac12cadf030bb0841f97eac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e8659e4bcb13b45af54c016e08dc9f68c1e3daab240b61ab5f0ecda18e8a68aa
MD5 c3f974a95653b216117cac92a00e617b
BLAKE2b-256 6d8c5a92eb91bb72dc4a1a953c70af8ac22a918ac1ccd164d10d602c15e2fe6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 41.8 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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 82f48cca6c103f852e2c01ced0db5293bd3c881a823d14aa07b36a56caeb485c
MD5 f8d2002b228198bd56885186cfd870fa
BLAKE2b-256 491129e49bd0c0f8b28d5cd412e8fe6392d31e2a9d5e270b7a3ad1af992621ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3e2caef79ea081edda46d63d5bf5d8828778eb1d99b2e29b6ea11fabb626aae3
MD5 cad642476ba4fe5c5d678d7390a62295
BLAKE2b-256 4d65fed841f61edecc55e4989a816d23b72871a52c486aceba8f467a7fbfc4ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ff881ece65e3fc4a1680796a93bd1e0f765f3e90386e27b20833483fe932d043
MD5 4bf0fb3969616cd2272e7252539996f3
BLAKE2b-256 779c6ec7084e67f17f86f00906179679c0f6e9d0e4ebd46f3b44e30d3f55547b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 41.4 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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 736f785174b239396c549ba32898aff30a7a412a332e3fbc29c4388e9bcd503c
MD5 e140d7a792179c04d48dd51907308e61
BLAKE2b-256 c22962e9a4d282377a81bc875780609a529b8cd4508b6c63a4d4fe269921a5b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18aac807b495c4c7c65aa070ffa021d3d9dd687fa7ef6bf73e4b77b8d3e05ef2
MD5 5b08564e83620db47eb7ee6754ffa36b
BLAKE2b-256 51d0227b93711e80a8639231d61ee89f21a698a3f70d139b93769c18bde280d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a93a390a6d61f9bbbc6dbcd2f75c3613c6c52ee1e44805925a21f6501536b7e2
MD5 0a9377f9c3b2432630fbbae5472dd239
BLAKE2b-256 22664f77580a93bef7eb0151553da25e1817009ef7ea2bbf516bda5b4eda51fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 41.3 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.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4c6bd66a9dfbe7a443a06345ab8dfe04d2ae0919d11cd87f689d149b5c3e73cc
MD5 79a85f0dded233824e1c3edb9b578278
BLAKE2b-256 3488361fb6c82e3987d5d0d2f3bda6c8cd916883c47995558e306e17e1fafe3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3bdb5eafa34b8c70741c7b3f14c218d3f754d22e0f96b8b09ea4ab810c6c2835
MD5 1e8510b6351c8e8ade6eafd39c2fbbc5
BLAKE2b-256 ad6b9f67f0941704b546d508d53f198fd63a6ca0697db7db2b9509aa5cdd7c22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ca26ce6c69a89aea57ea381a3131dc58720542f9e9db1c94a31d501b1ba811ce
MD5 0901dbef9017fd3aa72b9938910a558d
BLAKE2b-256 5b36b1dc309200e158a21c90a1c39c8d2cabb1484f4eff2ef0ffa2a7083da5c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 41.3 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.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 059cca502a68b69a1e26b31f77fb6f0da2eade8b5955e17b103c3c455aec5c71
MD5 fc78c7e0bd661c7ee01f29c3def906ab
BLAKE2b-256 dd94e9c284cb57c0b4241b266b447f0d73d72da6c052a1f5bc3ecd83d5069109

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f794f80bb173017a0cb8eb67ba49817f7bafd471502aa844ab7e09cc08fe3e48
MD5 26944643ce2cccd9b13d68118cd35a02
BLAKE2b-256 48cce3f2eb91265a161fedca168fc5fb85378f227ba53de35fa163f89c04d9b9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 39.7 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.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2348dd991c41e018708c7b61f5bc5a6aa8a6e95da3553af8c7d70d9b15df28d
MD5 80793918eeeea1507a1fcb6a25a1e9ba
BLAKE2b-256 d4caf8268c9be9a55a17bf880b947aa2a218ff3a98908e438bcb5e73137f5a00

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 41.7 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.6-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ee0ffbd9c6f79f6fbc455438151ce27717613174cb23218985106fb4d6e86dfc
MD5 9a733cdde4ce493f7074fd46fce83641
BLAKE2b-256 bc86d2deebfea924b9d037f2fe31688ece17a7715e8e416ad382b0f683962235

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82889d782dfb406c40ed513f057b07fbee258110d4bb7460a43ab644d113162e
MD5 8652eebbf7680f067d8d06b0b40184b0
BLAKE2b-256 d1aa83874579d2ab82d92e173e6fc222f0ce819eb616f5751f51522fa65364d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 40.3 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.6-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7a50a4e95b1425fe9c565e4a78fcf74b11ffde62b67b20600bbf99462a4b2ece
MD5 044d1074406da3fc1d8f7799e5311f99
BLAKE2b-256 973dee6f39a298802d6ec708c988730ec26846f2d3034e9c5c327248c0ce03d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 42.7 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.6-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 d0d763e928f6d293da5ddcdb1e9ca85afe5b2a6ec77612b6fc87712bbf174cca
MD5 956bd4bf8e1a6da84906ff262b252246
BLAKE2b-256 3d54ad328c61438b97ac6d332bb51c5f0aa82583cf787d09af5f4cd8dac3b917

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5baaf95353ce4ee5677ac96799af23e3d82617e8f5f1c263e33f04b06b95680b
MD5 9e9715c384d6da978b25940775855055
BLAKE2b-256 4a35227376b4b6c5f052cd5bea00fa8b05770abd0e52925a9b9f2b1647cc1562

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.6-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 41.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.6-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 75b1d357f7a9cf3d744e0691250837c06f3c906751d0169d3d3913a72fee2c6c
MD5 9b7e551c95e3affd5262a9b13c45af7a
BLAKE2b-256 75b80b81321635878c94609a2a90a1b08fa6513a662b7e5355d3c8e54a612ccc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.6-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b965f806f73f834e375910b54cee4eccb7c5411abce80d24f9536a51ee2d39d8
MD5 83532a356f3fabf117c7e6f0943cc33a
BLAKE2b-256 97017f78db3cd0a013825308c4b859448ced3f47e8b9f4d6d05b915f99fbacf6

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