MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / visit

Function visit

ui/src/lib/steps-model.ts:676–697  ·  view source on GitHub ↗
(root: string)

Source from the content-addressed store, hash-verified

674 const state = new Map<string, number>();
675 const closes = new Set<WireMapLink>();
676 const visit = (root: string): void => {
677 const stack: { id: string; next: number }[] = [{ id: root, next: 0 }];
678 state.set(root, 1);
679 while (stack.length > 0) {
680 const top = stack[stack.length - 1]!;
681 const list = out.get(top.id) ?? [];
682 if (top.next >= list.length) {
683 state.set(top.id, 2);
684 stack.pop();
685 continue;
686 }
687 const link = list[top.next++]!;
688 const seen = state.get(link.target) ?? 0;
689 if (seen === 1) {
690 closes.add(link);
691 continue;
692 }
693 if (seen === 2) continue;
694 state.set(link.target, 1);
695 stack.push({ id: link.target, next: 0 });
696 }
697 };
698 for (const id of nodes) if (!state.has(id)) visit(id);
699 return links.filter((l) => !closes.has(l));
700}

Callers 1

forwardLinksFunction · 0.70

Calls 4

pushMethod · 0.80
getMethod · 0.65
setMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected