求有向图的强联通分支十一个典型的图论题目。
本来想把他写成一个通用的算法,但是发现有很多不太好处理的地方,比如选用邻接链表还是选用邻接矩阵来表示图,有的情况是不一样的,再者很难把强联通分支缩点,并且再构建一个图出来,主要是强联通分支之间的边表示的时候要考虑一些情况,比如边的费用什么的。
但是也可以尝试做一个稍微通用的一点的算法,就是把所有点属于那个强连通标识(用id[i]表示)出来。
如果对于原图中两点i,j。 如果id[i]==id[j],则他们在一个强联通分支中,否则他们一定不在一个强联通分支中。至于确定两个不同强连通分支之间的关系,就留给客户去做,就好了。
先给出pku的一个题目,使用了求强联通分支的技术。
The Bottom of a Graph
Description
We will use the following (standard) definitions from graph theory. Let V be a nonempty and finite set, its elements being called vertices (or nodes). Let E be a subset of the Cartesian product V×V, its elements being called edges. Then G=(V,E) is called a directed graph.
Let n be a positive integer, and let p=(e1,...,en) be a sequence of length n of edges ei∈E such that ei=(vi,vi+1) for a sequence of vertices (v1,...,vn+1). Then p is called a path from vertex v1 to vertex vn+1 in G and we say that vn+1 is reachable from v1, writing (v1