开发者

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

开发者 https://www.devze.com 2023-03-14 04:32 出处:网络
I wonder if you could help me with a 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

精彩评论

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