diff --git a/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts b/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts index d77155b..e2dd645 100644 --- a/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts +++ b/understand-anything-plugin/packages/core/src/analyzer/graph-builder.ts @@ -127,6 +127,7 @@ export class GraphBuilder { private readonly edges: GraphEdge[] = []; private readonly languages = new Set(); private readonly nodeIds = new Set(); + private readonly edgeKeys = new Set(); private readonly projectName: string; private readonly gitHash: string; @@ -235,6 +236,9 @@ export class GraphBuilder { } addImportEdge(fromFile: string, toFile: string): void { + const key = `imports|file:${fromFile}|file:${toFile}`; + if (this.edgeKeys.has(key)) return; + this.edgeKeys.add(key); this.edges.push({ source: `file:${fromFile}`, target: `file:${toFile}`, @@ -250,6 +254,9 @@ export class GraphBuilder { calleeFile: string, calleeFunc: string, ): void { + const key = `calls|function:${callerFile}:${callerFunc}|function:${calleeFile}:${calleeFunc}`; + if (this.edgeKeys.has(key)) return; + this.edgeKeys.add(key); this.edges.push({ source: `function:${callerFile}:${callerFunc}`, target: `function:${calleeFile}:${calleeFunc}`,