Dependency graph operations on the lockfile.
Provides adjacency-list based graph algorithms for analyzing the dependency structure: detecting cycles, computing fan-in/out, and finding orphans.
Summary
Functions
Build an adjacency list from the lockfile.
Detect circular dependencies. Returns list of cycle paths.
Compute fan-in (number of dependents) for each package.
Compute fan-out (number of dependencies) for each package.
Find leaf packages (no dependencies).
Find root packages (not depended on by any other package).
Functions
@spec adjacency_list(%{required(String.t()) => NPM.Lockfile.entry()}) :: %{ required(String.t()) => [String.t()] }
Build an adjacency list from the lockfile.
Returns %{name => [dep_name, ...]}.
Detect circular dependencies. Returns list of cycle paths.
Uses Erlang's :digraph_utils for reliable cycle detection.
@spec fan_in(%{required(String.t()) => [String.t()]}) :: %{ required(String.t()) => non_neg_integer() }
Compute fan-in (number of dependents) for each package.
@spec fan_out(%{required(String.t()) => [String.t()]}) :: %{ required(String.t()) => non_neg_integer() }
Compute fan-out (number of dependencies) for each package.
Find leaf packages (no dependencies).
Find root packages (not depended on by any other package).