def draw_architecture_yield(target_graph, **kwargs): """ Draws graph G according to G's family layout and highlights faulty qubits. """ family = target_graph.graph['family'] try: m = target_graph.graph['columns'] n = target_graph.graph['rows'] t = target_graph.graph['tile'] coordinates = target_graph.graph['labels'] == 'coordinate' except: raise ValueError("Target graph needs to have columns, rows, and tile \ attributes to identify faulty qubits.") if family == 'chimera': dnx.draw_chimera_yield(target_graph, **kwargs) elif family == 'pegasus': dnx.draw_pegasus_yield(target_graph, **kwargs) else: nx.draw_spring(target_graph) warnings.warn( "Graph family not available. Using NetworkX spring layout")
def yield_double_plot(P, filename): fig = plt.figure(figsize=(40, 20)) axes = fig.subplots(nrows=1, ncols=2) dnx.draw_pegasus_yield(P, node_size=80, ax=axes[0]) dnx.draw_pegasus(P, crosses=True, node_size=80, node_color="#f37820", edge_color="#17bebb", ax=axes[1]) fig.tight_layout() plt.savefig(filename) plt.close()
# Copyright 2020 D-Wave Systems Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from pegasus_graph import P6 import dwave_networkx as dnx import matplotlib try: import matplotlib.pyplot as plt except ImportError: matplotlib.use("agg") import matplotlib.pyplot as plt dnx.draw_pegasus_yield(P6, node_size=80) dnx.draw_pegasus(P6, node_size=80)
def test_draw_pegasus_yield(self): G = dnx.pegasus_graph(3, data=False) G.remove_edges_from([(5, 104), (12, 96), (23, 112)]) G.remove_nodes_from([109, 139]) dnx.draw_pegasus_yield(G)