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 Rkeeps_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
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kwok-1.1.5.tar.gz.
File metadata
- Download URL: kwok-1.1.5.tar.gz
- Upload date:
- Size: 80.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
222060c5ffbbad712926461c8c3b568bd16e973f10e9795c909bef46750bd3de
|
|
| MD5 |
63c16224118a0fea41023d0342c63432
|
|
| BLAKE2b-256 |
3d252d906b26bf9c120cfcd3d3401666cbe25f560a4d49e2291b2907d834e0e5
|
File details
Details for the file kwok-1.1.5-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: kwok-1.1.5-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 40.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5c836110aea8388db7c122ff762b0cd36accf64a2f0b7fbaf6c20b8abc75d05
|
|
| MD5 |
1ac68d650cffe9b914e9ccab39c36489
|
|
| BLAKE2b-256 |
4dd42e31b35280c2b77e0e8bd1cbd0d3b3d9203c8a304a9bd95ca318079c27a5
|
File details
Details for the file kwok-1.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kwok-1.1.5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 358.7 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03f88feef5d0b68a9f414ba2d9a5c3a3b377f409d889d24cdfbc69b55ccd1a04
|
|
| MD5 |
5f3a844d01fc2242e432de67363748db
|
|
| BLAKE2b-256 |
7b6554dee99fb47358c409b97af0ec90e59e4e6a6d8000f9d60bfeb898b5367b
|
File details
Details for the file kwok-1.1.5-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: kwok-1.1.5-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 38.4 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbbaa328ec3bea7199ea24faf077c4efc5dfbbb905ae03c371527fce6a8682dd
|
|
| MD5 |
428bf2c79a5f2da847bdfc744a10d2fa
|
|
| BLAKE2b-256 |
c80ddbf224ab32492d3f4c023c6406dbcea9cffeb4e2aec604c4da0b27a07634
|
File details
Details for the file kwok-1.1.5-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: kwok-1.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fa1dc12133386cff370e0db828aa025d1bb7e7699b817585c7c6dd515c57d5d
|
|
| MD5 |
277280b7b7371158cba6083598de95f6
|
|
| BLAKE2b-256 |
87eb77ed029302464634ef68ab2ba604c6c178a236d743ecdfe468cd78f47eb5
|
File details
Details for the file kwok-1.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kwok-1.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 362.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10e435ea1fce45547ddb3ce19fbebc2a5279bb5b29d163c92658720af69a6630
|
|
| MD5 |
a212cf75a184638d6775127a69d4a959
|
|
| BLAKE2b-256 |
a4e3d7e89dd3bf5526d60e80a0ceaac832d85c4446b979be166547beb1864ce4
|
File details
Details for the file kwok-1.1.5-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: kwok-1.1.5-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 39.0 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5284710f85281e24101efdfbddd5a3abf3597c449c6330ce7581cb19e9fb54ff
|
|
| MD5 |
8653e63b8d4d3c0b5386e80e212662e2
|
|
| BLAKE2b-256 |
4dd95312399fcc28c2e40c8d032d0b4ec3e98fddd6409f6c32224e045bd2128f
|
File details
Details for the file kwok-1.1.5-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: kwok-1.1.5-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 40.0 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae797aaa4a0fd69c69fc71531e7e378272ae11505bfcb5191b5a13bb481abfd5
|
|
| MD5 |
1794518cf20e6cf78e77f0a628adbc3a
|
|
| BLAKE2b-256 |
a5c5c5b4a918541ee9ea828bda21630ccbfe44bc4b8eff67b61a82d2b2c2f1e3
|
File details
Details for the file kwok-1.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kwok-1.1.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 350.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b668d4857b8817ad5f27404f8376549de78504279701a6020c518e93449626c6
|
|
| MD5 |
c104a06b57e5fafc776de88e9d27aa33
|
|
| BLAKE2b-256 |
410bd467de9175de9c43e66d81f8adbd1278bbe9c955151296cf5d54e160ff0d
|
File details
Details for the file kwok-1.1.5-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: kwok-1.1.5-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 38.4 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8939d1b8036a53a92638c4148317ecd5a12c92a9d9d56a4c8fad3a38564d8577
|
|
| MD5 |
e2d3684192d7ee212a77340a8d4faddb
|
|
| BLAKE2b-256 |
03b2ebaa7e67ded0ffbf5306800ee94510ced910f5c92bc4e58dcfe15fe5ae0a
|
File details
Details for the file kwok-1.1.5-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: kwok-1.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff8cc8f023a0cc4686d183d214abf989d62ab1c0bf411f706fb8c60cdf312f14
|
|
| MD5 |
7ca7fa8884939248af122f14ea29ba0c
|
|
| BLAKE2b-256 |
db98fb42af77fd8ff453fccfdbb624d51366be1f741cb2e0fe336763eff8d170
|
File details
Details for the file kwok-1.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kwok-1.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 338.6 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c67f243d2b60dc56de3ed0892e82a856d5941e4935efbe3ca922bbd73357466
|
|
| MD5 |
cc5e392f0aaab9d73329ad5b91018ba4
|
|
| BLAKE2b-256 |
6e38735dc8ed2e6ea19b299f382504103e6e816da3d13c505fe768b390bc3f6e
|
File details
Details for the file kwok-1.1.5-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: kwok-1.1.5-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 38.4 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
709cc6163bb837dd26dbef862ad5f029c1ef57186b333080939c52193eb52c22
|
|
| MD5 |
b5ea1e22a52a7986b97efbdbda0413a2
|
|
| BLAKE2b-256 |
5ca874851a530369aa95b3dcfdcdf83bf1329d342ccaaa12ae34d59915b72082
|
File details
Details for the file kwok-1.1.5-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: kwok-1.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
062e876410f931edda694e35bbd765be872d018b17b0e1cd128e77aa433346a6
|
|
| MD5 |
9540c5de0176e0d3c91677553e794631
|
|
| BLAKE2b-256 |
7c1f7510f4f6b6d5ea0d007e874158076d24cf6896d49859cb04d1ee4023d57c
|
File details
Details for the file kwok-1.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kwok-1.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 337.6 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f83fe67c31f50ce921bd5d527dd0c5d0fc9b34e62114e346257e826dfcbe0f06
|
|
| MD5 |
d2a12f578eed4c26587abf10f9d080db
|
|
| BLAKE2b-256 |
711f289adadca607db6e62df2f7888b7cc84c0ae3e339fde887675c8a3688958
|
File details
Details for the file kwok-1.1.5-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: kwok-1.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
794550009b8bdfd254726ee18e54384bab20889018a4d627ea2850173851270e
|
|
| MD5 |
eca0fbb569e93b194fc38a1f5e8efdf2
|
|
| BLAKE2b-256 |
eed6879013d4a3714669e7796e6963b76687bd57ea3b9584427d1f9ea29aea7a
|
File details
Details for the file kwok-1.1.5-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: kwok-1.1.5-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 40.5 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
073654d41eaca60fd87a7f56d4b5e0eb0dea863a85071ff697ad9419c8468354
|
|
| MD5 |
88c8cc7f5a03979caaf174b4606d0ff6
|
|
| BLAKE2b-256 |
e5afdef16bbb6062a8840e103f65dde3d25ba7eb483a92101fa1ef18219b8fc7
|
File details
Details for the file kwok-1.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kwok-1.1.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 342.2 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a553cb88281213d0d9bfee20c5d1ec422fb89d31f93366b8ab4b50346558535
|
|
| MD5 |
15bf67dd40cf51f30d44520cdafe80de
|
|
| BLAKE2b-256 |
d83023f0c31d36d9da895d7adb434de4b48c1c43aaf1c55a941c922a2088aa4a
|
File details
Details for the file kwok-1.1.5-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: kwok-1.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a08bfdcd10f13643e5549ac88a72eebae2f1f0aa0c4d15e6e1e1c24268d3c792
|
|
| MD5 |
617fa120db1b97518cca85bd69d1b09a
|
|
| BLAKE2b-256 |
2328d6cd5b42c8c16a190b8e6f390ef1cce9a505652ea40edde797d398a07215
|
File details
Details for the file kwok-1.1.5-cp37-cp37m-win_amd64.whl.
File metadata
- Download URL: kwok-1.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f8c73055484bafe2eae22e50af9a2866c11f24a89f78feb220d0c4fd0428c21
|
|
| MD5 |
e2dd94f814bdc32cdee4e47fd4090315
|
|
| BLAKE2b-256 |
96094eed822baba4d6d557e05c4c412ee7c47888927a4e5449d71197f9bc5806
|
File details
Details for the file kwok-1.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kwok-1.1.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 330.0 kB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02eb53532bd9bb211541839f2411ce5bd19922d8f064cdcfe0cd71de92796831
|
|
| MD5 |
d459b979c0698946684fef14b14ccac2
|
|
| BLAKE2b-256 |
205d9ca0a5fec30296fb50ffb4bf61d8484cb74cab7cabec62004e0acfe4fc23
|
File details
Details for the file kwok-1.1.5-cp36-cp36m-win_amd64.whl.
File metadata
- Download URL: kwok-1.1.5-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1585ad27a594f59ca87976000b7416445e22b47ec4085eebaa7b998d5c707f08
|
|
| MD5 |
7ef836fae778856de7dfcc3acd61bf97
|
|
| BLAKE2b-256 |
b70e115af1bfb6a53c6a3bfe7c6494ee3f08426a6acd449a2e0a3342682b4203
|
File details
Details for the file kwok-1.1.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: kwok-1.1.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 316.9 kB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f23088fc2fa15957e47d9f9f6ec0704623972457898e6108b6106d0ecd45527
|
|
| MD5 |
c79ccaac88b030a0052367aba2a2d64e
|
|
| BLAKE2b-256 |
7cf76424aca8b958dfd82bf9ed40967de11309d5923fd0830afd69f8aca3b366
|