Skip to content

Conversation

@sakshamkhowala
Copy link

Topological-Sort-BFS

Topological sorting for Directed Acyclic Graph (DAG) is a linear ordering of vertices such that for every directed edge u->v, vertex u comes before v in the ordering. Topological Sorting for a graph is not possible if the graph is not a DAG.

Intuition- indegree zero nodes won't have any edges so they are placed before. Indegree is being reduced as zero indegree nodes were taken beforehand. We do this using a queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant