Organizing Data in Keys with Specific Characteristics and Values

I am trying to figure out how to organize a set of nodes (not server nodes, just nodes in a general sense) I’m working with and I’m not sure how to go about this.

Each node is a cartesian point and they all form a network of connected points that connect either by a horizontal or vertical line, so I need to assign information to them about which nodes are neighbors. For example:

node1A = 10 @ 58;

node1A’s southern neighbor is node2A.

node1A’s eastern neighbor is node1B.

node1A’s northern and western neighbors are both nil (node1A is a top left corner).

Would I use an identity dictionary for this? I hope this makes sense. I have another Pen class object moving between these nodes on a GUI and it needs an algorithm to determine which way it can go once it hits a specific node. So for example, if this object hits node1A or any other node with southern and eastern neighbors, it should go either south or east.

I think this is what you want to setup ?

// Create the Dict :
var allNodes = ();

// For each node, reference it with it's neighbors 
allNodes.put( \node1A, [ node2A, node1B ] );
// etc

// The Dict will have a key for each node (a symbol), and the associated value is the node neighbors, inside an Array : \node1A ) // Return neighbors \node1A )[0].asSymbol ) ); // Find first neighbor's neighbors

Thanks! I actually ended up using a ton of variables in the mean time and I have no desire to go back and change it but this did work and it would have been a much better solution.