How to find all or any number of adjacent polygons in a voronoi pattern?


In a neighboring polygon community like the above, how can one polygon say Hi to all its neighbors who share the same edge with it?

Thanks!

This is referencing one voroni polygon at a time, to find it’s personal neighbors, but the same system works if you are trying to create a list structure of all the neighboring sets. It’s finding the nearest polygon center points to the target’s center point, and calling the associated polygons using those point indexes. It knows how many nearby polygons to search for based on the number of edges.

howdy neighbors.gh (8.9 KB)

Thank you!
It is simple and intuitive, but there is a small problem:
For the members living in the rural area, I don’t think they are quite good at recognizing their immediate neighbors.
image

Ha, damn those corners! Proximity 2D is another method but could cause similar hiccups since voroni vary in size. Someone else should jump in with ideas.

I’ll post back if I think of anything… maybe with lines going from the center point to the polygon edge mid points, extending them and checking to see what polygons/regions those end points land in.

Here is another option:
howdy neighbors_v2.gh (9.8 KB)

2 Likes

Thank you! It is working perfectly! The simplest way to say Hi!

One small change, I realised I used the wrong output of the collision component:
howdy neighbors_v3.gh (19.0 KB)

This could also be done with Brep Topology.

howdy neighbors topo.gh (18.7 KB)

2 Likes

Good catch, I didn’t knew this component, I never saw it. And it is there since 2013

so here a way of doing with SandBox


topology brep.gh (9.5 KB)

2 Likes

Could the adjacent cells (points) be retrieved in a scripted voronoi command?

I dont know it must depend on the tool you use to generate the voronoi diagram. At the moment in my c# i use an open source Delaunay Voronoi tool. It is not fast but robust and simple to use.

1 Like

Yes- the Voronoi adjacencies are exactly those which have their sites connected by an edge in the Delaunay triangulation.
So with this one line script you can get the indices:
A = m.Vertices.GetConnectedVertices(i);

voro_adjacency.gh (7.7 KB)

3 Likes

Thanks Daniel. Is there such a simple solution for 3D voronoi too?

No, not natively in GH or RhinoCommon.
The same dual relation does still hold in 3d - sites connected by Delaunay edges share a face in the Voronoi.
There are no methods currently exposed for the 3d Delaunay though.

1 Like

voro_adjacency test.gh (16.2 KB)

Thank you!
It works perfectly in the central part, but when it comes to the boundary, it will show some extra polygon.
image

One way that wouldn’t even require scripting or 3D Delaunay logic could be to deconstruct the 3D Voronoi cells in order to get their number of faces, and thus the count of potential neighbouring cells. Additional logic needs be added here, because some cells that lie on the Voronoi regional boundary have less neighbours than faces.
Once you have the neighbour count figured out, you then can use the cell centers and for each look for n-closeset points, which correspond by index to the actual cell neighbours.

1 Like

I have a solution for 3D voronoi neighbors but I was wondering if there is a way to retrieve all this from a script and apparently that’s not so easy…

What I proposed above should work in Python, C#, etc. too.

That’s not the goal.

When the initial Voronoi is created, the neighbors are there but apparently they aren’t available as an output?

Yes, and what I propose is a rather easy way to get the neighbours for a single or all cells.

I don’t understand your meaning. Both the 2D and 3D components don’t output neighbourhood information.

The dual of the Voronoi in both 2D and 3D is the Delaunay diagram, which you get by connecting the cell centroids to their immediate neighbours. The resulting line network can then be converted to an undirected graph, doubly-connected edge list, or other appropriate data structure to more easily extract information like the neighbourhood of cells, and so fourth.