int getHeadProp(Node *Graphptr, Node *ptr, char prop)
{
int retProp;
Node *temp;
temp = findHnode(ptr, Graphptr);
switch(prop)
{
case 'c' :
retProp = temp -> color;
break;
case 'd' :
retProp = temp -> di;
break;
case 'f' :
retProp = temp -> fi;
break;
case 'v' :
retProp = temp -> visited;
}
return retProp;
}
void setHeadProp(Node *Graphptr, Node *ptr, char prop, int setVal)
{
Node *temp;
temp = findHnode(ptr, Graphptr);
switch(prop)
{
case 'c' :
temp -> color = setVal;
break;
case 'd' :
temp -> di = setVal;
break;
case 'f' :
temp -> fi = setVal;
break;
case 'v' :
temp -> visited = setVal;
break;
}
}
Node *findHnode(Node *ptr, Node *Graphptr)
{
Node *temp = Graphptr;
while (temp)
{
if (temp -> data == ptr -> data)
break;
temp = temp -> NbH;
}
return temp;
}
void dfs(Node *ptr)
{
while (ptr)
{
if (getHeadProp(Graphptr, ptr, 'v') == 0)
{
printf("%-2c", ptr -> data);
setHeadProp(Graphptr, ptr, 'v', 1);
dfs(findHnode(ptr -> NbN, Graphptr));
}
ptr = ptr -> NbN;
}
}
void main()
{
Node *Graphptr, *ptr;
Graphptr = createGraph();
ptr = Graphptr;
dfs(ptr);
}