Strongly connected components [k algorithm, t algorithm]

A connected component is a graph whose vertices can reach each other

The connected component of the undirected graph can select any vertex and use DFS to traverse it. The number of DFS required to traverse all the vertices is the number of connected components.

Since the strongly connected component of a directed graph is directed [DFS can access point B from point A, but it may not be able to return to A from point B], it cannot simply be considered that traversing the vertices is enough, then only the correct one can be selected. Vertex order DFS to get correct results. There is a very well written blog, Amway has a wave: https://www.cnblogs.com/nullzx/p/6437926.html

k algorithm: by inverting the graph, and then DFS post-order traversal [that is, traverse all unvisited vertices of unvisited vertices first, and then traverse the point] put the point into the stack, from the top of the stack [the last one pushed onto the stack] ] The beginning is a correct sequence that meets the above requirements.

t-algorithm: Time complexity is better than k-algorithm. Mainly through two arrays to record 1) whether the instack[i] vertex is in the recursive stack, and 2) whether the vis[i] vertex is traversed. [If it is not in the stack and is accessed, return directly, you cannot use that point to update the low[u] value of the point in the stack, because it is not in a stack or a ring, and if it is in the stack and It has been visited, indicating that there is a ring, and you can retroactively update the low[u] value of u on the ring] Continue to Amway Blog: [ Blogger Lazy... ] https://blog.csdn.net/qq_16234613/article/details /77431043

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324875522&siteId=291194637