Lazeeez / HacktoberFest-21

A mentorship initiative to help beginners kickstarting their open-source journey by completing Hacktoberfest'21 challenge | Curated list of beginner-friendly issues for Hacktoberfest 2021 | Raise PR to add your issues
MIT License
26 stars 73 forks source link

TopologicalSort-BFS #21

Closed dhruviagrawal closed 3 years ago

dhruviagrawal commented 3 years ago

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.

Lazeeez commented 3 years ago

@dhruviagrawal Add a little description about the implementation, thanks.

dhruviagrawal commented 3 years ago

Is this sufficient or should I give an explanation of the entire code?

Lazeeez commented 3 years ago

Is this sufficient or should I give an explanation of the entire code?

It's enough. thanks for your contribution. Make sure you star the repository for the confirmation.