@@ -185,7 +185,7 @@ def chromatic_polynomial(G, return_tree_basis=False, algorithm='C', cache=None):
185
185
# Breadth first search from 0:
186
186
bfs_reorder[0 ] = 0
187
187
mpz_init(tot[0 ]) # sets to 0
188
- for i from 0 < i < nverts:
188
+ for i in range ( 1 , nverts) :
189
189
bfs_reorder[i] = - 1
190
190
mpz_init(tot[i]) # sets to 0
191
191
mpz_init(tot[nverts]) # sets to 0
@@ -230,12 +230,12 @@ def chromatic_polynomial(G, return_tree_basis=False, algorithm='C', cache=None):
230
230
for i in range (nverts):
231
231
mpz_clear(tot[i])
232
232
raise
233
- for i from 0 <= i <= nverts :
233
+ for i in range (nverts + 1 ) :
234
234
mpz_init(coeffs[i]) # also sets them to 0
235
235
mpz_init(coeff)
236
236
mpz_init_set_si(m, - 1 )
237
237
# start with the zero polynomial: f(x) = 0
238
- for i from nverts >= i > 0 :
238
+ for i in range ( nverts, 0 , - 1 ): # nverts >= i > 0
239
239
if not mpz_sgn(tot[i]):
240
240
continue
241
241
mpz_neg(m, m)
@@ -244,7 +244,7 @@ def chromatic_polynomial(G, return_tree_basis=False, algorithm='C', cache=None):
244
244
# f += tot[i]*m*x*(x-1)**(i-1)
245
245
mpz_addmul(coeffs[i], m, tot[i])
246
246
mpz_set_si(coeff, 1 )
247
- for j from 1 <= j < i :
247
+ for j in range ( 1 , i) :
248
248
# an iterative method for binomial coefficients...
249
249
mpz_mul_si(coeff, coeff, j- i)
250
250
mpz_divexact_ui(coeff, coeff, j)
@@ -254,13 +254,13 @@ def chromatic_polynomial(G, return_tree_basis=False, algorithm='C', cache=None):
254
254
mpz_mul(coeff, coeff, m)
255
255
coeffs_ZZ = []
256
256
cdef Integer c_ZZ
257
- for i from 0 <= i <= nverts :
257
+ for i in range (nverts + 1 ) :
258
258
c_ZZ = Integer(0 )
259
259
mpz_set(c_ZZ.value, coeffs[i])
260
260
coeffs_ZZ.append(c_ZZ)
261
261
f = R(coeffs_ZZ)
262
262
263
- for i from 0 <= i <= nverts :
263
+ for i in range (nverts + 1 ) :
264
264
mpz_clear(tot[i])
265
265
mpz_clear(coeffs[i])
266
266
0 commit comments