dwave_networkx.algorithms.matching.is_matching¶
-
is_matching
(edges)[source]¶ Determines whether the given set of edges is a matching.
A matching is a subset of edges in which no node occurs more than once.
Parameters: edges (iterable) – A iterable of edges. Returns: is_matching – True if the given edges are a matching. Return type: bool Example
This example checks two sets of edges, both derived from a single Chimera unit cell, for a matching. Because every node in a Chimera unit cell connects to four other nodes in the cell, the first set, which contains all the edges, repeats each node 4 times; the second is a subset of those edges found using the min_maximal_matching() function.
>>> import dwave_networkx as dnx >>> G = dnx.chimera_graph(1, 1, 4) >>> dnx.is_matching(G.edges()) False >>> dnx.is_matching({(0, 4), (1, 5), (2, 7), (3, 6)}) True