Edit page

Detect cycle

In graph theory, a cycle in a graph is a non-empty trail in which the only repeated vertices are the first and last vertices. A directed cycle in a directed graph is a non-empty directed trail in which the only repeated vertices are the first and last vertices.

A graph without cycles is called an acyclic graph. A directed graph without directed cycles is called a directed acyclic graph. A connected graph without cycles is called a tree. [Source: Wikipedia]

References

  • Geeksforgeeks
  • Geeksforgeeks
  • Wikipedia
  • cp-algorithms