MCPcopy Index your code
hub / github.com/marijnh/Eloquent-JavaScript / findPath_set

Function findPath_set

code/solutions/22_3_optimizing.js:8–21  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

6}
7
8function findPath_set(a, b) {
9 let work = [[a]];
10 let reached = new Set([a]);
11 for (let path of work) {
12 let end = path[path.length - 1];
13 if (end == b) return path;
14 for (let next of end.edges) {
15 if (!reached.has(next)) {
16 reached.add(next);
17 work.push(path.concat([next]));
18 }
19 }
20 }
21}
22
23time(findPath_set);
24

Callers

nothing calls this directly

Calls 2

hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected