zoukankan      html  css  js  c++  java
  • graph-SCC

    strongly connected component(SCC): 里面的任一对顶点都是互相可达的。

    一个有向图,将每个SCC缩成一个点,那么这个图就变成了DAG(有向无环图)。

    原图进行DFS之后,使post (u)最大的u点必然在source中.

    如果C和C'是两个不同的SCC,一条边从C到C',那么C中post值最大的值一定比C'中最大的要大。

    寻找SCC的算法:

    1 call DFS (G) to compute finishing times post[u] for each vertex u

    2 compute GT // GT 即对G中的边取反后得到的图。取反后,SCC内部仍然是通的,但SCC之间就不再是连通的了。
    3 call DFS (GT), but in the main loop of DFS, consider the vertices in order of decreasing post[u]

    4 output the vertices of each tree in the depth-first forest formed in step 3 as a SCC

    计算GT的时间:O(V+E)
    两次DFS的时间:O(V+E)
    总时间: O(V+E)

    算法实现:


  • 相关阅读:
    condition精准控制
    Juc(上)
    算法和空间复杂度分析
    ReentrantLock
    死锁
    互斥锁
    线程常用方法
    多线程售票与同步机制
    线程的7种状态
    selenium 自动刷司法课
  • 原文地址:https://www.cnblogs.com/pxy7896/p/6581033.html
Copyright © 2011-2022 走看看