What is a dependency graph?
A dependency graph is a directed graph where each node is an item, such as a package, service or task, and each arrow means one item depends on another. Unlike a tree, a node can have many parents, and cycles can exist.
Read an arrow from the dependent to what it needs. Nodes with many incoming arrows, high fan-in, are the ones whose changes break the most things, and a loop of arrows is a circular dependency.
When to use a dependency graph
- Use it to audit frontend packages or microservices before a refactor or upgrade.
- Use it to find circular dependencies and single points of failure.
- If every item has exactly one parent, a tree diagram is easier to read.
How to make a good dependency graph
- Keep arrows in one direction, from dependent to dependency, throughout.
- Lay it out in layers so most arrows point the same way and cycles stand out.
- Show fan-in counts or size nodes by them to highlight critical items.
- Color cycles in red so they are not missed.