BFS concepts, search in a Graph
Hi.
I am trying to understand this code:
q.push(start);
Visit [start] =1;
while(!q.empty())
{
cur=q.front();
q.pop();
process(cur);
adjacents=get_adjacent of(cur);
fo(i,0,sz(adjacents))
if(visit[adjacent[i]]==0)
{
visit[adjacent[i]]=1;
q.push(adjacent[i]);
}
}
Doing some BFS search. But I don't see anything that matches the text book. As far as I understood the BFS traversing searches the parent first and then from left to right the child nodes. If not found, then the leftmost becomes the parent doing the same thing.
The process continues until the Node is found. But how do I do it? Please explain the process if possible.








