MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / applyGraphFilters

Function applyGraphFilters

dashboard/graph/src/explorerState.ts:37–56  ·  view source on GitHub ↗
(
  graphNodes: Iterable<GraphNode>,
  graphEdges: Iterable<GraphEdge>,
  { kindFilters = new Set(), langFilters = new Set(), dirScope = "" }: GraphFilters = {},
)

Source from the content-addressed store, hash-verified

35}
36
37export function applyGraphFilters(
38 graphNodes: Iterable<GraphNode>,
39 graphEdges: Iterable<GraphEdge>,
40 { kindFilters = new Set(), langFilters = new Set(), dirScope = "" }: GraphFilters = {},
41) {
42 const nodes: GraphNode[] = [];
43 const keep = new Set<string>();
44 for (const node of graphNodes) {
45 if (kindFilters.size > 0 && !kindFilters.has(kindFamily(node.kind))) continue;
46 if (langFilters.size > 0 && !langFilters.has(languageForPath(node.file_path))) continue;
47 if (dirScope && !node.file_path.startsWith(dirScope)) continue;
48 nodes.push(node);
49 keep.add(node.id);
50 }
51 const edges: GraphEdge[] = [];
52 for (const edge of graphEdges) {
53 if (keep.has(edge.source) && keep.has(edge.target)) edges.push(edge);
54 }
55 return { nodes, edges };
56}
57
58export function deriveChipOptions(graphNodes: Iterable<GraphNode>) {
59 const families = new Set<string>();

Callers 1

CodeGraphExplorerFunction · 0.90

Calls 4

kindFamilyFunction · 0.90
languageForPathFunction · 0.90
pushMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected