(candidates: SemanticNode[], relations: SemanticEdge[])
| 570 | const filter = options.filter?.trim().toLowerCase(); |
| 571 | const matching = new Set<string>(); |
| 572 | const capped = (candidates: SemanticNode[], relations: SemanticEdge[]) => { |
| 573 | const degrees = new Map<string, number>(); |
| 574 | for (const edge of relations) for (const id of [edge.source, edge.target]) degrees.set(id, (degrees.get(id) ?? 0) + edge.count); |
| 575 | return [...candidates].sort((a, b) => (a.id === rootId ? -1 : b.id === rootId ? 1 : 0) |
| 576 | || Number(matching.has(b.id)) - Number(matching.has(a.id)) |
| 577 | || (a.depth ?? 0) - (b.depth ?? 0) || (degrees.get(b.id) ?? 0) - (degrees.get(a.id) ?? 0) || compare(a.id, b.id)) |
| 578 | .slice(0, bounded(options.maxNodes, 40, 80)).sort((a, b) => compare(a.id, b.id)); |
| 579 | }; |
| 580 | const unfiltered = capped(nodes, edges); |
| 581 | if (filter) { |
| 582 | // A filter that names a route group's prefix selects exactly that group's |
no test coverage detected