News for hackers. Stuff that matters.
Re:Possibly all the ways to get loop-finding in graphs wrong by zeroonetwothree on Wednesday September 11, 2024 @10:22AM (#41511668)
The most obvious way is to just run a DFS, if you ever come back to a node you’ve seen then you have a cycle (and by storing parent pointers you can get the cycle back). That’s like CS 101 level.

However in the article it’s actually a graph being modified. If you don’t want to run a full dfs every time, there are better ways. This problem is called “online cycle detection” and you can google some other algorithms.

There are no comments on this comment yet.