def draw_pegasus_yield(G, **kwargs): """Draws the given graph G with highlighted faults, according to layout. Parameters ---------- G : NetworkX graph The graph to be parsed for faults unused_color : tuple or color string (optional, default (0.9,0.9,0.9,1.0)) The color to use for nodes and edges of G which are not faults. If unused_color is None, these nodes and edges will not be shown at all. fault_color : tuple or color string (optional, default (1.0,0.0,0.0,1.0)) A color to represent nodes absent from the graph G. Colors should be length-4 tuples of floats between 0 and 1 inclusive. fault_shape : string, optional (default='x') The shape of the fault nodes. Specification is as matplotlib.scatter marker, one of 'so^>v<dph8'. fault_style : string, optional (default='dashed') Edge fault line style (solid|dashed|dotted,dashdot) kwargs : optional keywords See networkx.draw_networkx() for a description of optional keywords, with the exception of the `pos` parameter which is not used by this function. If `linear_biases` or `quadratic_biases` are provided, any provided `node_color` or `edge_color` arguments are ignored. """ try: assert (G.graph["family"] == "pegasus") m = G.graph['columns'] offset_lists = (G.graph['vertical_offsets'], G.graph['horizontal_offsets']) coordinates = G.graph["labels"] == "coordinate" # Can't interpret fabric_only from graph attributes except: raise ValueError("Target pegasus graph needs to have columns, rows, \ tile, and label attributes to be able to identify faulty qubits.") perfect_graph = pegasus_graph(m, offset_lists=offset_lists, coordinates=coordinates) draw_yield(G, pegasus_layout(perfect_graph), perfect_graph, **kwargs)
def draw_zephyr_yield(G, **kwargs): """Draws the given graph G with highlighted faults, according to layout. Parameters ---------- G : NetworkX graph Graph to be parsed for faults. unused_color : tuple or color string (optional, default (0.9,0.9,0.9,1.0)) The color to use for nodes and edges of G which are not faults. If unused_color is None, these nodes and edges will not be shown at all. fault_color : tuple or color string (optional, default (1.0,0.0,0.0,1.0)) A color to represent nodes absent from the graph G. Colors should be length-4 tuples of floats between 0 and 1 inclusive. fault_shape : string, optional (default='x') The shape of the fault nodes. Specification is as for `Matplotlib's markers <https://matplotlib.org/stable/api/markers_api.html#module-matplotlib.markers>`_; for example "o" (circle), "^" (triangle)", "s" (square) and many more options. fault_style : string, optional (default='dashed') Edge fault line style (solid|dashed|dotted|dashdot) kwargs : optional keywords See :func:`~networkx.drawing.nx_pylab.draw_networkx` for a description of optional keywords, with the exception of the ``pos`` parameter, which is unsupported. If the ``linear_biases`` or ``quadratic_biases`` parameters are provided, any provided ``node_color`` or ``edge_color`` arguments are ignored. """ try: assert (G.graph["family"] == "zephyr") m = G.graph['columns'] t = G.graph['tile'] coordinates = G.graph["labels"] == "coordinate" except: raise ValueError("Target zephyr graph needs to have columns, rows, \ tile, and label attributes to be able to identify faulty qubits.") perfect_graph = zephyr_graph(m, t, coordinates=coordinates) draw_yield(G, zephyr_layout(perfect_graph), perfect_graph, **kwargs)