breadth first search using adjacency lists