MCPcopy
hub / github.com/FlowiseAI/Flowise / getAllConnectedNodes

Function getAllConnectedNodes

packages/server/src/utils/index.ts:266–287  ·  view source on GitHub ↗
(graph: INodeDirectedGraph, startNodeId: string)

Source from the content-addressed store, hash-verified

264 * @param {string} startNodeId
265 */
266export const getAllConnectedNodes = (graph: INodeDirectedGraph, startNodeId: string) => {
267 const visited = new Set<string>()
268 const queue: Array<[string]> = [[startNodeId]]
269
270 while (queue.length > 0) {
271 const [currentNode] = queue.shift()!
272
273 if (visited.has(currentNode)) {
274 continue
275 }
276
277 visited.add(currentNode)
278
279 for (const neighbor of graph[currentNode]) {
280 if (!visited.has(neighbor)) {
281 queue.push([neighbor])
282 }
283 }
284 }
285
286 return [...visited]
287}
288
289/**
290 * Get ending node and check if flow is valid

Callers 2

executeUpsertFunction · 0.90
buildFlowFunction · 0.85

Calls 1

addMethod · 0.45

Tested by

no test coverage detected