更改

删除52字节 、 2020年10月27日 (二) 16:47
无编辑摘要
第50行: 第50行:       −
关于环在有向或无向图中的存在,可以通过'''深度优先搜索(DFS depth-first search)'''来确定。具体方法是查找是否存在一条连边指向当前顶点的原始点(包括回边)。<ref>{{cite book|last=Tucker|first=Alan|authorlink=Alan Tucker|title=Applied Combinatorics |year=2006|publisher=John Wiley & sons|location=Hoboken|isbn=978-0-471-73507-6|edition=5th|page=49|chapter=Chapter 2: Covering Circuits and Graph Colorings}}</ref>DFS跳过的所有回边都是环的一部分。<ref name="sedgewick">{{citation | first=Robert | last=Sedgewick | author-link=Robert Sedgewick (computer scientist) | title=Algorithms | chapter=Graph algorithms | year=1983 | publisher=Addison–Wesley | isbn=0-201-06672-6 | url-access=registration | url=https://archive.org/details/algorithms00sedg }}</ref>在无向图中,指向一个节点上级的连边不应算作后边,但是如果找到任何其他已访问的顶点可以视为后边。在无向图的情况下,只需要O(n)时间即可在n个顶点图中找到一个循环,因为最多n-1个边可以是树边。
+
关于环在有向或无向图中的存在,可以通过'''深度优先搜索(DFS depth-first search)'''来确定。具体方法是查找是否存在一条连边指向当前顶点的原始点(包括回边)。<ref>{{cite book|last=Tucker|first=Alan|authorlink=Alan Tucker|title=Applied Combinatorics |year=2006|publisher=John Wiley & sons|location=Hoboken|isbn=978-0-471-73507-6|edition=5th|page=49|chapter=Chapter 2: Covering Circuits and Graph Colorings}}</ref>DFS跳过的所有回边都是环的一部分。<ref name="sedgewick">{{citation | first=Robert | last=Sedgewick | title=Algorithms | chapter=Graph algorithms | year=1983 | publisher=Addison–Wesley | isbn=0-201-06672-6 | url-access=registration | url=https://archive.org/details/algorithms00sedg }}</ref>在无向图中,指向一个节点上级的连边不应算作后边,但是如果找到任何其他已访问的顶点可以视为后边。在无向图的情况下,只需要O(n)时间即可在n个顶点图中找到一个循环,因为最多n-1个边可以是树边。