项目作者: chuazhe

项目描述 :
Cycle Detection for Undirected Graph or Directed Graph Using Recursive Function(Java)
高级语言: Java
项目地址: git://github.com/chuazhe/cycle-detection.git
创建时间: 2018-07-02T13:40:15Z
项目社区:https://github.com/chuazhe/cycle-detection

开源协议:

下载



Cycle Detection for Undirected Graph or Directed Graph Using Recursive Function(Java)


Cycle is a path of edges that traverse from a node to itself or from a node to its starting
vertex. For cycle detection, Depth First Traversal (DFS) can be used to detect cycle in the
graph and able to work on both undirected graph and digraph. The data structure of the
graph is first created by using the graph function and used by the algorithm. The algorithm
is based on the concept of recursion to move to the next adjacent vertices and backtrack
to the previous vertex if there is no other adjacent vertex. For every visited vertex A, if
there is an adjacent vertex B such that B is already visited and B is not the parent vertex of
A, then there is a cycle. If there is not such vertex, then we can say that there is no cycle.