update graph, add bfs.