61 votes 61 votes Consider the following directed graph: The number of different topological orderings of the vertices of the graph is _____________. Algorithms gatecse-2016-set1 algorithms graph-algorithms normal numerical-answers topological-sort + – Sandeep Singh asked Feb 12, 2016 • retagged Jan 2 by Hira Thakur Sandeep Singh 28.6k views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments KUSHAGRA गुप्ता commented Feb 2, 2020 i edited by KUSHAGRA गुप्ता Aug 27, 2020 reply Follow Share Caution: For those who might have this query after going through cormen One application of DFS is finding Topological sort But by using DFS you will only get $2$ topological sort$=abcdef,adebcf$ Now between B $\&$ C is there any condition which restricts D coming as per the definition of topological sort $?-NO$ Hence D can come in b/w B $\&$ C and it will not violate the topological sort. But in DFS this case is not possible. That's why DFS can give some topological sort but not possible to get all for some graphs. It's better to approach through brute force. $a|\_|\_|\_|\_|f$ Now, $b$ must come before $c$ $\&$ $d$ must come before $e$. So, let’s write down all possibilities $bcde|bdce|bdec\Rightarrow3$ $debc|dbec|dbce\Rightarrow3$ Total $6$ different possibilities. 5 votes 5 votes Abhrajyoti00 commented Dec 11, 2022 reply Follow Share The best method to find Topological Sort w/o any doubt: All Topological Sorts of a Directed Acyclic Graph - GeeksforGeeks 0 votes 0 votes anshul7 commented Dec 14, 2023 reply Follow Share for undirected graph what is the answer can anybody tell it 0 votes 0 votes Please log in or register to add a comment.
–1 votes –1 votes this is according to me I think it is 8 I may be wrong akashrai110 answered Feb 12, 2016 • edited Feb 12, 2016 by akashrai110 akashrai110 comment Share Follow See 1 comment See all 1 1 comment reply abhilashpanicker29 commented Feb 13, 2016 reply Follow Share in second last one.. f cannot occur before b and c occur,, hence it is wrong 0 votes 0 votes Please log in or register to add a comment.