* 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> )
| 619 | * contiguous. They are still drawn, and still counted. |
| 620 | */ |
| 621 | function 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. |