Section 4.8Source:
server/src/analytics/paths/CallPathAnalyzer.tsCall Path Reachability
Finding whether a directed call chain exists between two specific symbols using iterative DFS with parent backtracking.
Source:
server/src/analytics/paths/CallPathAnalyzer.tsDFS Path-Finding with Early Exit
CallPathAnalyzer finds a call chain connecting sourceNodeId to targetNodeIdfollowing strictly "calls" edges between symbol nodes:
server/src/analytics/paths/CallPathAnalyzer.ts
1234567891011121314151617181920212223242526272829303132333435363738394041export class CallPathAnalyzer { analyze(sourceNodeId: string, targetNodeId: string): CallPathResult { if (sourceNodeId === targetNodeId) { return { sourceNodeId, targetNodeId, path: [sourceNodeId] }; } const visited = new Set<string>([sourceNodeId]); const stack = [sourceNodeId]; const parent = new Map<string, string>(); while (stack.length > 0) { const current = stack.pop()!; for (const edgeId of this.graph.outgoingEdges.get(current) || []) { const edge = this.graph.edges.get(edgeId); if (!edge || edge.relationshipKind !== "calls") continue; const targetNode = this.graph.nodes.get(edge.targetId); if (!targetNode || targetNode.kind !== "symbol") continue; if (!visited.has(edge.targetId)) { visited.add(edge.targetId); parent.set(edge.targetId, current); // Early exit when target is found! if (edge.targetId === targetNodeId) { return { sourceNodeId, targetNodeId, path: this.buildPath(sourceNodeId, targetNodeId, parent), }; } stack.push(edge.targetId); } } } return { sourceNodeId, targetNodeId, path: null }; } }