Skip to main content

Module graph_analysis

Module graph_analysis 

Source
Expand description

Static dependency-graph analyses (God-Nodes, import cycles).

These run on the real directed dependency edges — import and reexport — and deliberately exclude the co-location heuristics (sibling, cochange) and the ambiguous module edges. That way the results reflect genuine code dependencies (graphify-style) instead of directory layout coincidences.

Structs§

BridgeCentrality
Betweenness result with sampling provenance, so callers can disclose when the values are an estimate (large graphs) rather than the exact Brandes result.
BridgeNode
A file with high betweenness centrality.
GodNode
A highly connected file in the dependency graph.
ImportCycle
A circular dependency: a set of files that import each other.
SurprisingConnection
An unexpected coupling between two files.

Constants§

DEP_EDGE_KINDS
Edge kinds that represent a genuine directed code dependency (from depends on to).

Functions§

compute_bridge_centrality
Like compute_bridge_nodes but also reports whether the result was sampled and over how many sources, for honest disclosure in reports/UI.
compute_bridge_nodes
Returns the top limit bridge nodes (betweenness > 0), highest first. Thin wrapper over compute_bridge_centrality for callers that don’t need the sampling metadata.
compute_god_nodes
Ranks files by total dependency degree (fan-in + fan-out) and returns the top limit. Deterministic: ties broken by path so the output is stable across rebuilds.
dependency_edges
Directed dependency edges as (from, to) pairs, with self-loops removed. Borrows from edges to avoid allocating new strings.
edge_confidence
Confidence that an edge represents a real relationship, in 0.0..=1.0.
find_import_cycles
Finds import cycles (SCCs of size >= 2), largest first, capped at limit. Output is deterministic.
find_surprising_connections
Returns the top limit surprising connections, highest score first. Deterministic. community maps file path → community id (may be partial).
is_dependency_kind
True when an edge kind is a genuine directed dependency.