From 553581ca37ef2a390cff0cadd464a35f0c139548 Mon Sep 17 00:00:00 2001 From: Kelly Boothby Date: Wed, 25 Jan 2023 13:48:41 -0800 Subject: [PATCH] doc review; improved references and added generic plotting docs --- docs/reference/drawing.rst | 18 ++++++++++++++++-- dwave_networkx/drawing/chimera_layout.py | 4 ++-- dwave_networkx/drawing/pegasus_layout.py | 4 ++-- dwave_networkx/drawing/qubit_layout.py | 4 ++-- dwave_networkx/drawing/zephyr_layout.py | 8 ++++---- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/docs/reference/drawing.rst b/docs/reference/drawing.rst index 1434d36a..fc6862a3 100644 --- a/docs/reference/drawing.rst +++ b/docs/reference/drawing.rst @@ -21,6 +21,7 @@ Chimera Graph Functions chimera_layout draw_chimera + chimera_node_placer_2d Example ~~~~~~~ @@ -89,8 +90,6 @@ of nodes of a simple 5-node graph on a small Pegasus lattice. edge_list=[(4, 40), (4, 41), (4, 42), (4, 43)]) >>> # Show graph H on a small Pegasus lattice >>> plt.ion() - >>> # Show graph H on a small Pegasus lattice - >>> plt.ion() >>> dnx.draw_pegasus(G, with_labels=True, crosses=True, node_color="Yellow") >>> dnx.draw_pegasus(H, crosses=True, node_color='b', style='dashed', edge_color='b', width=3) @@ -141,3 +140,18 @@ of a five-node clique on a small Zephyr graph. :alt: Five-node clique embedded in a small Zephyr graph. Five-node clique embedded in a small Zephyr graph. + + +Generic Plotting Functions +-------------------------- + +.. automodule:: dwave_networkx.drawing.qubit_layout + +.. autosummary:: + :toctree: generated/ + + draw_qubit_graph + draw_embedding + draw_yield + normalize_size_and_aspect + draw_lineplot diff --git a/dwave_networkx/drawing/chimera_layout.py b/dwave_networkx/drawing/chimera_layout.py index 206d1756..b0b09278 100644 --- a/dwave_networkx/drawing/chimera_layout.py +++ b/dwave_networkx/drawing/chimera_layout.py @@ -53,7 +53,7 @@ def chimera_layout(G, scale=1., center=None, dim=2, plot_kwargs=None): plot_kwargs : None or dict (default None) A dict of keyword arguments to be used in a plotting function (see - :func:`networkx.draw` and :func:`draw_lineplot`), to scale node and edge + :func:`networkx.drawing.nx_pylab.draw` and :func:`draw_lineplot`), to scale node and edge sizes appropriately to the graph `G`. Optional keys in ``plot_kwargs`` are set to default values by the :func:`normalize_size_and_aspect` function. Do nothing if ``plot_kwargs`` is None. @@ -140,7 +140,7 @@ def chimera_node_placer_2d(m, n, t, scale=1., center=None, dim=2, plot_kwargs=No plot_kwargs : None or dict (default None) A dict of keyword arguments to be used in a plotting function (see - :func:`networkx.draw` and :func:`draw_lineplot`), to scale node and edge + :func:`networkx.drawing.nx_pylab.draw` and :func:`draw_lineplot`), to scale node and edge sizes appropriately to the graph `G`. Optional keys in ``plot_kwargs`` are set to default values by the :func:`normalize_size_and_aspect` function. Do nothing if ``plot_kwargs`` is None. diff --git a/dwave_networkx/drawing/pegasus_layout.py b/dwave_networkx/drawing/pegasus_layout.py index 69b29123..a2825e48 100644 --- a/dwave_networkx/drawing/pegasus_layout.py +++ b/dwave_networkx/drawing/pegasus_layout.py @@ -60,7 +60,7 @@ def pegasus_layout(G, scale=1., center=None, dim=2, crosses=False, plot_kwargs=N plot_kwargs : None or dict (default None) A dict of keyword arguments to be used in a plotting function (see - :func:`networkx.draw` and :func:`draw_lineplot`), to scale node and edge + :func:`networkx.drawing.nx_pylab.draw` and :func:`draw_lineplot`), to scale node and edge sizes appropriately to the graph `G`. Optional keys in ``plot_kwargs`` are set to default values by the :func:`normalize_size_and_aspect` function. Do nothing if ``plot_kwargs`` is None. @@ -131,7 +131,7 @@ def pegasus_node_placer_2d(G, scale=1., center=None, dim=2, crosses=False, plot_ plot_kwargs : None or dict (default None) A dict of keyword arguments to be used in a plotting function (see - :func:`networkx.draw` and :func:`draw_lineplot`), to scale node and edge + :func:`networkx.drawing.nx_pylab.draw` and :func:`draw_lineplot`), to scale node and edge sizes appropriately to the graph `G`. Optional keys in ``plot_kwargs`` are set to default values by the :func:`normalize_size_and_aspect` function. Do nothing if ``plot_kwargs`` is None. diff --git a/dwave_networkx/drawing/qubit_layout.py b/dwave_networkx/drawing/qubit_layout.py index 73752968..da18c22c 100644 --- a/dwave_networkx/drawing/qubit_layout.py +++ b/dwave_networkx/drawing/qubit_layout.py @@ -27,7 +27,7 @@ from numbers import Number -__all__ = ['draw_qubit_graph'] +__all__ = ['draw_qubit_graph', 'draw_embedding', 'draw_yield', 'normalize_size_and_aspect', 'draw_lineplot'] def draw_qubit_graph(G, layout, linear_biases={}, quadratic_biases={}, @@ -637,7 +637,7 @@ def draw_lineplot(G, layout, *, ax, node_size, width, nodelist=None, edge_vmin=None, edge_vmax=None, z_offset=0): """Draws the graph G with line segments representing nodes. - This function is meant to be a drop-in replacement for :func:`networkx.draw` + This function is meant to be a drop-in replacement for :func:`networkx.drawing.nx_pylab.draw` where nodes are associated with line segments (specified as 2x2 matrices [[x0, y0], [x1, y1]]). This function makes significant assumptions about the edges of the graph G, that hold when G is a Chimera, Pegasus, or Zephyr diff --git a/dwave_networkx/drawing/zephyr_layout.py b/dwave_networkx/drawing/zephyr_layout.py index 5f1ce4c1..5262b1b8 100644 --- a/dwave_networkx/drawing/zephyr_layout.py +++ b/dwave_networkx/drawing/zephyr_layout.py @@ -54,9 +54,9 @@ def zephyr_layout(G, scale=1., center=None, dim=2, plot_kwargs=None): plot_kwargs : None or dict (default None) A dict of keyword arguments to be used in a plotting function (see - :func:`networkx.draw` and :func:`draw_lineplot`), to scale node and edge + :func:`networkx.drawing.nx_pylab.draw` and :func:`draw_lineplot`), to scale node and edge sizes appropriately to the graph `G`. Optional keys in ``plot_kwargs`` - are set to default values by the :func:`normalize_size_and_aspect` + are set to default values by the :func:`~dwave_networkx.drawing.qubit_layout.normalize_size_and_aspect` function. Do nothing if ``plot_kwargs`` is None. Returns @@ -113,9 +113,9 @@ def zephyr_node_placer_2d(G, scale=1., center=None, dim=2, plot_kwargs=None): plot_kwargs : None or dict (default None) A dict of keyword arguments to be used in a plotting function (see - :func:`networkx.draw` and :func:`draw_lineplot`), to scale node and edge + :func:`networkx.drawing.nx_pylab.draw` and :func:`draw_lineplot`), to scale node and edge sizes appropriately to the graph `G`. Optional keys in ``plot_kwargs`` - are set to default values by the :func:`normalize_size_and_aspect` + are set to default values by the :func:`~dwave_networkx.drawing.qubit_layout.normalize_size_and_aspect` function. Do nothing if ``plot_kwargs`` is None. Returns