Topological sort

whitehousechef·2023년 9월 17일
0

https://freedeveloper.tistory.com/390

This explains well but basically it is for DAG (directed so has direction). We put all nodes with indegree 0 in the queue and traverse their children nodes and minus their indegrees in the process. If their indegrees are subtracted to value 0, only then we add them to our queue to be traversed.

This sort is used for calculating reachability or determining the order in which elements should be arranged.

0개의 댓글