(graph: INodeDirectedGraph, startNodeId: string)
| 264 | * @param {string} startNodeId |
| 265 | */ |
| 266 | export 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 |
no test coverage detected