Finding Strongly Connected Components?

北慕城南 提交于 2019-12-13 04:34:35

问题


My book defines a method to find the strongly connected components of a directed graph in linear time. In addition several other algorithms to find strongly connected components (i.e. Tarjan's algorithm) is also able to find the components in linear time.

However all of these algorithms require the vertices of the graph to be ordered in decreasing post values (time the vertex is left). Common ordering algorithms such as Mergesort take O(n log n) time.

Therefore how do these algorithms manage to complete locating the strongly connected components in linear time, if ordering the list of vertices by post values takes O(n log n) time?


回答1:


Since "time" (the kind by which the post values are measured) is monotonically nondecreasing as a function of time (the number of steps executed by the depth-first search program), it suffices to append each node to a list immediately after the traversal leaves it. At the end of the traversal, the list is in sorted order.

Alternatively, since the post values are integers bounded above polynomially, on some machine models it is possible to sort them in linear time using e.g. radix sort.



来源:https://stackoverflow.com/questions/11093690/finding-strongly-connected-components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!