networkx.algorithms.matching.is_perfect_matching¶
- is_perfect_matching(G, matching)[source]¶
Return True if
matchingis a perfect matching forGA perfect matching in a graph is a matching in which exactly one edge is incident upon each vertex.
- Parameters
- GNetworkX graph
- matchingdict or set
A dictionary or set representing a matching. If a dictionary, it must have
matching[u] == vandmatching[v] == ufor each edge(u, v)in the matching. If a set, it must have elements of the form(u, v), where(u, v)is an edge in the matching.
- Returns
- bool
Whether the given set or dictionary represents a valid perfect matching in the graph.