Added Lock-based implementation of BFS