Section 5.4Source:
server/src/analytics/paths/CallPathAnalyzer.tsIterative Depth-First Search
Stack-based iterative DFS with early target termination and parent map backtracking for call chain discovery.
Source:
server/src/analytics/paths/CallPathAnalyzer.tsMemory Efficiency: Parent Map vs Path Array Passing
Passing active path arrays down recursion branches incurs an O(depth × branching) memory overhead due to repetitive array allocations.
CodeGraph records parent pointers in a flat parent: Map<string, string> that costs onlyO(V) space. When the target node is reached, the path is reconstructed backwards inO(path length) time:
Path Backtracking Implementation
12345678910111213private buildPath(sourceNodeId: string, targetNodeId: string, parent: Map<string, string>): string[] { const path: string[] = []; let current: string | undefined = targetNodeId; while (current !== undefined) { path.push(current); if (current === sourceNodeId) break; current = parent.get(current); } path.reverse(); // [source -> ... -> target] return path; }