19
19
import networkx as nx
20
20
from networkx import draw
21
21
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
23
23
from dwave_networkx .generators .pegasus import pegasus_graph , pegasus_coordinates
24
24
from dwave_networkx .drawing .chimera_layout import chimera_node_placer_2d
25
25
@@ -133,6 +133,11 @@ def pegasus_node_placer_2d(G, scale=1., center=None, dim=2, crosses=False, norma
133
133
"""
134
134
import numpy as np
135
135
136
+ line_plot = False if normalize_kwargs is None else normalize_kwargs .get ('line_plot' )
137
+
138
+ if line_plot :
139
+ crosses = False
140
+
136
141
m = G .graph ['rows' ]
137
142
h_offsets = G .graph ["horizontal_offsets" ]
138
143
v_offsets = G .graph ["vertical_offsets" ]
@@ -180,7 +185,19 @@ def _xy_coords(u, w, k, z):
180
185
# convention for Pegasus-lattice pictures is to invert the y-axis
181
186
return np .hstack ((xy * scale , paddims )) + center
182
187
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
184
201
185
202
186
203
def draw_pegasus (G , crosses = False , ** kwargs ):
@@ -207,7 +224,16 @@ def draw_pegasus(G, crosses=False, **kwargs):
207
224
crosses: boolean (optional, default False)
208
225
If True, :math:`K_{4,4}` subgraphs are shown in a cross
209
226
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
+
211
237
212
238
kwargs : optional keywords
213
239
See networkx.draw_networkx() for a description of optional keywords,
@@ -277,6 +303,15 @@ def draw_pegasus_embedding(G, *args, crosses=False, **kwargs):
277
303
If True, chains in ``emb`` may overlap (contain the same vertices
278
304
in G), and these overlaps are displayed as concentric circles.
279
305
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
+
280
315
kwargs : optional keywords
281
316
See networkx.draw_networkx() for a description of optional keywords,
282
317
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):
315
350
crosses: boolean (optional, default False)
316
351
If True, :math:`K_{4,4}` subgraphs are shown in a cross
317
352
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
+
319
363
320
364
kwargs : optional keywords
321
365
See networkx.draw_networkx() for a description of optional keywords,
0 commit comments