1function bfs(graph, start) {
2 const adjacency = buildAdjacencyList(graph);
3 const visited = new Set([start]);
4 const queue = [start];
5 const order = [];
6 while (queue.length > 0) {
7 const current = queue.shift();
8 order.push(current);
9 for (const neighbor of adjacency.get(current)) {
10 if (!visited.has(neighbor)) {
11 visited.add(neighbor);
12 queue.push(neighbor);
13 }
14 }
15 }
16 return order;
17}