dimod.QuadraticModel.iter_quadratic#

QuadraticModel.iter_quadratic() Iterator[Tuple[Hashable, Hashable, float | floating | integer]][source]#

Iterate over the interactions of a quadratic model.

Returns:

Interactions of the quadratic model and their biases.

Examples

>>> from dimod import QuadraticModel
>>> qm = QuadraticModel()
>>> qm.add_variables_from('BINARY', ['x', 'y', 'z'])
>>> qm.add_quadratic('x', 'y', -2)
>>> qm.add_quadratic('x', 'z', 2)
>>> list(qm.iter_quadratic())
[('y', 'x', -2.0), ('z', 'x', 2.0)]