开发者

Simple implementation for detecting cycles in a directed graph in C#

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜