BFS in java for graphs