hybrid.utils.bqm_edges_between_variables

bqm_edges_between_variables(bqm, variables)[source]

Return edges connecting specified variables of a binary quadratic model.

Parameters:
Returns:

All edges connecting variables as tuples plus the variables themselves as tuples (v, v).

Return type:

list

Examples

This example returns connecting edges between 3 nodes of a BQM based on a 4-variable path graph.

>>> import dimod
>>> bqm = dimod.BQM({}, {(0, 1): 1, (1, 2): 1, (2, 3): 1}, 0, 'BINARY')
>>> bqm_edges_between_variables(bqm, {0, 1, 3})
[(0, 1), (0, 0), (1, 1), (3, 3)]