NPM.GraphOps (NPM v0.6.0)

Copy Markdown View Source

Advanced graph operations on dependency graphs.

Builds on NPM.DepGraph's adjacency list to provide transitive closure, shortest path, depth analysis, and dependency impact scoring.

Summary

Functions

Computes impact score — how many packages transitively depend on a package.

Returns all leaf packages (no dependencies).

Computes the maximum depth of a package in the dependency tree.

Reverses the graph (all edges point the other direction).

Returns all root packages (nothing depends on them).

Finds the shortest path between two packages.

Computes the transitive closure — all reachable packages from a root.

Functions

impact(adj, package)

@spec impact(map(), String.t()) :: non_neg_integer()

Computes impact score — how many packages transitively depend on a package.

leaves(adj)

@spec leaves(map()) :: [String.t()]

Returns all leaf packages (no dependencies).

max_depth(adj, root)

@spec max_depth(map(), String.t()) :: non_neg_integer()

Computes the maximum depth of a package in the dependency tree.

reverse_graph(adj)

@spec reverse_graph(map()) :: map()

Reverses the graph (all edges point the other direction).

roots(adj)

@spec roots(map()) :: [String.t()]

Returns all root packages (nothing depends on them).

shortest_path(adj, from, to)

@spec shortest_path(map(), String.t(), String.t()) :: [String.t()] | nil

Finds the shortest path between two packages.

transitive_deps(adj, root)

@spec transitive_deps(map(), String.t()) :: MapSet.t()

Computes the transitive closure — all reachable packages from a root.