(nodeId: string, edges: FlowEdge[])
| 192 | * Uses edges as undirected: two nodes are in the same flow if there is a path of edges between them. |
| 193 | */ |
| 194 | export function getConnectedNodeIds(nodeId: string, edges: FlowEdge[]): Set<string> { |
| 195 | const adj = new Map<string, Set<string>>(); |
| 196 | const add = (a: string, b: string) => { |
| 197 | if (!adj.has(a)) adj.set(a, new Set()); |
| 198 | adj.get(a)!.add(b); |
| 199 | }; |
| 200 | edges.forEach((e) => { |
| 201 | const s = e.source; |
| 202 | const t = e.target; |
| 203 | add(s, t); |
| 204 | add(t, s); |
| 205 | }); |
| 206 | const out = new Set<string>(); |
| 207 | const stack: string[] = [nodeId]; |
| 208 | out.add(nodeId); |
| 209 | while (stack.length > 0) { |
| 210 | const cur = stack.pop()!; |
| 211 | for (const next of adj.get(cur) ?? []) { |
| 212 | if (!out.has(next)) { |
| 213 | out.add(next); |
| 214 | stack.push(next); |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | return out; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Resolve overlaps for a specific node by pushing down overlapping nodes. |
no test coverage detected