Channi Studies

[Data Structure] Graph: Topological Sort 본문

Data Science/Data Structure & Algorithm

[Data Structure] Graph: Topological Sort

Chan Lee 2025. 5. 28. 05:02

topological sort of a directed, acyclic graph produces a list of graph's vertices such that for every edge from a vertex X to a vertex Y, X comes before Y in the list. 

There can be more than one valid topoligcal sort. Again, the graph must be acyclic and riected in order to apply topological sorting. 

 

The time complexity and space complexity of topological sorting is O(|V| + |E|).