dimod.QuadraticModel.iter_neighborhood#
- QuadraticModel.iter_neighborhood(v: Hashable) Iterator[tuple[Hashable, float | floating | integer]] [source]#
Iterate over the neighbors and quadratic biases of a variable.
- Parameters:
v – Variable in the quadratic model.
- Returns:
Neighbors of the specified variable and their quadratic 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_neighborhood('x')) [('y', -2.0), ('z', 2.0)]