Draw lines between all neighbours

I have seen this question, but what I want is a bit different.

I have a set of data (blue points) and I would like to end up with something like this:

,

i.e. joining each site with all its (nearest) neighbours.

The order of the data points is random so if I just do Joined->True it plots lines at random.

I know I can use Nearest[], so I added a line

x0 = Neartest[data]


which outputs a set of sets of numbers (the nearest neighbours), but am not quite sure how to plot that on top of the original points WITH segments in between.

Any pointers?

Thanks

if you want, the data is:

data= Uncompress@Import["http://pastebin.com/raw.php?i=qvMp8BNv"]

• Look up DelaunayMesh[]. – J. M. will be back soon Nov 12 '15 at 13:12
• What exactly do you means by "all its nearest neighbors"? It is important to define this precisely. If you connect each dot to the one that is closes to it, you will not end up with the sort of figure you have drawn. Typically each dot will have a single nearest neighbour. BTW NearestNeighborGraph will do just that. – Szabolcs Nov 12 '15 at 13:15
• Yeah I realise that's a bit misleading sorry. I meant all the points around a given datum... – SuperCiocia Nov 12 '15 at 13:31
• I think DelaunayMesh is the one I want. By chance, is there any way of telling it what polygons to fit? Eg. "only try to draw pentagons" – SuperCiocia Nov 12 '15 at 14:01
• I don't think that it does, since it performs a Delaunay triangulation which exclusively generates triangles. – IPoiler Nov 12 '15 at 15:44

here is the nearest neighbors plot:

pts = RandomReal[{-1, 1}, {200, 2}];
near = Nearest[pts];
Graphics[{Function[{pt}, Line[{pt, #}] & /@ near[pt, {5, .2}]] /@ pts,
PointSize[.015], Red, Point@pts}]


this is up to 5 near neighbors within radius of .2..

for comparison DelaunayMesh[pts]

• The comparison is a good hint. – user9660 Nov 12 '15 at 19:15