hopcroft_karp_matching(G, top_nodes=None)
A matching is a set of edges that do not share any nodes. A maximum cardinality matching is a matching with the most edges possible. It is not always unique. Finding a matching in a bipartite graph can be treated as a networkx flow problem.
The functions hopcroft_karp_matching
and maximum_matching
are aliases of the same function.
This function is implemented with the :None:None:`Hopcroft--Karp matching algorithm
<https://en.wikipedia.org/wiki/Hopcroft%E2%80%93Karp_algorithm>`
for bipartite graphs.
See bipartite documentation <networkx.algorithms.bipartite>
for further details on how bipartite graphs are handled in NetworkX.
Undirected bipartite graph
Container with all nodes in one bipartite node set. If not supplied it will be computed. But if more than one solution exists an exception will be raised.
Raised if the input bipartite graph is disconnected and no container with all nodes in one bipartite set is provided. When determining the nodes in each bipartite set more than one valid solution is possible if the input graph is disconnected.
The matching is returned as a dictionary, :None:None:`matches`
, such that matches[v] == w
if node :None:None:`v`
is matched to node :None:None:`w`
. Unmatched nodes do not occur as a key in :None:None:`matches`
.
Returns the maximum cardinality matching of the bipartite graph G
.
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.bipartite.matching.hopcroft_karp_matching
networkx.algorithms.bipartite.matching.eppstein_matching
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them