MCPcopy Index your code
hub / github.com/deepnote/deepnote / dfs

Function dfs

packages/cli/src/utils/analysis.ts:341–363  ·  view source on GitHub ↗
(nodeId: string, path: string[])

Source from the content-addressed store, hash-verified

339 const cycleBlocks = new Set<string>()
340
341 function dfs(nodeId: string, path: string[]): void {
342 visited.add(nodeId)
343 recursionStack.add(nodeId)
344
345 const neighbors = graph.get(nodeId) ?? new Set()
346 for (const neighbor of neighbors) {
347 if (!visited.has(neighbor)) {
348 dfs(neighbor, [...path, nodeId])
349 } else if (recursionStack.has(neighbor)) {
350 // Found a cycle - mark all nodes in the cycle
351 const cycleStart = path.indexOf(neighbor)
352 if (cycleStart !== -1) {
353 for (let i = cycleStart; i < path.length; i++) {
354 cycleBlocks.add(path[i])
355 }
356 }
357 cycleBlocks.add(neighbor)
358 cycleBlocks.add(nodeId)
359 }
360 }
361
362 recursionStack.delete(nodeId)
363 }
364
365 for (const node of dag.nodes) {
366 if (!visited.has(node.id)) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected