chain_break_frequency(samples_like, embedding)[source]

Determine the frequency of chain breaks in the given samples.

  • samples_like (samples_like/dimod.SampleSet) – A collection of raw samples. ‘samples_like’ is an extension of NumPy’s array_like. See dimod.as_samples().

  • embedding (dict) – Mapping from source graph to target graph as a dict of form {s: {t, …}, …}, where s is a source-model variable and t is a target-model variable.


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



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, one ([-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'])