dimod.binary.BinaryQuadraticModel.iter_neighborhood#

BinaryQuadraticModel.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 binary quadratic model.

Examples

>>> bqm = dimod.BinaryQuadraticModel({},
...                 {(0, 1): -1, (1, 2): -2, (2, 3): -3},
...                 "BINARY")
>>> list(bqm.iter_neighborhood(1))
[(0, -1.0), (2, -2.0)]