MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / bfs

Function bfs

javascript/0261-graph-valid-tree.js:83–89  ·  view source on GitHub ↗
(graph, visited, queue)

Source from the content-addressed store, hash-verified

81};
82
83const bfs = (graph, visited, queue) => {
84 while (!queue.isEmpty()) {
85 for (let i = queue.size() - 1; 0 <= i; i--) {
86 checkNeighbor(graph, visited, queue);
87 }
88 }
89};
90
91const checkNeighbor = (graph, visited, queue) => {
92 const node = queue.dequeue();

Callers 1

validTreeFunction · 0.70

Calls 3

checkNeighborFunction · 0.70
isEmptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected