I wonder if you could help me with a simple implementation for detecting cycles in a directed graph in C#.
I've read about the algorithms but I'd like to find something already implemented, very simple and short开发者_开发百科.
I don't care about the performance because the data size is limited.
Check out QuickGraph - it has loads of the algorithms implemented and it's quite a nice library to use.
Run a DFS on G and check for backedges.
At every node you expand just check if it is already in the currrent path.
精彩评论