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

Function strongconnect

ui/src/lib/map-model.ts:673–698  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

671 let counter = 0;
672
673 const strongconnect = (id: string): void => {
674 index.set(id, counter);
675 low.set(id, counter);
676 counter += 1;
677 stack.push(id);
678 onStack.add(id);
679 for (const next of out.get(id) ?? []) {
680 if (!index.has(next)) {
681 strongconnect(next);
682 low.set(id, Math.min(low.get(id) ?? 0, low.get(next) ?? 0));
683 } else if (onStack.has(next)) {
684 low.set(id, Math.min(low.get(id) ?? 0, index.get(next) ?? 0));
685 }
686 }
687 if (low.get(id) === index.get(id)) {
688 const component: string[] = [];
689 for (;;) {
690 const popped = stack.pop();
691 if (popped === undefined) break;
692 onStack.delete(popped);
693 component.push(popped);
694 if (popped === id) break;
695 }
696 if (component.length > 2) found.push(component.sort());
697 }
698 };
699
700 for (const id of [...ids].sort()) if (!index.has(id)) strongconnect(id);
701 return found.sort((a, b) => b.length - a.length || (a[0] ?? '').localeCompare(b[0] ?? ''));

Callers 1

moduleCyclesFunction · 0.85

Calls 6

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

Tested by

no test coverage detected