* Build a map of node ID -> child IDs (nodes that depend on this node).
(dag: BlockDependencyDag)
| 208 | * Build a map of node ID -> child IDs (nodes that depend on this node). |
| 209 | */ |
| 210 | function buildChildrenMap(dag: BlockDependencyDag): Map<string, { id: string; variables: string[] }[]> { |
| 211 | const children = new Map<string, { id: string; variables: string[] }[]>() |
| 212 | |
| 213 | for (const edge of dag.edges) { |
| 214 | const existing = children.get(edge.from) ?? [] |
| 215 | existing.push({ id: edge.to, variables: edge.inputVariables }) |
| 216 | children.set(edge.from, existing) |
| 217 | } |
| 218 | |
| 219 | return children |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Build a map of node ID -> DagNode. |