Answer the question
In order to leave comments, you need to log in
What is the best way to store a Voronoi diagram?
Let's leave the construction algorithm behind the scenes - let's say we know how to do it in some way, and even if only manually.
But what is the best way to store the finished chart, what data structure to use?
And not just to store, but to quickly and conveniently find out in which cell an arbitrary point fell into.
After all, it (the diagram) is generally devoid of any regularity.
Answer the question
In order to leave comments, you need to log in
"Keep the chart" makes no sense.
I would store only the coordinates of the points and, when requested, do a search for the nearest neighbor. After all, the whole point of the Voronoi diagram is to divide it into regions where the nearest neighbor is one of the control points.
Upd. Perhaps I was wrong and you can store the diagram as a binary tree, which will give a faster search for an answer to whether a point belongs to an area - by traversing the tree. (or won't?)
if you need to quickly find out the nearest point to a given one, then you can store the Voronoi diagram as a raster map.
regular grid, each cell has a list of nearest points. most of the cells inside the polygons of the diagram will have a list of one element, and on the borders between the polygons - of several.
the higher the resolution of the map, the more hits and less calculations per point. at a low card resolution (if there is little memory), you get a bloom filter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question