Py Bipartite Matching¶
Algorithms for Enumerating All Perfect, Maximum and Maximal Matchings in Bipartite Graphs.
Algorithm described in “Algorithms for Enumerating All Perfect, Maximum and Maximal Matchings in Bipartite Graphs” By Takeaki Uno in “Algorithms and Computation: 8th International Symposium, ISAAC ‘97 Singapore, December 17-19, 1997 Proceedings” See http://dx.doi.org/10.1007/3-540-63890-3_11
Free software: MIT license
Documentation: https://py-bipartite-matching.readthedocs.io.
Features¶
- Functions available:
enum_perfect_matchings
enum_maximum_matchings
usage¶
To use Py Bipartite Matching in a project the networkx package is needed as well
>>> import py_bipartite_matching as pbm
>>> import networkx as nx
Use enum_perfect_matchings to enumerate all perfect matchings
>>> n = 2
>>> graph = nx.complete_bipartite_graph(n, n, nx.Graph)
>>> for matching in pbm.enum_perfect_matchings(graph):
>>> print(matching)
{0: 2, 1: 3}
{0: 3, 1: 2}
Use enum_maximum_matchings to enumerate all maximum matchings
>>> n = 2
>>> m = 3
>>> graph = nx.complete_bipartite_graph(n, m, nx.Graph)
>>> for matching in enum_maximum_matchings(graph):
>>> print(matching)
{0: 3, 1: 4}
{0: 4, 1: 3}
{0: 3, 2: 4}
{1: 3, 2: 4}
{0: 4, 2: 3}
{2: 3, 1: 4}
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.