dimod.binary.BinaryQuadraticModel.relabel_variables#
- BinaryQuadraticModel.relabel_variables(mapping, inplace=True)[source]#
Relabel the variables of a binary quadratic model.
- Parameters:
mapping – Mapping between current and new labels.
inplace – If True, the binary quadratic model is updated in-place; otherwise, a new binary quadratic model is returned.
Examples
>>> bqm = dimod.BinaryQuadraticModel({0: 1, 1: 2, 2: 3}, ... {(0, 1): 5}, ... 0, "BINARY") >>> bqm_new = bqm.relabel_variables({0: "a", 1: "b", 2: "c"}, ... inplace=False) >>> bqm_new.variables Variables(['a', 'b', 'c'])