Topological order using bfs

前端 未结 3 1103
后悔当初
后悔当初 2020-12-21 05:05

The following question was found in Sedgewick and Wayne book about algorithms in java:

4.2.19 Topological sort and BFS. Explain why the followin

3条回答
  •  春和景丽
    2020-12-21 05:37

    Counter-example:

    A -> B
    A -> C
    B -> C
    

    BFS starting at A could find the nodes in order A-B-C or A-C-B, but only one of those is a topological sort.

提交回复
热议问题