function pycnoStep(values0) {
const values1 = Float64Array.from(values0);
const neighbors = voronoi.delaunay.neighbors;
for (const [tract, I] of classes) {
if (tract === undefined) continue;
for (const i of I) {
values1[i] +=
(d3.mean(neighbors[i], (j) => values0[j]) - values0[i]) * 0.7;
}
const sum = d3.sum(I, (i) => values1[i]);
for (const i of I) {
values1[i] += ((total[tract] - sum) / I.length) * 1;
}
const neg = d3.group(I, (i) => values1[i] < 0);
if (neg.has(true)) {
const reallocate =
-d3.sum(neg.get(true), (i) => values1[i]) / neg.get(false).length;
for (const i of neg.get(true)) values1[i] = 0;
for (const i of neg.get(false)) values1[i] += reallocate;
}
}
return values1;
}