Closed calebj0seph closed 2 years ago
Sorry about that -- nice catch! I think this was due to an early exit "optimization" in my findCycles
loop that I must've made up all by myself, since I can't find any backing for it in Johnson's algorithm when I look now. I added your test case to the tests and it passes now (fix here).
Thanks for taking the time to implement Tarjan's on Becsy's data structures! I'm going to try sticking to my algorithm for now since it's not clear to me whether Tarjan's finds the smallest possible cycles or just any strongly connected components. (I want to find the smallest cycles as those are the most useful when debugging your system dependencies.)
Please let me know if you find another bug, though, and I'll most likely dump Johnson in favor of Tarjan. :)
I'll publish the fixed version later tonight as 0.10.0.
Thanks @pkaminski, appreciate the super fast fix 😃
Consider the following systems with some trivial scheduling constraints that have a cycle:
World.create()
will happily accept this despite the cycle betweenSystemB -> SystemD -> SystemC -> SystemB
. This has bitten us on our application where we had such a cycle that went undetected. This caused the dependency graph to be broken causing strange behaviour.When we rewrote
findCycles()
using Tarjan's strongly connection component algorithm, it was able to properly detect the cycle: