MCPcopy Index your code
hub / github.com/neetcode-gh/leetcode / buildGraph

Function buildGraph

javascript/0207-course-schedule.js:19–31  ·  view source on GitHub ↗
(numCourses, prerequisites)

Source from the content-addressed store, hash-verified

17});
18
19var buildGraph = (numCourses, prerequisites) => {
20 const { graph, path } = initGraph(numCourses);
21
22 for (const [src, dst] of prerequisites) {
23 const neighbors = graph[dst] || [];
24
25 neighbors.push(src);
26
27 graph[dst] = neighbors;
28 }
29
30 return { graph, path };
31};
32
33var hasPath = (numCourses, graph, path) => {
34 for (let course = 0; course < numCourses; course++) {

Callers 1

canFinishFunction · 0.70

Calls 2

initGraphFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected