Topological Sort in Graphs
This lesson will teach you how to write a recursive code for topological sorting in graphs.
What is Topological Sort?
Topological Sort is a way to order a directed acyclic graph. A directed graph has edges that are incoming or outgoing, meaning that they have a specific direction. An acyclic graph has no cycles, i.e., a node is not reachable from its ancestors. A topological sort takes a graph and finds the order of its nodes so it always starts from a node that has no incoming edges and then traverses the adjacent nodes. Note that the current node is before its adjacent. The illustration below will help explain this concept better.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.