Skip to main content

Implementation of the Hungarian Algorithm for optimal matching in bipartite weighted graphs.

Project description

A Python 3 implementation of the Hungarian Algorithm for optimal matching in bipartite weighted graphs.

Based on the graph theory implementation in [these notes](http://www.cse.ust.hk/~golin/COMP572/Notes/Matching.pdf) combined with the matrix interpretation in [these notes](https://montoya.econ.ubc.ca/Econ514/hungarian.pdf).

For a detailed overview, see [this Jupyter notebook](https://github.com/jbrightuniverse/Hungarian-Algorithm-No.-5/blob/main/HungarianAlgorithm.ipynb).

# Usage

Installation: pip3 install hungarianalg

Import: from hungarianalg.alg import hungarian

Function call: result = hungarian(matrix)

Properties: - Optimal Matching: result.match - Revenues: result.revenues - Row Weights: result.row_weights - Col Weights: result.col_weights - Total Revenue: result.revenue_sum

See example.py for a comprehensive example.

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

hungarianalg-0.0.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

hungarianalg-0.0.1-py3-none-any.whl (4.6 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