dwavesystems / dwave-networkx

D-Wave Systems extension of the NetworkX Python package for graphs and graph algorithms.
https://docs.ocean.dwavesys.com/projects/dwave-networkx/en/latest
Apache License 2.0
89 stars 56 forks source link

draw_topology functions error when linear xor quadratic biases is provided #232

Open kevinchern opened 10 months ago

kevinchern commented 10 months ago

Description draw_topology functions, e.g., draw_pegasus, errors when you supply linear biases and not quadratic biases (vice versa too)

To Reproduce

import dwave_networkx as dnx
G = dnx.pegasus_graph(3)
# This case works as expected
dnx.draw_pegasus(G,  linear_biases={117:-1}, quadratic_biases={(128, 130): -1})
# This case errors out
try:
    dnx.draw_pegasus(G, quadratic_biases={(128, 130): -1})
except Exception as e:
    print(e)
# This case errors out
try:
    dnx.draw_pegasus(G, linear_biases={117:-1})
except Exception as e:
    print(e)

Additional context Culprit: https://github.com/dwavesystems/dwave-networkx/blob/0.8.14/dwave_networkx/drawing/qubit_layout.py#L117C1-L120