算法能够执行是因为,如果一个顶点没有后继,那么它肯定是拓扑序列中的最后一个。
The algorithm works because if a vertex has no successors, it must be the last one in the topological ordering.
一旦删除它,剩下的顶点中必然有一个没有后继,所以它成为下一个拓扑序列中的最后一个,依此类推。
As soon as it's removed, one of the remaining vertices must have no successors, so it will be the next-to-last one in the ordering, and so on.
应用推荐