How to compute number of neighbours of each element in a tensor?

123 Views Asked by At

I have a tensor (multidimensional data) with "d" dimensions. I want to compute number of neighbours of each element in the tensor. How can I do this? For example in a matrix, each cell has maximum of four neighbours. In a cube, each cell has maximum of six neighbours. What's the formula to compute number of neighbours each cell has in multidimensional data?

1

There are 1 best solutions below

0
On BEST ANSWER

It sounds like a neighbor has coordinates within one in one dimension and equal in all other dimensions. In that case you have $d$ ways to pick the dimension to change and two choices of the amount to add, $+1$ or $-1$, so there are at most $2d$ neighbors.