import networkx as nx def qubo_to_nx_graph(qubo): graph = nx.Graph() for coupler, energy in qubo.items(): if coupler[0] != coupler[1]: graph.add_edge(coupler[0], coupler[1], weight=energy) return graph def negate_qubo(qubo): negative_qubo = {} for coupler, energy in qubo.items(): negative_qubo[coupler] = -1 * energy return negative_qubo def create_qpu_solver_nxgraph(solver): graph = nx.Graph() graph.name = solver.id graph.add_edges_from(solver.edges) return graph