























































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!
























































BFS(G, s) { initialize vertices; Q = {s}; // Q is a queue (duh); initialize to s while (Q not empty) { u = RemoveTop(Q); for each v ā u->adj { if (v->color == WHITE) v->color = GREY; v->d = u->d + 1; v->p = u; Enqueue(Q, v); } u->color = BLACK; } } v->p represents parent in tree v->d represents depth in tree
source vertex
source vertex d f
source vertex d f
source vertex d f
source vertex d f
source vertex d f
source vertex d f
source vertex d f
source vertex d f
source vertex d f
source vertex d f
source vertex d f