madge does not detect all circular dependencies or even all files with circular dependencies. I think this is a fundamental issue with the algorithm in cyclic.js. (There may be some good suggestions in here: https://stackoverflow.com/questions/546655/finding-all-cycles-in-a-directed-graph)
I created some minimal test cases here (including graphviz diagrams in case that helps):
yoz@847668f
Explanation:
- "defg" case: There are two cycles:
d -> e -> g -> d and d -> f -> g -> d. However, madge never reports the d -> f -> g case (or indeed that f belongs to a cycle), regardless of which file(s) we use as the starting input.
- "bcdeg" case: There are two cycles:
d -> c -> g -> d and d -> e -> g -> d.
- This is equivalent to the "defg" case (but with 'c' instead of 'f'). Yet the madge output is different - it finds all the cycles.
- But if we add a dependency
b -> d and start at b, madge no longer reports one of the cycles.
madge does not detect all circular dependencies or even all files with circular dependencies. I think this is a fundamental issue with the algorithm in
cyclic.js. (There may be some good suggestions in here: https://stackoverflow.com/questions/546655/finding-all-cycles-in-a-directed-graph)I created some minimal test cases here (including graphviz diagrams in case that helps):
yoz@847668f
Explanation:
d -> e -> g -> dandd -> f -> g -> d. However, madge never reports thed -> f -> gcase (or indeed thatfbelongs to a cycle), regardless of which file(s) we use as the starting input.d -> c -> g -> dandd -> e -> g -> d.b -> dand start atb, madge no longer reports one of the cycles.