Jump to content

Voronoi diagram: Difference between revisions

(→‎{{header|Python}}: Added alternative Python implementation, using numpy/scipy.)
Line 2,127:
[[File:Voronoi_python.png|500px|thumb|center|Voronoi Diagram in Python]]
 
Alternatively, vectorized code leveraging numpy and scipy is 2x shorter and 10x faster:, as seen below.
 
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.
 
<syntaxhighlight lang="python">
4

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.