Skip to content

Commit 3dbd419

Browse files
authored
FIXED bug in graphplot.py
1 parent d022481 commit 3dbd419

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pytheus/graphplot.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,11 @@ def plotFromFile(filename, number_nodes=True, outfile=""):
215215
raise IOError(f'File does not exist: {filename}')
216216
with open(filename) as input_file:
217217
sol_dict = json.load(input_file)
218-
# graph = Graph(sol_dict['graph'])
219-
# graphPlot(graph.graph, scaled_weights=True, number_nodes=number_nodes, filename=outfile)
220-
graphPlotOld(sol_dict['graph'], scaled_weights=True, number_nodes=number_nodes, filename=outfile)
218+
graph = Graph(sol_dict['graph'])
219+
ancillas = [ii for ii, dim in enumerate(graph.dimensions) if dim==1]
220+
print('WARNING: single photons are presented as ancillas. Single photon sources and other types of nodes are not available.')
221+
graphPlotNew(graph.graph, type_photons=[ancillas,[],[]])#, scaled_weights=True, number_nodes=number_nodes, filename=outfile)
222+
# graphPlot(sol_dict['graph'], scaled_weights=True, number_nodes=number_nodes, filename=outfile)
221223

222224
# # Experiment plotting tools
223225

@@ -301,21 +303,21 @@ def Plot_Vertices(ax, num_nodes, side_length, type_photons = None, font_size =12
301303
elif isinstance(type_photons, tuple) or isinstance(type_photons, list):
302304
if len(type_photons)==3:
303305
ancilla, single_emitters, in_nodes = type_photons
304-
for i, vertex in enumerate(vertices):
305-
if i in ancilla:
306-
if i in single_emitters:
306+
for ii, vertex in enumerate(vertices):
307+
if ii in ancilla:
308+
if ii in single_emitters:
307309
plot_triangle(ax, vertex ,2.5*r, 10, linewidth=linewidth )
308310
else:
309311
x =vertex[0]-r
310312
y = vertex[1]-r
311313
ax.add_patch(Rectangle((x,y),2*r, 2*r,fc = 'w', \
312314
ec = 'k',zorder = 10, linewidth=linewidth))
313-
elif i in single_emitters or i in in_nodes:
315+
elif ii in single_emitters or ii in in_nodes:
314316
plot_triangle(ax, vertex ,2.5*r, 10, linewidth=linewidth )
315317
else:
316318
ax.add_patch(Circle(vertex, radius= r, facecolor='w',\
317319
edgecolor='black', zorder = 10, linewidth=linewidth))
318-
ax.text(vertex[0], vertex[1], str(i), ha='center', \
320+
ax.text(vertex[0], vertex[1], str(ii), ha='center', \
319321
va='center', fontsize=font_size,zorder = 12 )
320322
else:
321323
raise ValueError("The type_photons is not valid.")
@@ -1138,5 +1140,3 @@ def graphPlotNew(graph, type_photons = None, DistanceOfVertices=0.1,filename='',
11381140
return fig
11391141

11401142
cols = ['#66c2a5', '#fc8d62', '#8da0cb']
1141-
1142-

0 commit comments

Comments
 (0)