Detecting all circles in a graph

淺唱寂寞╮ 提交于 2019-12-03 20:44:33
DubioserKerl

Since a circle in a directed graph represents a strongly connected component, you can use any of the algorithms referenced on the wikipedia page for finding strongly connected components https://en.wikipedia.org/wiki/Strongly_connected_component - for instance Tarjan's algorithm which is based on depth-first search: https://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm

Edit: It is possible that a strongly connected component contains multiple circles that share nodes with each other. So, a manual checking of each component must follow, but should be easy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!