Skip to main content

Crate normalize_graph

Crate normalize_graph 

Source
Expand description

Pure graph algorithms for dependency analysis.

Operates on abstract graphs represented as adjacency lists (HashMap<String, HashSet<String>>). No filesystem, CLI, or normalize-specific types.

Algorithms: Tarjan SCC, bridge-finding, diamond detection, transitive edge detection, longest chains, weakly connected components.

Structs§

BlastRadius
Blast radius summary statistics (modules graph only).
BridgeEdge
A bridge edge whose removal disconnects the graph.
DependentEntry
A file that depends on the query target (modules graph only).
DependentsReport
Report for reverse dependency queries: what depends on a given file/symbol.
Diamond
A diamond dependency: source imports left and right, both import target.
GraphReport
Full graph analysis report.
GraphStats
Overall graph statistics.
ImportChain
A deep import chain (longest dependency path).
Scc
A strongly connected component (circular-dependency cluster).
TransitiveEdge
A transitive (redundant) import: A→C is redundant because A→B→C.

Enums§

GraphTarget
What the graph nodes represent.

Functions§

all_nodes
Collect all nodes from the import graph.
analyze_graph_data
Analyze graph-theoretic properties of an abstract dependency graph.
count_transitive_edges
Count all transitive edges (without limit, for stats).
edge_count
Count directed edges.
find_bridges
Bridge finding via Tarjan’s bridge algorithm on the undirected view. Only report bridges where exactly one directed edge exists (bidirectional ≠ bridge).
find_dead_nodes
Find nodes with no inbound edges (nothing imports/calls them) that do have outbound edges (they import/call something). These are unreachable internal nodes — potential dead code. Entry points (main.rs, lib.rs) are included; callers can filter based on their heuristics.
find_dependents
Find all nodes that (transitively) depend on target via BFS on the reverse graph. Returns a sorted list excluding the target itself.
find_diamonds
Diamond detection: for each node A with imports {B₁,B₂,…}, check pairs for shared targets.
find_longest_chains
Find the longest import chains (dependency paths) in the graph.
find_sccs
Find nontrivial SCCs (size > 1) with internal edge counts.
find_transitive_edges
Transitive edge detection: A→C is redundant if ∃B: A→B and B→C.
longest_path_from
Find the longest path from a node using DFS with memoization.
reverse_graph
Build the reverse (transposed) graph: edges point from target to source.
tarjan_sccs
Iterative Tarjan’s SCC algorithm.
weakly_connected_components
Weakly connected components via BFS on the undirected view.