function example(svg) {
const points = distribution();
const voronoi = d3.Delaunay.from(points).voronoi([0, 0, 290, 190]);
const spurious = new Set(
[...voronoi.cellPolygons()].flat().map(d => d.join(","))
);
for (let i = 0; i < points.length; i++) {
for (const d of edges(voronoi.cellPolygon(i))) {
spurious.delete(d.join(","));
}
}
svg
.append("path")
.attr("d", voronoi.renderBounds())
.attr("fill", "none")
.attr("stroke", "black");
svg
.append("path")
.attr("d", voronoi.render())
.attr("fill", "none")
.attr("stroke", "#999");
svg
.selectAll("circle")
.data(points)
.join("circle")
.attr("r", 1)
.attr("transform", d => `translate(${d})`);
svg
.append("g")
.selectAll("circle")
.data([...spurious])
.join("circle")
.attr("r", 4)
.style("fill", "red")
.attr("transform", d => `translate(${d})`);
}