dimod.binary.BinaryQuadraticModel.relabel_variables_as_integers#

BinaryQuadraticModel.relabel_variables_as_integers(inplace=True)[source]#

Relabel to consecutive integers the variables of a binary quadratic model.

Parameters:

inplace – If True, the binary quadratic model is updated in-place; otherwise, a new binary quadratic model is returned.

Examples

>>> bqm = dimod.BinaryQuadraticModel({"a": 1, "b": 2},{"ab": -1}, 0, "BINARY")
>>> _, mapping = bqm.relabel_variables_as_integers()
>>> print(bqm.quadratic)
{(1, 0): -1.0}