aryagraph.algorithms.matching.bipartite_maximum_matching#
- aryagraph.algorithms.matching.bipartite_maximum_matching(g: Graph, top_nodes: Iterable[Hashable] | None = None) dict[Hashable, Hashable]#
Maximum-cardinality matching of a bipartite graph (Hopcroft–Karp, O(m·√n)).
- Parameters:
top_nodes – The nodes of one side. Every edge must join a top node to a non-top node (
GraphTypeErrorotherwise). If omitted, sides come fromaryagraph.algorithms.coloring.bipartite_sets(); the matching size does not depend on which side is called “top”.- Returns:
dict –
{u: v, v: u, …}: each matched pair in both directions, in graph order.