Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout overhaul #214

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Layout overhaul #214

wants to merge 7 commits into from

Conversation

boothby
Copy link
Contributor

@boothby boothby commented Dec 7, 2021

Normalizes node sizes across the board
Makes yield plots easier to read
Adds qubit-line plots

needs a little more documentation

@boothby
Copy link
Contributor Author

boothby commented Dec 7, 2021

Caught a mistake; will patch later. For now, have a preview.

yield2z100

A giant run of sample images:

import dwave_networkx as dnx
import networkx as nx
from minorminer import find_embedding
import random
import gc
from matplotlib import pyplot as plt
import os
from itertools import chain
os.system("rm yield*.png")
for dpi in (100,):
    for i,(m, t) in enumerate([(2, 1), (2, 4), (2,8), (4,4), (4,8), (8,6), (6,8), (15,4), (15,8), (2, 2), (2, 1), (4, 1), (8, 1)]):
        z = dnx.zephyr_graph(m,t,coordinates=True)
        z.remove_nodes_from(random.sample([*z], len(z)//10))
        z.remove_edges_from(random.sample([*z.edges], len(z.edges)//10))
        emb = {}
        hits = set()
        for _ in range(10):
            emb_ = find_embedding(nx.complete_graph(8), z.subgraph(z.nodes - hits), tries=1, max_no_improvement=1, chainlength_patience=0)
            for c in emb_.values():
                hits.update(c)
                emb[len(emb)] = c
            if not emb_: break
        fig, ax = plt.subplots(2, 2, figsize=(20,20), dpi=dpi)
        dnx.draw_zephyr(z, node_color = range(len(z)), ax=ax[0][0])
        dnx.draw_zephyr(z, node_color = range(len(z)), edge_color=range(len(z.edges)), ax=ax[0][1], line_plot=True)
        dnx.draw_zephyr_embedding(z, emb, ax=ax[1][0], line_plot=True)
        dnx.draw_zephyr_yield(z, fault_shape='o', ax=ax[1][1], line_plot=True)
        fig.tight_layout()
        plt.savefig(f'yield{i}z{dpi}.png', bbox_inches='tight')
        plt.close()
        gc.collect()
    for i,(m,crosses) in enumerate([(2,0), (2, 1), (4,0), (6,1), (8,0), (16,1)]):
        z = dnx.pegasus_graph(m,coordinates=True)
        z.remove_nodes_from(random.sample([*z], len(z)//10))
        z.remove_edges_from(random.sample([*z.edges], len(z.edges)//10))
        emb = {}
        hits = set()
        for _ in range(10):
            emb_ = find_embedding(nx.complete_graph(8), z.subgraph(z.nodes - hits), tries=1, max_no_improvement=1, chainlength_patience=0)
            for c in emb_.values():
                hits.update(c)
                emb[len(emb)] = c
            if not emb_: break
        fig, ax = plt.subplots(2, 2, figsize=(20,20), dpi=dpi)
        dnx.draw_pegasus(z, ax=ax[0][0], crosses=crosses)
        dnx.draw_pegasus(z, ax=ax[0][1], crosses=not crosses, line_plot=True)
        dnx.draw_pegasus_embedding(z, emb, ax=ax[1][0], crosses=crosses, line_plot=True)
        dnx.draw_pegasus_yield(z, fault_shape='o', ax=ax[1][1], crosses=crosses)
        fig.tight_layout()
        plt.savefig(f'yield{i}p{dpi}.png', bbox_inches='tight')
        plt.close()
        gc.collect()
    for i,(m, n, t) in enumerate([(2, 2, 2), (2,2,4), (2,2,8), (4,4,8), (4,4,4), (8,4,8), (8,8,4), (16,16,4), (16, 16,8)]):
        z = dnx.chimera_graph(m,n,t,coordinates=True)
        z.remove_nodes_from(random.sample([*z], len(z)//10))
        z.remove_edges_from(random.sample([*z.edges], len(z.edges)//10))
        emb = {}
        hits = set()
        for _ in range(1):
            emb_ = find_embedding(nx.complete_graph(8), z.subgraph(z.nodes - hits), tries=1, max_no_improvement=1, chainlength_patience=0)
            for c in emb_.values():
                hits.update(c)
                emb[len(emb)] = c
            if not emb_: break
        fig, ax = plt.subplots(2, 2, figsize=(20*n/m,20), dpi=dpi)
        dnx.draw_chimera(z, ax=ax[0][0])
        dnx.draw_chimera(z, ax=ax[0][1], line_plot=True)
        dnx.draw_chimera_embedding(z, emb, ax=ax[1][0], line_plot=False)
        dnx.draw_chimera_yield(z, fault_shape='o', ax=ax[1][1], line_plot=False)
        fig.tight_layout()
        plt.savefig(f'yield{i}c{dpi}.png', bbox_inches='tight')
        plt.close()
        gc.collect()

@boothby boothby force-pushed the layout_overhaul branch 4 times, most recently from 9288684 to 96f586a Compare December 8, 2021 17:14
@arcondello arcondello mentioned this pull request Dec 8, 2021
@boothby boothby force-pushed the layout_overhaul branch 2 times, most recently from 070454a to f110c95 Compare December 10, 2021 18:45
@codecov-commenter
Copy link

codecov-commenter commented Dec 10, 2021

Codecov Report

Merging #214 (25b0adc) into main (4ade84b) will decrease coverage by 5.21%.
The diff coverage is 5.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #214      +/-   ##
==========================================
- Coverage   74.42%   69.20%   -5.22%     
==========================================
  Files          29       29              
  Lines        2045     2205     +160     
==========================================
+ Hits         1522     1526       +4     
- Misses        523      679     +156     
Impacted Files Coverage Δ
dwave_networkx/drawing/qubit_layout.py 4.63% <3.22%> (-0.41%) ⬇️
dwave_networkx/drawing/zephyr_layout.py 15.71% <7.69%> (-4.66%) ⬇️
dwave_networkx/drawing/chimera_layout.py 11.82% <8.10%> (-2.84%) ⬇️
dwave_networkx/drawing/pegasus_layout.py 13.63% <8.92%> (-3.76%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ade84b...25b0adc. Read the comment docs.

Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments from a first scan: if I have time, I'd like to try using the new functionality a bit and then returning to this.
Lovely addition!

dwave_networkx/drawing/chimera_layout.py Outdated Show resolved Hide resolved
dwave_networkx/drawing/chimera_layout.py Show resolved Hide resolved
dwave_networkx/drawing/chimera_layout.py Outdated Show resolved Hide resolved
dwave_networkx/drawing/chimera_layout.py Outdated Show resolved Hide resolved
dwave_networkx/drawing/chimera_layout.py Outdated Show resolved Hide resolved
dwave_networkx/drawing/qubit_layout.py Outdated Show resolved Hide resolved
dwave_networkx/drawing/qubit_layout.py Outdated Show resolved Hide resolved
dwave_networkx/drawing/qubit_layout.py Outdated Show resolved Hide resolved
dwave_networkx/drawing/qubit_layout.py Outdated Show resolved Hide resolved
dwave_networkx/drawing/zephyr_layout.py Outdated Show resolved Hide resolved
Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you be adding the https://github.com/dwavesystems/dwave-networkx/blob/main/dwave_networkx/drawing/qubit_layout.py functions to RST files (see comment below on __all__ = ['draw_qubit_graph'])? If so, I'll render those docstrings and see how they look too.

@@ -51,6 +51,13 @@ def chimera_layout(G, scale=1., center=None, dim=2):
Number of dimensions. When dim > 2, all extra dimensions are
set to 0.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

":func:networkx.draw" --> to create a linked object this needs to be :func:~networkx.drawing.nx_pylab.draw

image

Same in many other spots.

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
sizes appropriately to the graph `G`. Optional keys in ``plot_kwargs``
are set to default values by the :func:`normalize_size_and_aspect`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

":func:normalize_size_and_aspect" --> two issues:

  1. Needs to be something like :func:~dwave_networkx.drawing.qubit_layout.normalize_size_and_aspect
  2. You can only link to this function once you add it to an RST file so it's rendered to the docs.

dwave_networkx/drawing/chimera_layout.py Show resolved Hide resolved
@@ -131,6 +138,13 @@ def chimera_node_placer_2d(m, n, t, scale=1., center=None, dim=2):
Number of dimensions. When dim > 2, all extra dimensions are
set to 0.

plot_kwargs : None or dict (default None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as in def chimera_layout() above

where two qubits overlap. In this drawing style, the interpretation of
the ``width`` and ``node_size`` parameters (provided in ``kwargs``)
determine the area of the circles and line widths respectively. See
:func:`dwave_networkx.qubit_layout.draw_lineplot` for more information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefixing with a tilde (~) will be shorter, it might need a .drawing. before the func name, and it needs to be rendered in the docs first.

Also appears in funcs below.

@@ -58,6 +58,13 @@ def pegasus_layout(G, scale=1., center=None, dim=2, crosses=False):
rather than L configuration. Ignored if G is defined with
``nice_coordinates=True``.

plot_kwargs : None or dict (default None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as in def chimera_layout() above

@@ -120,6 +129,13 @@ def pegasus_node_placer_2d(G, scale=1., center=None, dim=2, crosses=False):
If True, :math:`K_{4,4}` subgraphs are shown in a cross
rather than L configuration.

plot_kwargs : None or dict (default None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as in def chimera_layout() above

@@ -23,13 +23,16 @@
from networkx import draw

from dwave_networkx.drawing.distinguishable_colors import distinguishable_color_map
from itertools import repeat, chain

from numbers import Number

__all__ = ['draw_qubit_graph']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about funcs draw_embedding, draw_yield, normalize_size_and_aspect, draw_lineplot? Shouldn't these be added? And added to the appropriate RST file?

@@ -52,6 +52,13 @@ def zephyr_layout(G, scale=1., center=None, dim=2):
Number of dimensions. When dim > 2, all extra dimensions are
set to 0.

plot_kwargs : None or dict (default None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comments on func pathnames

Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have two functions remaining that I'll do right after this but I'm submitting these proposed updates now because (1) I want to submit a separate comment on what looks like a bug and (2) I have a lot of work that would be lost if this review hits a snag


Generic Plotting Functions
--------------------------

Copy link
Contributor

@JoelPasvolsky JoelPasvolsky Jan 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. Caution::
The following semi-public methods are intended to be used by public
functions such as :func:`.draw_chimera()`, not directly by the user.

We do something similar for such functions in dimod here

Comment on lines +638 to +655
"""Draws the graph G with line segments representing nodes.

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
graph and the line segments are provided by :func:`chimera_layout`,
:func:`pegasus_layout` and :func:`zephyr_layout` respectively. These graphs
have three classes of edges:

* internal edges between qubits whose line segments are perpendicular
and intersect at a point, drawn as a circle located at the point of
intersection,
* external edges between qubits whose line segments are colinear, drawn
as a line segment between the nearest endpoints, and
* odd edges between parallel qubits whose line segments are parallel and
overlap in a perpendicular projection, drawn as a line segment between
the midpoints of the respective perpendicular projections.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Draws the graph G with line segments representing nodes.
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
graph and the line segments are provided by :func:`chimera_layout`,
:func:`pegasus_layout` and :func:`zephyr_layout` respectively. These graphs
have three classes of edges:
* internal edges between qubits whose line segments are perpendicular
and intersect at a point, drawn as a circle located at the point of
intersection,
* external edges between qubits whose line segments are colinear, drawn
as a line segment between the nearest endpoints, and
* odd edges between parallel qubits whose line segments are parallel and
overlap in a perpendicular projection, drawn as a line segment between
the midpoints of the respective perpendicular projections.
"""Draws the given graph with line segments representing nodes.
This function is meant to be a drop-in replacement for the NetworkX
:func:`~networkx.drawing.nx_pylab.draw` function, where nodes are associated
with line segments specified as 2x2 matrices ``[[x0, y0], [x1, y1]]``.
The function makes significant assumptions about the edges of graph ``G``,
which hold when ``G`` is a Chimera, Pegasus, or Zephyr graph and the line
segments are generated by :func:`.chimera_layout`, :func:`.pegasus_layout`
and :func:`.zephyr_layout` functions respectively. These graphs have three
classes of edges:
* Internal edges between qubits whose line segments are perpendicular
and intersect at a point, drawn as a circle located at the point of
intersection.
* External edges between qubits whose line segments are colinear, drawn
as a line segment between the nearest endpoints.
* Odd edges between parallel qubits whose line segments are parallel and
overlap in a perpendicular projection, drawn as a line segment between
the midpoints of the respective perpendicular projections.

Fixes the formatting problem with the bullets, separates the intro content into sections and formats the non-simple text

Comment on lines +661 to +662
A graph constructed by :func:`chimera_layout`, :func:`pegasus_layout`,
or :func:`zephyr_layout`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A graph constructed by :func:`chimera_layout`, :func:`pegasus_layout`,
or :func:`zephyr_layout`.
A graph constructed by :func:`.chimera_layout`, :func:`.pegasus_layout`,
or :func:.`zephyr_layout`.

unused_node_color = [unused_color for v in nodelist]
unused_edge_color = [unused_color for v in edgelist]
layout : dict
A dictionary with nodes as keys and 2x2 matrices [[x0, y0], [x1, y1]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A dictionary with nodes as keys and 2x2 matrices [[x0, y0], [x1, y1]]
A dictionary with nodes as keys and 2x2 matrices ``[[x0, y0], [x1, y1]]``

representing the line segments of nodes.

ax : matplotlib.Axis
The matplotlib Axis object to draw the graph on.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The matplotlib Axis object to draw the graph on.
The `Matplotlib <https://matplotlib.org/>`_ Axis object to draw the graph on.

Comment on lines +595 to +596
A magic number used to scale node circles -- ignored and replaced with
the number 50 when `kwargs["line_plot"]` is True.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A magic number used to scale node circles -- ignored and replaced with
the number 50 when `kwargs["line_plot"]` is True.
A magic number used to scale node circles; ignored and replaced with
the number 50 when ``kwargs["line_plot"]`` is ``True``.

@@ -442,22 +487,35 @@ def draw_yield(G, layout, perfect_graph, unused_color=(0.9,0.9,0.9,1.0),
perfect_graph : NetworkX graph
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameters G and perfect_graph need end-of-sentence periods.
Parameter layoutshould be updated to, "...perfect_graph. Should be of the form {node: coordinate, ...}``. Coordinates are ..."

Comment on lines +495 to +496
A color to represent nodes absent from the graph G, and edges absent
from the graph G which are not incident to faulty nodes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A color to represent nodes absent from the graph G, and edges absent
from the graph G which are not incident to faulty nodes.
A color to represent nodes absent from the graph ``G``, and edges absent
from the graph ``G`` which are not incident to faulty nodes.

Comment on lines +510 to +517
If line_plot is True, then qubits are drawn as line segments, and edges
are drawn either as line segments between qubits, or as circles where
two qubits overlap. In this drawing style, the interpretation the width
and node_size parameters (provided in kwargs) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
{node: ((x0, y0), (y0, x0)), ...} -- instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If line_plot is True, then qubits are drawn as line segments, and edges
are drawn either as line segments between qubits, or as circles where
two qubits overlap. In this drawing style, the interpretation the width
and node_size parameters (provided in kwargs) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
{node: ((x0, y0), (y0, x0)), ...} -- instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.
If ``line_plot`` is ``True``, qubits are drawn as line segments and edges
are drawn as either line segments between qubits or circles where
two qubits overlap. In this drawing style, the interpretation the ``width``
and ``node_size`` parameters (provided in ``kwargs``) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
``{node: ((x0, y0), (y0, x0)), ...}``; instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.

twice the width of edges. Layout should be a dict of the form
{node: ((x0, y0), (y0, x0)), ...} -- instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
with the exception of the `pos` parameter which is not used by this
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 illustrates how functions such as :func:`.draw_pegasus` can make use of this internal function.
.. code-block:: python
import dwave_networkx as dnx
import matplotlib.pyplot as plt
from dwave_networkx.drawing.qubit_layout import draw_yield
G = dnx.chimera_graph(1)
layout = dnx.chimera_layout(G)
draw_yield(G.subgraph([0, 4, 5, 6, 7]), layout, G, unused_color="green", fault_color="red")
"""

This one will need a minor edit for indent spaces and cleaning up the three lines below after being committed.

@@ -424,9 +469,9 @@ def unoverlapped_embedding(G, emb, interaction_edges):


def draw_yield(G, layout, perfect_graph, unused_color=(0.9,0.9,0.9,1.0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boothby, I'm seeing something weird with this function though it might be because I'm using it directly rather than through the public functions as intended, where it might not affect anything. The following code snippet,

import dwave_networkx as dnx
import matplotlib.pyplot as plt
from dwave_networkx.drawing.qubit_layout import draw_yield
G = dnx.chimera_graph(1)
layout = dnx.chimera_layout(G)
draw_yield(G.subgraph([0, 4, 5, 6, 7]), layout, G, unused_color="green", fault_color="red")

generates the nodes with/without faults correctly but the edges are offset from the nodes:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not reproducing that on my end (matplotlib 3.4.1, networkx 2.4). Can you try the public interface?

Copy link
Contributor

@JoelPasvolsky JoelPasvolsky Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I finally managed to reproduce it through the public interface:

  1. It does not happen for matplotlib 3.4.1, networkx 2.4; it happens if you upgrade to matplotlib 3.6.3 (dwave-netwokx doesn't set a version requirement for Matplotlib so users might have more recent versions)
  2. We need to add draw_chimera_yield and draw_pegasus_yield to the docs, currently there's only draw_zephyr_yield
import dwave_networkx as dnx
import matplotlib.pyplot as plt
G = dnx.chimera_graph(1)
fig, ax = plt.subplots(figsize=(10, 5))
dnx.draw_chimera_yield(G.subgraph([0, 4, 5, 6, 7]), unused_color="green", fault_color="red", ax=ax)
plt.show()

Shows up once you zoom in as:

image

@JoelPasvolsky
Copy link
Contributor

@boothby, what about updating the requirement on networkx to a minimum of version 2.8.6 to apply this fix there too?

I'm hitting it on the NetworkX draw() function here:

>>> from dwave_networkx.drawing.qubit_layout import draw_embedding
>>> draw_embedding(G, layout, {0:[0, 4, 5]})
...
File ~\pyenv\ocean_repos\dwave_networkx_3_10_2\lib\site-packages\networkx\drawing\nx_pylab.py:117, in draw(G, pos, ax, **kwds)
    115 cf.set_facecolor('w')
    116 if ax is None:
--> 117     if cf._axstack() is None:
    118         ax = cf.add_axes((0, 0, 1, 1))
    119     else:

TypeError: '_AxesStack' object is not callable

Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, these are great functionality additions.
There are still a few small changes (mostly formatting and an example) I'd like but because they're not on code lines directly updated in this PR it's messy to propose them here---I can submit a followup PR to you once this is merged.

twice the width of edges. Layout should be a dict of the form
{node: ((x0, y0), (y0, x0)), ...} -- instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kwargs : optional keywords
See :func:`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 illustrates how functions such as :func:`.draw_pegasus` can make use of this internal function.
.. code-block:: python
import dwave_networkx as dnx
import matplotlib.pyplot as plt
from dwave_networkx.drawing.qubit_layout import draw_embedding
G = dnx.chimera_graph(1)
layout = dnx.chimera_layout(G)
draw_embedding(G, layout, {0:[0, 4, 5], 1: [1, 6], 2: [2, 6], 3: [3, 7]})
"""

This one will need the deletion of lines 272-277 after committing.

Comment on lines +262 to +270
line_plot : boolean (optional, default False)
If line_plot is True, then qubits are drawn as line segments, and edges
are drawn either as line segments between qubits, or as circles where
two qubits overlap. In this drawing style, the interpretation the width
and node_size parameters (provided in kwargs) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
{node: ((x0, y0), (y0, x0)), ...} -- instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
line_plot : boolean (optional, default False)
If line_plot is True, then qubits are drawn as line segments, and edges
are drawn either as line segments between qubits, or as circles where
two qubits overlap. In this drawing style, the interpretation the width
and node_size parameters (provided in kwargs) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
{node: ((x0, y0), (y0, x0)), ...} -- instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.
line_plot : boolean (optional, default False)
If ``line_plot`` is ``True``, qubits are drawn as line segments and edges
are drawn as either line segments between qubits or circles where
two qubits overlap. In this drawing style, the interpretation of the ``width``
and ``node_size`` parameters (provided in ``kwargs``) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
``{node: ((x0, y0), (y0, x0)), ...}``; instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.

Comment on lines +67 to +74
If line_plot is True, then qubits are drawn as line segments, and edges
are drawn either as line segments between qubits, or as circles where
two qubits overlap. In this drawing style, the interpretation the width
and node_size parameters (provided in kwargs) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
{node: ((x0, y0), (y0, x0)), ...} -- instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If line_plot is True, then qubits are drawn as line segments, and edges
are drawn either as line segments between qubits, or as circles where
two qubits overlap. In this drawing style, the interpretation the width
and node_size parameters (provided in kwargs) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
{node: ((x0, y0), (y0, x0)), ...} -- instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.
If ``line_plot`` is ``True``, qubits are drawn as line segments and edges
are drawn as either line segments between qubits or circles where
two qubits overlap. In this drawing style, the interpretation of the ``width``
and ``node_size`` parameters (provided in ``kwargs``) determines the area of the
circles, and line widths, respectively. Qubit line segments are given
twice the width of edges. Layout should be a dict of the form
``{node: ((x0, y0), (y0, x0)), ...}``; instead of coordinates, the nodes
are associated with endpoints of n-dimensional line segments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants