Hi, I am trying to plot lines between nearest neighbors among a group of 6 points using Nearest. I wrote the following code to find the 3 n.n. of every point and tabulate them in a table tt
p[1] = {0, 1}; p[2] = {1, 2}; p[3] = {2, 3}; p[4] = {3, 4}; p[5] = {4, 5}; p[6] = {-1, 2};
tab = Table[p[i], {i, 1, 6}];
Do[tt[j] = Nearest[tab, p[j], 3], {j, 1, 6}]
sor = Table[{tt[j]}, {j, 1, 6}]
But when I run the Do command I get this error message
Set::write: Tag Null in Null[1] is Protected. >>
I also found that when I apply Nearest to one point only I get the same point as a nearest neighbor like this
Nearest[tab, {-1, 2}, 3]
Answer-> {{-1, 2}, {0, 1}, {1, 2}}
Why I get the same point again? and why I get that error message?
Please help me