更新时间:2023-11-26 08:10:04
两种方法:
反转图形并计算DFS-loop()并注意没有出边的顶点(如Abhishek说的那样)。
Reverse the graph and calculate DFS-loop() and note the vertices which have no outgoing edges (like Abhishek said).
更高效-使用真,假表在图形上运行DFS-loop()并跟踪没有传入边的顶点。
More efficient - Run DFS-loop() on the graph and keep track of vertices with no incoming edges using a true, false table.
在最坏的情况下,方法1花费的时间是原来的两倍。
Method 1 takes twice as long in the worst case.