I have an orthotopic grid, in n-dimensions (usually small ~<3), where each node is connected to it's orthogonal neighbours. The grid may be any number of nodes long, but is finite (and usually small – ~<10) in each dimension. The edges of the grid are undirected.
Given the grid dimensions (e.g. (3,4,3)), how can I generate an adjacency matrix for the nodes (1=edge, 0=no edge)?
Best Answer
Ok, so I worked it out, after a lot of trial and error. Here is the code that I'm using in python. If there is a better way of doing this, I would happily accept another answer.