New in Wolfram Mathematica 6: Exploratory Data Analysis | ◄ previous | next ► |
Find Nearest Neighbors in Any Space
Mathematica 6 has powerful and efficient nearest-neighbor algorithms, suitable for any dimension and any distance function.
In[1]:= | Graphics[Module[{r = RandomReal[1, {1000, 2}], nf}, nf = Nearest[r -> Automatic]; GraphicsComplex[r, Table[{Line[Thread[{n, nf[r[[n]], 5]}]], Red, Point[n]}, {n, 1000}]]]] |
Out[1]= |