hybrid.utils.bqm_edges_between_variables#
- bqm_edges_between_variables(bqm, variables)[source]#
Return edges connecting specified variables of a binary quadratic model.
- Parameters:
bqm (
dimod.BinaryQuadraticModel
) – Binary quadratic model (BQM).variables (list/set) – Subset of variables in the BQM.
- Returns:
All edges connecting variables as tuples plus the variables themselves as tuples (v, v).
- Return type:
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') >>> edges = bqm_edges_between_variables(bqm, {0, 1, 3}) >>> edges [(0, 1), (0, 0), (1, 1), (3, 3)] # note: order not defined