GraphFilter

Produces a subset of a module graph for export - the machinery behind the mermaid { } focus/exclude filters that keep a large graph's diagram readable.

Two independent selectors, applied in order:

  1. focus - if any focus glob is given, start from the modules that match and grow outward by up to neighborDepth hops along dependency edges in either direction (dependencies and dependents), so the focused modules keep their immediate context. An empty focus list keeps every module.

  2. exclude - then drop any surviving module matching an exclude glob (e.g. :test:**).

An edge is kept only when both of its endpoints survive. The result carries the original projectName and metadata. This is a pure function - no Gradle, no I/O - so it is fully unit-tested and reused unchanged by the Mermaid and DOT generators.

Functions

Link copied to clipboard
fun filter(graph: ModuleDependencyGraph, focus: List<String>, exclude: List<String>, neighborDepth: Int): ModuleDependencyGraph

Returns graph restricted by focus / exclude globs. When both lists are empty the graph is returned unchanged (the common no-filter case), so existing exports are byte-for-byte identical.