1919import networkx as nx
2020from networkx import draw
2121
22- from dwave_networkx .drawing .qubit_layout import draw_qubit_graph , draw_embedding , draw_yield , normalize_size_and_aspect
22+ from dwave_networkx .drawing .qubit_layout import draw_qubit_graph , draw_embedding , draw_yield , normalize_size_and_aspect , draw_lineplot
2323from dwave_networkx .generators .pegasus import pegasus_graph , pegasus_coordinates
2424from dwave_networkx .drawing .chimera_layout import chimera_node_placer_2d
2525
@@ -133,6 +133,11 @@ def pegasus_node_placer_2d(G, scale=1., center=None, dim=2, crosses=False, norma
133133 """
134134 import numpy as np
135135
136+ line_plot = False if normalize_kwargs is None else normalize_kwargs .get ('line_plot' )
137+
138+ if line_plot :
139+ crosses = False
140+
136141 m = G .graph ['rows' ]
137142 h_offsets = G .graph ["horizontal_offsets" ]
138143 v_offsets = G .graph ["vertical_offsets" ]
@@ -180,7 +185,19 @@ def _xy_coords(u, w, k, z):
180185 # convention for Pegasus-lattice pictures is to invert the y-axis
181186 return np .hstack ((xy * scale , paddims )) + center
182187
183- return _xy_coords
188+
189+ if line_plot :
190+ qubit_dx = np .hstack (([5.75 , 0 ], paddims )) * scale
191+ qubit_dy = np .hstack (([0 , 5.75 ], paddims )) * scale
192+ def _line_coords (u , w , k , z ):
193+ xy = _xy_coords (u , w , k , z )
194+ if u :
195+ return np .vstack ((xy - qubit_dx , xy + qubit_dx ))
196+ else :
197+ return np .vstack ((xy - qubit_dy , xy + qubit_dy ))
198+ return _line_coords
199+ else :
200+ return _xy_coords
184201
185202
186203def draw_pegasus (G , crosses = False , ** kwargs ):
@@ -207,7 +224,16 @@ def draw_pegasus(G, crosses=False, **kwargs):
207224 crosses: boolean (optional, default False)
208225 If True, :math:`K_{4,4}` subgraphs are shown in a cross
209226 rather than L configuration. Ignored if G is defined with
210- ``nice_coordinates=True``.
227+ ``nice_coordinates=True`` or ``line_plot=True``.
228+
229+ line_plot : boolean (optional, default False)
230+ If line_plot is True, then qubits are drawn as line segments, and edges
231+ are drawn either as line segments between qubits, or as circles where
232+ two qubits overlap. In this drawing style, the interpretation the width
233+ and node_size parameters (provided in kwargs) determines the area of the
234+ circles, and line widths, respectively. For more information, see
235+ :func:`dwave_networkx.qubit_layout.draw_lineplot`.
236+
211237
212238 kwargs : optional keywords
213239 See networkx.draw_networkx() for a description of optional keywords,
@@ -277,6 +303,15 @@ def draw_pegasus_embedding(G, *args, crosses=False, **kwargs):
277303 If True, chains in ``emb`` may overlap (contain the same vertices
278304 in G), and these overlaps are displayed as concentric circles.
279305
306+ line_plot : boolean (optional, default False)
307+ If line_plot is True, then qubits are drawn as line segments, and edges
308+ are drawn either as line segments between qubits, or as circles where
309+ two qubits overlap. In this drawing style, the interpretation the width
310+ and node_size parameters (provided in kwargs) determines the area of the
311+ circles, and line widths, respectively. For more information, see
312+ :func:`dwave_networkx.qubit_layout.draw_lineplot`.
313+
314+
280315 kwargs : optional keywords
281316 See networkx.draw_networkx() for a description of optional keywords,
282317 with the exception of the ``pos`` parameter, which is not used by this
@@ -315,7 +350,16 @@ def draw_pegasus_yield(G, crosses=False, **kwargs):
315350 crosses: boolean (optional, default False)
316351 If True, :math:`K_{4,4}` subgraphs are shown in a cross
317352 rather than L configuration. Ignored if G is defined with
318- ``nice_coordinates=True``.
353+ ``nice_coordinates=True`` or ``line_plot=True``.
354+
355+ line_plot : boolean (optional, default False)
356+ If line_plot is True, then qubits are drawn as line segments, and edges
357+ are drawn either as line segments between qubits, or as circles where
358+ two qubits overlap. In this drawing style, the interpretation the width
359+ and node_size parameters (provided in kwargs) determines the area of the
360+ circles, and line widths, respectively. For more information, see
361+ :func:`dwave_networkx.qubit_layout.draw_lineplot`.
362+
319363
320364 kwargs : optional keywords
321365 See networkx.draw_networkx() for a description of optional keywords,
0 commit comments