MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / capped

Function capped

graph-ui/src/architecture/semantic-graph.ts:572–579  ·  view source on GitHub ↗
(candidates: SemanticNode[], relations: SemanticEdge[])

Source from the content-addressed store, hash-verified

570 const filter = options.filter?.trim().toLowerCase();
571 const matching = new Set<string>();
572 const capped = (candidates: SemanticNode[], relations: SemanticEdge[]) => {
573 const degrees = new Map<string, number>();
574 for (const edge of relations) for (const id of [edge.source, edge.target]) degrees.set(id, (degrees.get(id) ?? 0) + edge.count);
575 return [...candidates].sort((a, b) => (a.id === rootId ? -1 : b.id === rootId ? 1 : 0)
576 || Number(matching.has(b.id)) - Number(matching.has(a.id))
577 || (a.depth ?? 0) - (b.depth ?? 0) || (degrees.get(b.id) ?? 0) - (degrees.get(a.id) ?? 0) || compare(a.id, b.id))
578 .slice(0, bounded(options.maxNodes, 40, 80)).sort((a, b) => compare(a.id, b.id));
579 };
580 const unfiltered = capped(nodes, edges);
581 if (filter) {
582 // A filter that names a route group's prefix selects exactly that group's

Callers 1

buildSemanticGraphFunction · 0.85

Calls 3

compareFunction · 0.70
boundedFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected