I am at moment trying create a function which take a node, and transverse through the adjacent .
Such that
if Root node A(0,0) has two adjacent nodes B(1,0) and C(0,1).
The function has to traverse the graph in a manner such that the next position of the node will be like this
A(0,0) -> B(1,0) -> B1(2,0) ->.. until a certain condition is fulfilled.
Each node is defined using this struct
1 2 3 4 5 6 7 8 9 10 11 12
|
struc vertex
{
Node * me;
Node * adjacent;
}
struct Node
{
pair<int,int> position;
vector<vertex> adjacent;
}
|
The condition mentioned above is the size of next node adjacent. When the size becomes above either 2 or 4 it has to stop traversing, and continue traversing to the next node when size of the adjacent it three.
The same thing has to be done in the who direction.
I am pretty sure that this can be done in a recursive function.. I just don't know how..