update graph, add bfs