Implemented BFS basic procedure.