# グラフgと始点ノードs breadthFirstSearch(g, s): Queue que for i ← 0 to g.N - 1: dist[i] ← INF que.enqueue(s) dist[s] ← 0 while not que.empty(): u ← que.dequeue() for v in g.adjLists[u]: if dist[v] = INF: dist[v] ← dist[u] + 1 que.enqueue(v)