export function findShortestPath(
  startIndex: number,
  endIndex: number,
  adjacency: number[][]
) {
  const queue = [[startIndex]];
  const visited = new Set<number>();

  while (queue.length > 0) {
    const path = queue.shift()!;
    const node = path[path.length - 1];
    if (node === endIndex) return path;

    if (!visited.has(node)) {
      visited.add(node);
      for (const neighbor of adjacency[node]) {
        queue.push([...path, neighbor]);
      }
    }
  }
  return [];
}
