There are different ways of detecting cycle in a graph. Let us understand how to detect cycles in an undirected graph using the degree of each vertex.
Introduction
Our objective is to check if a cycle exists in an undirected graph. What is a cycle ? A graph that has a number of vertices connected in a close chain, is said to contain a cycle or a loop.
Look at the graph below :

Fig. 1
There is a cycle formed by the nodes 0,3,1 and 5.
NOTE : Self loops are also considered as a cycle in the graph....
Published on November 02, 2020 22:59