一、拓扑排序
1、对于一个有向无环图G=(V,E)来说,其拓扑排序是G中所有结点的一种线性次序,该次序满足如下条件:如果图G包含边(u,v),则结点u在拓扑排序中处于结点v的前面(如果图G包含环路,则不可能排出一个线性次序)。可以将图的拓扑排序看做是将图的所有结点在一条水平线上排开,图的所有有向边
都从左指向右。
2、伪代码
TOPOLOGICAL-SORT(G)
call DFS(G) to compute finishing times v.f for each vertex v
as each vertex is finished, insert it onto the front of a linked list
return the linked list of vertices
3、引理
二、强连通分量
将有向图通过深度优先搜索来转化为强连通分量
1、有向图G= (V, E)的强连通分量是一个最大结点集合C包含于V,对于该集合中的任意一对结点u和v来说,路径u~>o 和路径 v ~>u同时存在。
2、
3、使用两次深度优先搜索来计算有向图G = (V,E)的强连通分量,一次在图G上,另一次在转置图GT上。
STRONGLY-CONNECTED-COMPONENTS(G)
call DFS(G) to compute finishing times u.f for each vertex u
compute G^T^
call DFS(G^T^), but in the main loop of DFS, consider the vertices
in orderof decreasing u.f (as computed in line 1)
output the vertices of each tree in the depth-first forest formed in line 3 as a
separate strongly connected component