advice on a data structure

Hi im doing some research into cell signalling in fly wings, and need to represent such cells in a hexagonal grid

now each hexagon (6 sides) has 6 neighbours, and these neighbours have 6 neighbours and so on...

ive began to design a class on paper to represent a Cell Wall, thus a class Cell will constitute 6 walls (the hexagon)

now comes the difficulty im having, i was trying to link cells into a linear data structure with corresponding pointers to all neighbours, and sofar i have something similar to below on paper:

key : cell = [X]

pointer ->

This seems to be the linear style data structure for 7 cells;

[0] <-> [1] <-> [2] <-> [3] <-> [4] <-> [5] <-> [6]

[6] <-> [0]

[5] <-> [0]

[4] <-> [0]

[3] <-> [0]

[2] <-> [0]

[1] <-> [0]

[7] <-> [6]

[7] <-> [1]

(think of a spiral to visualise what i mean)

This is quite overly complex and gets rather messy with 20+ cells, i was wondering if any1 has any ideas of arranging this sort of structure in a more simple way..?

it looks as if ill be dealing with a large number of pointers if i go this way .. which is quite daunting ... the only other way is if i come up with a complex algorithm to determine possible neighbours based upon the cell id number or something

Thanks in advance.

Don't know if this would work.

I am just taking a stab at the problem. I may be way off base but, if you want to reduce the number of pointers I think you might be able to just create a structure with six members of type int. If you number each cell (1-100 or something) ....... then you could try

Code:

`struct Cell`

{

int side1;

int side2;

int side3;

int side4;

int side5;

int side6;

};

now you could create an array of structures. IE however many cells you want and make its data members equal to the cell it is adjacent too.

if side1 of cells[1] was adjacent to cell 40 then make it equal to 40. cells[1].side1=40; To access any adjacent cell just put its side as the index.

Code:

`cells[1].side1=40;`

cells[ cells[1].side1 ]; //would give you cell #40

also you will notice that you have certain pairs. if you take the sides going clockwise side1 will always share side4 of that adjacent cell and side2 will always share side5 of that adjacent cell and 3 will always share side 6 of that adjacent cell. Basically just adding 3 to the appropriate side will give you the adjacent cells side for 1/2 of the cell then subtracting 3 will give you the other 1/2 of the cell.