dwave.embedding.chain_break_frequency#

chain_break_frequency(samples_like, embedding)[source]#

Determine the frequency of chain breaks in the given samples.

Parameters:
Returns:

Frequency of chain breaks as a dict in the form {s: f, ...}, where s is a variable in the source graph and float f the fraction of broken chains.

Return type:

dict

Examples

This example embeds a single source node, \(a\), as a chain of two target nodes \((0, 1)\) and uses chain_break_frequency() to show that out of two synthetic samples, \([-1, +1]\) represents a broken chain.

>>> import numpy as np
...
>>> samples = np.array([[-1, +1], [+1, +1]])
>>> embedding = {'a': {0, 1}}
>>> print(dwave.embedding.chain_break_frequency(samples, embedding)['a'])
0.5