hybrid.utils.select_random_subgraph

select_random_subgraph(bqm, n)[source]

Select randomly n variables of the specified binary quadratic model.

Parameters:
Returns:

n variables selected randomly from the BQM.

Return type:

list

Examples

This example returns 2 variables of a 4-variable BQM.

>>> import dimod
>>> bqm = dimod.BQM({}, {'ab': 0, 'bc': 1, 'cd': 2}, 0, 'BINARY')
>>> select_random_subgraph(bqm, 2)      # doctest: +SKIP
['d', 'b']