I was trying to write code for detecting a cycle in a directed graph and if there is no cycle then return a topological order of the same.
While I was searching for it I came across different techniques like DFS and topological sorting to detect cycle in a directed graph.
Is there any difference between these two?
Well, topological sorting is a specific order of the nodes of a directed acyclic graph, which can be achieved by depth-first search. Besides depth-first search, there are other methods to find the topological order, like the Kahn's algorighm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With