Voronoi diagram: Difference between revisions
→{{header|Python}}
Superbatfish (talk | contribs) |
Superbatfish (talk | contribs) |
||
Line 2,130:
Note that for large numbers of points, using a KDTree will be much faster thanks to lookups in log(N) time rather than N comparisons at every coordinate. The code below has running time O(X*Y*log(N)), whereas the code above has running time O(X*Y*N). For 1000 points, the code below is 250x faster than the above.
Alternative metrics can be supported by using a [https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KDTree.html#sklearn.neighbors.KDTree.query scikit-learn KDTree ].
<syntaxhighlight lang="python">
|