2
* @param {number[][]} graph5
var shortestPathLength = function (graph) {6
const n = graph.length;7
const allVisited = (1 << n) - 1;9
const visited = new Set();11
for (let i = 0; i < n; i++) {12
queue.push([1 << i, i, 0]);13
visited.add((1 << i) * 16 + i);16
while (queue.length > 0) {17
const [mask, node, dist] = queue.shift();19
if (mask === allVisited) {23
for (const neighbor of graph[node]) {24
const newMask = mask | (1 << neighbor);25
const hashValue = newMask * 16 + neighbor;27
if (!visited.has(hashValue)) {28
visited.add(hashValue);29
queue.push([newMask, neighbor, dist + 1]);