class Grid {
constructor(points) {
this.voronoi = new d3.Delaunay(points).voronoi([0, 0, width, height]);
this.cells = Array.from({length: points.length / 2}, (_, i) => new Cell(i));
for (const cell of this.cells) {
const neighborIndices = this.voronoi.neighbors(cell.index);
for (const idx of neighborIndices) {
const neighbor = this.cells[idx];
cell.neighbors.push(neighbor);
}
}
}
}