MCPcopy Index your code
hub / github.com/simstudioai/sim / dfs

Function dfs

apps/sim/lib/table/workflow-columns.ts:949–964  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

947 const stack: string[] = []
948
949 const dfs = (id: string): string[] | null => {
950 if (state.get(id) === VISITED) return null
951 if (state.get(id) === VISITING) {
952 const cycleStart = stack.indexOf(id)
953 return cycleStart >= 0 ? [...stack.slice(cycleStart), id] : [id]
954 }
955 state.set(id, VISITING)
956 stack.push(id)
957 for (const next of adjacency.get(id) ?? []) {
958 const found = dfs(next)
959 if (found) return found
960 }
961 stack.pop()
962 state.set(id, VISITED)
963 return null
964 }
965
966 for (const g of groups) {
967 const cycle = dfs(g.id)

Callers 1

findGroupCycleFunction · 0.85

Calls 3

getMethod · 0.65
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected