美文网首页
Strongly Connected in Graph强连通

Strongly Connected in Graph强连通

作者: 程序猪小羊 | 来源:发表于2018-02-12 03:13 被阅读19次

In the mathematical theory of directed graphs, a graph is said to be strongly connected or diconnected if every vertex is reachable from every other vertex.

有向图强连通分量的Tarjan算法

(“郭家寶”,个人网站byvoid.com 的页面
强烈推荐大神的博客)
直接根据定义,用双向遍历取交集的方法求强连通分量,时间复杂度为O(N^2+M)。更好的方法是Kosaraju算法或Tarjan算法,两者的时间复杂度都是O(N+M)。本文介绍的是Tarjan算法。

Graph Traversal Algorithms

This visualization is rich with a lot of DFS and BFS variants (all run in O(V+E)) such as:

* Topological Sort algorithm (both DFS and BFS/Kahn's algorithm version),
* Bipartite Graph Checker algorithm (both DFS and BFS version),
* Cut Vertex & Bridge finding algorithm,
* Strongly Connected Components (SCC) finding algorithms
(both Kosaraju's and Tarjan's version), and
2-SAT Checker algorithm.

Tarjan algorithm
undefined?
function strongconnect()

v.index
v.lowlink

Kosaraju algorithm

  1. G_rev
  2. DFS求G_rev的逆后排序
  3. 对逆后排序再次进行DFS
  4. 同一个SCC:同一个DFS recursion访问的所有顶点。

Strongly Connected Components Kosaraju's Algorithm Graph Algorithm

相关文章

网友评论

      本文标题:Strongly Connected in Graph强连通

      本文链接:https://www.haomeiwen.com/subject/tbmctftx.html