# How to find adjacent neighbours using Python?

Full problem description at stackoverflow

I need to find the adjacent neighbours (not necessarily nearest neighbours) to a given point in a multidimensional space.

As shown in the screenshot below, I need to get the adjacent neighbours around the red point, irrespective of their actual distance.

Problem: I can only find the nearest neighbours algorithms, which do not return adjacent neighbours if there is unequal spacing for different dimensions as shown below:

How can I retrieve the adjacent neighbours around a given point?

• – noe
Feb 21 at 17:12
• why don't you put the spacing on the same scale ? (standardize everything)? Feb 21 at 17:19
• @LucasMorin I posted the whole question on SO where the whole issue (and MWE) is described. Here I have posted on the simplified question. I can't use the same scaling because the points because the points will be non-linearly distributed in the multi-dimensional space with unequal spacing. The posted screenshots show linear distribution (more or less) to describe the problem and requirement.
– skm
Feb 21 at 18:02
• What is an "adjacent neighbor" and an "immediate neighbor"? Feb 21 at 18:09
• its not clear wht you mean by 'irrespective of the spacing'. To achieve that you would need that spacing is equal along dimension. If the spacing is not equal the neighboring is correct. Feb 21 at 18:51