00:00Now we are going to talk about cycle detection in graphs. In graphs we have already talked about that there
00:06is no big difference in cycles. In trees, cycles don't exist. Link lists exist in my link lists, but they
00:12are wrong with my link lists. But in graphs, there are so many cases in many cases that cycles exist.
00:18So, it is very important to detect that a graph exists in a cycle exists or does not exist. Now,
00:24there are many different ways in graphs. There are so many different algorithms.
00:29Actually my undirected graph, we can also use DFS and BFS. Along with that, we can also use a disjoint
00:39set union for undirected graph. Besides, cycles exist in a directed graph. We can also use DFS and BFS. Besides,
00:56there is a topological sort.
00:58we can use this to detect cycle. Here we have Kahn's algorithm.
01:03We will learn how to detect a directed graph in a directed graph. Usually, we will use the cycle detection
01:10algorithm in most cases. In your general interview or coding test, we generally use DFS because DFS algorithm is very
01:19similar. It is very instinctive, it remains a lot. Plus, our memory consumption is enough. DFS is a little efficient
01:28method of DFS. That's why we usually use DFS.
01:32But if you want to use DFS for your cycle detection then there is no problem. So we will cover
01:37which algorithms. We will talk about DFS for undirected graphs. We will talk about DFS for directed graphs. We will
01:44also talk about topological sort. Then we will talk about KANZ algorithms. Now how does the cycle exist in undirected
01:49graphs? If I make a graph like this, this is a node, this is a node, this is a node,
01:55this is a node, this is a node, and I connect a edge from here. So what happened?
02:23different cycles exist in graphs which we have to detect