Function
search
(
numCourses,
graph,
color,
topologicalOrder,
isDirectedAcyclicGraph,
)
Source from the content-addressed store, hash-verified
| 36 | }; |
| 37 | |
| 38 | var search = ( |
| 39 | numCourses, |
| 40 | graph, |
| 41 | color, |
| 42 | topologicalOrder, |
| 43 | isDirectedAcyclicGraph, |
| 44 | ) => { |
| 45 | for (let i = 0; i < numCourses; i++) { |
| 46 | const isNew = color[i] === 1; // White |
| 47 | if (isNew) |
| 48 | dfs(i, graph, color, topologicalOrder, isDirectedAcyclicGraph); |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | var dfs = (node, graph, color, topologicalOrder, isDirectedAcyclicGraph) => { |
| 53 | const hasCycle = !isDirectedAcyclicGraph[0]; |
Tested by
no test coverage detected