Topological sort

is this a kahns algorithm??

yes it is kahns algorithm.
Here as well we compute indegree of each node and put zero indegree vertex to queue same as in kahns algo.

And if I have a graph something which have different parts something similar to disconnected graph in undirected graph then how to find topological sort??

Then you can only find topological sorting of individual connected components and for that you can keep a visited array and make call to each node that is not visited for same topological sort function and update vertices that are visited
This step is same as finding bfs of different connected components

Ohk thanks… … …

Hey, if you feel that your doubt has been resolved then please mark it as resolved and rate your experience here.
And on the off chance if you have doubt left then you can reopen the doubt.
Thanks

Where to rate?? …

Just mark it as resolved
Thanks