* Calculate the impact radius of a node * * Returns all nodes that could be affected by changes to this node. * * @param nodeId - ID of the node * @param maxDepth - Maximum depth to traverse (default: 3) * @returns Subgraph containing potentially impacted nodes
(nodeId: string, maxDepth: number = 3)
| 518 | * @returns Subgraph containing potentially impacted nodes |
| 519 | */ |
| 520 | getImpactRadius(nodeId: string, maxDepth: number = 3): Subgraph { |
| 521 | const focalNode = this.queries.getNodeById(nodeId); |
| 522 | if (!focalNode) { |
| 523 | return { nodes: new Map(), edges: [], roots: [] }; |
| 524 | } |
| 525 | |
| 526 | const nodes = new Map<string, Node>(); |
| 527 | const edges: Edge[] = []; |
| 528 | const visited = new Set<string>(); |
| 529 | |
| 530 | // Add focal node |
| 531 | nodes.set(focalNode.id, focalNode); |
| 532 | |
| 533 | // Traverse incoming edges to find all dependents |
| 534 | this.getImpactRecursive(nodeId, maxDepth, 0, nodes, edges, visited); |
| 535 | |
| 536 | return { |
| 537 | nodes, |
| 538 | edges, |
| 539 | roots: [nodeId], |
| 540 | }; |
| 541 | } |
| 542 | |
| 543 | private getImpactRecursive( |
| 544 | nodeId: string, |
no test coverage detected