示例#1
0
def draw_chimera(G, **kwargs):
    """Draws graph G in a Chimera cross topology.
    If `linear_biases` and/or `quadratic_biases` are provided, these
    are visualized on the plot.
    Parameters
    ----------
    G : NetworkX graph
        Should be a Chimera graph or a subgraph of a Chimera graph.
    linear_biases : dict (optional, default {})
        A dict of biases associated with each node in G. Should be of
        form {node: bias, ...}. Each bias should be numeric.
    quadratic_biases : dict (optional, default {})
        A dict of biases associated with each edge in G. Should be of
        form {edge: bias, ...}. Each bias should be numeric. Self-loop
        edges (i.e., :math:`i=j`) are treated as linear biases.
    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.
    Examples
    --------
    >>> # Plot 2x2 Chimera unit cells
    >>> import networkx as nx
    >>> import dwave_networkx as dnx
    >>> import matplotlib.pyplot as plt  # doctest: +SKIP
    >>> G = dnx.chimera_graph(2, 2, 4)
    >>> dnx.draw_chimera(G)  # doctest: +SKIP
    >>> plt.show()  # doctest: +SKIP
    """
    draw_qubit_graph(G, chimera_layout(G), **kwargs)
示例#2
0
def draw_pegasus(G, crosses=False, **kwargs):
    """Draws graph G in a Pegasus topology.

    If ``linear_biases`` and/or ``quadratic_biases`` are provided, these
    are visualized on the plot.

    Parameters
    ----------
    G : NetworkX graph
        A Pegasus graph or a subgraph of a Pegasus graph, as produced by
        the :func:`dwave_networkx.pegasus_graph` function.

    linear_biases : dict (optional, default {})
        Biases as a dict, of form {node: bias, ...}, where keys are
        nodes in G and biases are numeric.

    quadratic_biases : dict (optional, default {})
        Biases as a dict, of form {edge: bias, ...}, where keys are
        edges in G and biases are numeric. Self-loop
        edges (i.e., :math:`i=j`) are treated as linear biases.

    crosses: boolean (optional, default False)
        If True, :math:`K_{4,4}` subgraphs are shown in a cross
        rather than L configuration. Ignored if G is defined with
        ``nice_coordinates=True``.

    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.

    Examples
    --------
        This example plots a Pegasus graph with size parameter 2.

    >>> import networkx as nx
    >>> import dwave_networkx as dnx
    >>> import matplotlib.pyplot as plt   # doctest: +SKIP
    >>> G = dnx.pegasus_graph(2)
    >>> dnx.draw_pegasus(G)    # doctest: +SKIP
    >>> plt.show()    # doctest: +SKIP

    """

    draw_qubit_graph(G, pegasus_layout(G, crosses=crosses), **kwargs)
示例#3
0
def draw_pegasus(G, crosses=False, **kwargs):
    """Draws graph G in a Pegasus topology.

    If `linear_biases` and/or `quadratic_biases` are provided, these
    are visualized on the plot.

    Parameters
    ----------
    G : NetworkX graph
        Should be a Pegasus graph or a subgraph of a Pegasus graph,
        a product of dwave_networkx.pegasus_graph.

    linear_biases : dict (optional, default {})
        A dict of biases associated with each node in G. Should be of
        form {node: bias, ...}. Each bias should be numeric.

    quadratic_biases : dict (optional, default {})
        A dict of biases associated with each edge in G. Should be of
        form {edge: bias, ...}. Each bias should be numeric. Self-loop
        edges (i.e., :math:`i=j`) are treated as linear biases.

    crosses: boolean (optional, default False)
        If crosses is True, K_4,4 subgraphs are shown in a cross
        rather than L configuration. Ignored if G was defined with
        nice_coordinates=True.

    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.

    Examples
    --------
    >>> # Plot a Pegasus graph with size parameter 2
    >>> import networkx as nx
    >>> import dwave_networkx as dnx
    >>> import matplotlib.pyplot as plt
    >>> G = dnx.pegasus_graph(2)
    >>> dnx.draw_pegasus(G)
    >>> plt.show()

    """

    draw_qubit_graph(G, pegasus_layout(G, crosses=crosses), **kwargs)
def draw_zephyr(G, **kwargs):
    """Draws graph G in a Zephyr topology.

    If ``linear_biases`` and/or ``quadratic_biases`` are provided, these
    are visualized on the plot.

    Parameters
    ----------
    G : NetworkX graph
        A Zephyr graph or a subgraph of a Zephyr graph, as produced by
        the :func:`dwave_networkx.zephyr_graph` function.

    linear_biases : dict (optional, default {})
        Biases as a dict, of form {node: bias, ...}, where keys are
        nodes in G and biases are numeric.

    quadratic_biases : dict (optional, default {})
        Biases as a dict, of form {edge: bias, ...}, where keys are
        edges in G and biases are numeric. Self-loop
        edges (i.e., :math:`i=j`) are treated as linear biases.

    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.

    Examples
    --------
    This example plots a Zephyr graph with size parameter 2.

    >>> import networkx as nx
    >>> import dwave_networkx as dnx
    >>> import matplotlib.pyplot as plt   # doctest: +SKIP
    >>> G = dnx.zephyr_graph(2)
    >>> dnx.draw_zephyr(G)    # doctest: +SKIP
    >>> plt.show()    # doctest: +SKIP

    """

    draw_qubit_graph(G, zephyr_layout(G), **kwargs)