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.7.tar.gz (82.4 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.7-cp313-cp313-win_amd64.whl (41.3 kB view details)

Uploaded CPython 3.13Windows x86-64

kwok-1.1.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (369.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

kwok-1.1.7-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.7-cp312-cp312-macosx_11_0_arm64.whl (40.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

kwok-1.1.7-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.7-cp311-cp311-macosx_11_0_arm64.whl (39.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

kwok-1.1.7-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.7-cp310-cp310-macosx_11_0_arm64.whl (39.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

kwok-1.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (346.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.9macOS 11.0+ ARM64

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

Uploaded CPython 3.8Windows x86-64

kwok-1.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (347.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.8macOS 11.0+ ARM64

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

Uploaded CPython 3.7mWindows x86-64

kwok-1.1.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (330.3 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.6mWindows x86-64

kwok-1.1.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (319.2 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: kwok-1.1.7.tar.gz
  • Upload date:
  • Size: 82.4 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.7.tar.gz
Algorithm Hash digest
SHA256 6bf0de93325b1b434baa3d671261946e679f71042064e7071fe80532652def02
MD5 8bddb00f6cc10537feaf25ca4f543959
BLAKE2b-256 7499cc164cce254c55cc8690fead0688a67ece827d31723eb14d5337f995f81e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 41.3 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.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 62e5b8970146da316971b7870e30d003ca3c512d0735450010951db591560d7f
MD5 dd8ec6d24150981496d8e3215a7db90f
BLAKE2b-256 fe88001888524b58b7f4ce240edfed4493976550a4e44ad2ea6d81a7cb6c4c43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a5ff179a027b13da35931c851e4efda2d573e86c1d618985d55986d4553079a9
MD5 480aaf8688389d2b8442b8880592fb52
BLAKE2b-256 2c6b89ff86edf45fc5ac0fdd071832c3c1f518b11ed8d2f3ebc91b44d9c10325

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e877c44afa30dff76b3dc4d573e825d017833a284ae8e800ed4549152287226a
MD5 8a04a1e3208a7808fd7f66580a7b787c
BLAKE2b-256 d52b6f93482eccb5e5d46ced889e258a85ed1591cb24d9af4f2abf4ad44463e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 993ef3516a473c98e485c70c7d79bc4eeedd0be8ebb19202cdf90ac6cc437962
MD5 c86d2a43e039c8267a62c914f0d5d4db
BLAKE2b-256 13d8a129e9cce6969d503cd3225228860e5a0d584bf112f9d4337cde8bf017f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fd142a3eacc3045547a5d2d0dd903639a6fb58d86238b2ec8b8de4e1d0e2fd2e
MD5 b7da13f647030dcaddb5554971cbbede
BLAKE2b-256 04d3f44349d56b8c9814fce9258ed32b3880a49a63b7502003c1ce4ad087b87f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 573e364eaa5b5d0e0f0356d1e1689312ba640cdb3631e269a3594d1b8db64456
MD5 1106e70594272d41dd5355bab4ea5d7e
BLAKE2b-256 eb31a3331b36d284d53cd55de3d1dbad3ad88dc2dbee41a44504b4e00c0a9fe1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 921df2c9dd383530637fbb5085aa59cbe5185a6337af9ecb7f7691619c8ec6a8
MD5 85b3d7393fe363b6dd058b7c97cd8da1
BLAKE2b-256 7f5371f85357f59c13052b269d1241a83a44f8f7bb102cc3be1c550ba2719dcd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 631834456cbe4c6fea225c804f93ac0c5040c4dfdd4532aa83d8814ef10788ed
MD5 e2b6ea1383e0b929e34e4d2e20a26568
BLAKE2b-256 fad94b62b14434b4ebf0f1f9080120ec790e9094bbb809c8df97f80fc0052239

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 180dfd9ab80a7f7b5bb163bdb8c0bbcad259a6e47fa317b0ed4820582035b482
MD5 ae613fb397a540618718a90cf7ed9c65
BLAKE2b-256 14301cf621748e69df4896e4010dcc5c13bb19d8c082af691b5c4a4a9003814f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6c88f4b5df4ab68616862e9a8237efa196022d1c1361c0b47f505f8e199524bc
MD5 67ea6af7f5cebcb4f7c4187f752e8d5d
BLAKE2b-256 740aa4383f4c322806434fd2fbf67fc6488302b8446a4865d632eac511250df9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a05286bb69f458d4f7c640039f848511e38ee53839a8cf3bc1c345073620998
MD5 cf9ea17fe54a68071642d2a72e5e60d6
BLAKE2b-256 21af4ca7a41917a6171f609488e0b94da854a0f9c82dfeeebd93077974b99440

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 773b927e971d88d45782a51551b450950f61156ebfacbcce140fd3106b259596
MD5 bde2f2c190fa0568607c7b65ca16ca89
BLAKE2b-256 c372bb9fac04428b5972aaa53ec87ed6b8981caab04cdace33fce6482dcde42a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5500fa8d308b77ec734b8170c4779464a881202673a4fcbfc8756248ed105610
MD5 7beaea923e07ecc734dc94875685d05d
BLAKE2b-256 2933e76363980497a9c469e9e5c03bb5ec4b7b928e57170169167f280f17e5a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8c98b2a09071bf6ba16903b2ffb4dc83336432b7b29f6685908c17372ae77cbb
MD5 1e9f77244e2e73cc0e59633358a1f4a9
BLAKE2b-256 291e470d7977cf5916baf4d041d79f08040f65323544a1726679c0f9896cca49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e29a2b9c6b68aa6c3b581d8aff6084be80250081cedf23b3917ea4cc815b802
MD5 765b46b14428887f8ba9f554f1a558bf
BLAKE2b-256 ec9fcf68fcb8f9adb796391946d48341efff867464eee6dbcc13ddd9ad0311a9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 747786b513e54df0674ebb064098d0c84b433461076f4d2d2dd9ee7f2f3b697e
MD5 56195af8560180f42a4fff315209e105
BLAKE2b-256 2669573e63e3a31cbf1d446abee2f81634d462446094508a8ce51f696333fcde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2620926e98f855c53222a946a40ce8c0233383adede7fb0590a89a1308b9f5ea
MD5 76e165d3ed42d38b1473005d5900703f
BLAKE2b-256 ce8f664bc3b2d35ac05877ff1a53ef89c27ca3dfd1137b69f08ec7a059a09f26

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 43e788c914dec91091e5470cb8948b375f7b1f7be1da85af57244d0ca4a50971
MD5 5da2066d952244b6a9d6ef68ff04d24c
BLAKE2b-256 88c372714c8faebf79c6900552beeb3592b6548ceaa769ff6d5f260cd57dd63b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 bfe15dc7b2e8691a7df0f2c923242172bfe72d995531bea699de800de4b63ea3
MD5 ce7719d729e91a812bc58de7d2460954
BLAKE2b-256 3f3b559392f8b56ba22df0ed410fb9d84ae10833f23013e87ee1f448a280c2e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 354ed18b1b58e06f68745547b411045815e7af1700c1b4c5467638935cf4ab21
MD5 1e5db01326ad3880a21e26da1dd17711
BLAKE2b-256 d2887b45f480519be5ede46e5451f690265531c6ccd86b269edc5e306485ae4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kwok-1.1.7-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.7-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c0a991965c4d0a272c05c6e42cf86cc5ced8940be477f640b898cb4c9c0f9188
MD5 3058bd1dbbda8081697604fa9ce557d4
BLAKE2b-256 67f72c56b5ab9d7c45a4dc7f3ee47e51f359951ad1e3b759241f8578184c9273

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kwok-1.1.7-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 601d4dade5bc8e171b3ba94884983858a6b4244ffbd4d3a515b734b3746290d6
MD5 bd43dd1a2adb9c198739fbba7dc1cc2f
BLAKE2b-256 2433bc8af441c2264b190972519484ef90e3b8479caf7bab1243bd0f28075c3f

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