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

Function barycenter

ui/src/lib/map-model.ts:621–631  ·  view source on GitHub ↗

* A module's horizontal pull: the mean position of everything it connects to. * * A module connected to nothing has no pull, and giving it its own position * back leaves it wherever the alphabet dropped it — which on a repository with * forty leaf directories means forty unconnected boxes interl

(
  id: string,
  neighbours: Map<string, string[]>,
  position: Map<string, number>
)

Source from the content-addressed store, hash-verified

619 * contiguous. They are still drawn, and still counted.
620 */
621function barycenter(
622 id: string,
623 neighbours: Map<string, string[]>,
624 position: Map<string, number>
625): number {
626 const list = neighbours.get(id) ?? [];
627 if (list.length === 0) return Number.POSITIVE_INFINITY;
628 let sum = 0;
629 for (const other of list) sum += position.get(other) ?? 0;
630 return sum / list.length;
631}
632
633/**
634 * A module's layer: one above the deepest thing it depends on.

Callers 1

buildMapLayoutFunction · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected