Finding shortest cycles in directed or undirected graph

China☆狼群 提交于 2019-12-24 14:23:48

问题


I'm looking for an algorithm to find the shortest cycle in a directed or undirected graph.

For example, for node 3, the algorithm could return:

  • cycle 1 : 3->10->11->7->8->3
  • cycle 2 : 3->10->9->8->3

For these cycles and the shortest is cycle 2, at four vertices.

I did some research and could find the Dijkstra algorithm, DFS, BFS and some others but they always show a path not a cycle.

PS : the arrows are not significant. Thank you for your help.

来源:https://stackoverflow.com/questions/47795348/finding-shortest-cycles-in-directed-or-undirected-graph

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