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

Function checkNeighbors

javascript/0210-course-schedule-ii.js:85–106  ·  view source on GitHub ↗
(
    node,
    graph,
    color,
    topologicalOrder,
    isDirectedAcyclicGraph,
)

Source from the content-addressed store, hash-verified

83};
84
85var checkNeighbors = (
86 node,
87 graph,
88 color,
89 topologicalOrder,
90 isDirectedAcyclicGraph,
91) => {
92 for (const neighbor of graph[node]) {
93 const isNew = color[neighbor] === 1; // White
94 if (isNew)
95 dfs(
96 neighbor,
97 graph,
98 color,
99 topologicalOrder,
100 isDirectedAcyclicGraph,
101 );
102
103 const isCycle = color[neighbor] === 2; // Grey
104 if (isCycle) isDirectedAcyclicGraph[0] = false;
105 }
106};
107
108/**
109 * https://leetcode.com/problems/course-schedule-ii/

Callers 2

colorBackTrackFunction · 0.70
bfsFunction · 0.70

Calls 3

isSourceFunction · 0.85
dfsFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected