fanIn method
How many project files depend on each file — its fan-in. Every node is a key, so a file nothing imports reads 0.
Implementation
Map<String, int> fanIn() {
final counts = {for (final file in edges.keys) file: 0};
for (final targets in edges.values) {
for (final target in targets) {
counts[target] = (counts[target] ?? 0) + 1;
}
}
return counts;
}