GraphAnalyzer
Stateless graph analysis algorithms that operate on a ModuleDependencyGraph.
All functions are pure - no side effects, no I/O, no mutation. This is the computational heart of Aalekh: every metric, every insight, every rule evaluation starts here.
Properties
Default minimum fan-in for a godModules classification - a module depended on by at least this many others. Shared with HealthScoreCalculator so the two never drift apart.
Default minimum fan-out for a godModules classification - a module depending on at least this many others. Shared with HealthScoreCalculator so the two never drift apart.
Functions
Returns the longest dependency chain (critical path) in the project. Useful for understanding which modules most constrain build parallelism.
Finds cycles using only main (non-test) edges.
Identifies "god modules" - modules with both high fan-in AND high fan-out. These are architectural hotspots that are hard to change and test.
Computes the longest chain of production dependencies as a count of modules. This is the graph height used by the max-graph-height rule and is the primary constraint on build parallelism. Returns 0 when a cycle prevents a topological ordering. Only main edges are considered.
Identifies "isolated modules" - modules with neither dependents nor dependencies. These are candidates for removal.
Identifies "leaf modules" - modules with no outgoing production dependencies. These should ideally be domain/model modules.
Returns all pairs of modules that share a significant number of common dependents, suggesting they might be tightly coupled and should be merged or extracted.
Identifies "root modules" - modules that nobody depends on. There should typically be exactly one (the app module).
Computes a summary of the graph suitable for the report header and metadata. Cycle detection uses main-only edges (test deps excluded).
Returns modules in topological order (dependencies before dependents). Throws IllegalStateException if the graph contains cycles. Uses Kahn's algorithm (BFS-based) for deterministic ordering.