MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / getConnectedNodeIds

Function getConnectedNodeIds

yaml-flow-editor/src/utils/layout.ts:194–219  ·  view source on GitHub ↗
(nodeId: string, edges: FlowEdge[])

Source from the content-addressed store, hash-verified

192 * Uses edges as undirected: two nodes are in the same flow if there is a path of edges between them.
193 */
194export 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.

Callers 1

resolveOverlapsForNodeFunction · 0.85

Calls 2

addFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected