@@ -70,7 +70,7 @@ def run_clustering_con(g, inputf, outputf, k, costf):
70
70
if "---" in line :
71
71
lines = True
72
72
elif lines :
73
- k = [ int (s ) for s in line .split () if s .isdigit ()][ 0 ]
73
+ k = next ( int (s ) for s in line .split () if s .isdigit ())
74
74
75
75
nodes_by_color [k ].append (counter )
76
76
color_by_node [counter ] = k
@@ -85,7 +85,7 @@ def run_clustering_con(g, inputf, outputf, k, costf):
85
85
86
86
for n in range (len (list (g .nodes ))):
87
87
if len (list (g .neighbors (n ))) == 1 :
88
- g .nodes [n ]["c" ] = g .nodes [list ( g .neighbors (n ))[ 0 ] ]["c" ]
88
+ g .nodes [n ]["c" ] = g .nodes [next ( iter ( g .neighbors (n ))) ]["c" ]
89
89
90
90
new_col_by_node = []
91
91
for i in g .nodes (data = True ):
@@ -166,7 +166,7 @@ def run_clustering_all(g, inputf, outputf, k, costf):
166
166
if "---" in line :
167
167
lines = True
168
168
elif lines :
169
- k = [ int (s ) for s in line .split () if s .isdigit ()][ 0 ]
169
+ k = next ( int (s ) for s in line .split () if s .isdigit ())
170
170
171
171
nodes_by_color [k ].append (counter )
172
172
color_by_node [counter ] = k
@@ -180,7 +180,7 @@ def run_clustering_all(g, inputf, outputf, k, costf):
180
180
# We don't need to fix terminal edges anymore, but we know it's a split qubit in that case, better not messing up
181
181
for n in range (len (list (g .nodes ))):
182
182
if len (list (g .neighbors (n ))) == 1 :
183
- g .nodes [n ]["c" ] = g .nodes [list ( g .neighbors (n ))[ 0 ] ]["c" ]
183
+ g .nodes [n ]["c" ] = g .nodes [next ( iter ( g .neighbors (n ))) ]["c" ]
184
184
185
185
new_col_by_node = []
186
186
for i in g .nodes (data = True ):
0 commit comments