Finding the neighbors of a node/vertex in a 2D mesh

Hi everyone,

I have a 2d mesh defined by nodes and elements:

Structure of a node:
Node ID, X position, Y position

Structure of an element:
Element ID, Node 1, Node 2, Node 3, Node 4

Example of a 2x2 elements mesh:

Nodes:

 ID  X  Y
  1  0  0
  2  0  1
  3  0  2
  4  1  0
  5  1  1
  6  1  2
  7  2  0
  8  2  1
  9  2  2

Elements:

 ID N1 N2 N3 N4
  1  1  2  4  5
  2  2  3  5  6  
  3  4  5  7  8
  4  5  6  8  9



N7-----N8-----N9
|      |      |
|  E3  |  E4  |
|      |      |
N4-----N5-----N6
|      |      |
|  E1  |  E2  |
|      |      |
N1-----N2-----N3


I'm storing both nodes and elements in linked lists.

I have two questions:
- How can I find the neighbors (nodes) for an arbitrary selected node?
- How can I find the neighbors (elements) for an arbitrary selected element?


*Note: This 2x2 element mesh simplified example for explanation proposes, the meshes I'm dealing with may contain several thousands of nodes and elements.

Thanks.
Topic archived. No new replies allowed.