Graph Tools
Every dependency chain is an edge list until someone makes it queryable.
Commands
python3 scripts/graph_tools.py deps.json --stats
python3 scripts/graph_tools.py deps.json --path ui database
python3 scripts/graph_tools.py deps.json --fail-on-cycle # CI: assert DAG
Input
{"edges": [["ui", "api"], ["api", "db"], ["db", "cache"]]}
Reports
- Node/edge counts, in/out degree per node (
--stats) - Cycles as readable paths (
a -> b -> c -> a), exit 1 when found - Shortest path via BFS (
--path FROM TO), exit 1 when none --fail-on-cyclefor CI gates on pipelines, imports, migrations
Pairs with
gate-graph (module overlap via AST fingerprints — the code-level view;
this is the structure-level view), json-diff (compare two graph snapshots).