What if I do not use G transpose in calculating Strongly Connected Components?

不问归期 提交于 2019-12-06 04:47:22
Dean Gurvitz

Your question is actually exercise 22.5-3 in the book. A counter example to the correctness of your alternative algorithm is given here: http://sites.math.rutgers.edu/~ajl213/CLRS/Ch22.pdf

Professor Bacon’s suggestion doesn’t work out. As an example, suppose that our graph is on the three vertices {1, 2, 3} and consists of the edges (2, 1),(2, 3),(3, 2). Then, we should end up with {2, 3} and {1} as our SCC’s. However, a possible DFS starting at 2 could explore 3 before 1, this would mean that the finish time of 3 is lower than of 1 and 2. This means that when we first perform the DFS starting at 3. However, a DFS starting at 3 will be able to reach all other vertices. This means that the algorithm would return that the entire graph is a single SCC, even though this is clearly not the case since there is neither a path from 1 to 2 of from 1 to 3.

The vertices in strongly connected component are, by definiton, connected to each other (by a path, not necessarily by direct edge). if you make first DFS call on vertex X, you find out "which vertices is X connected to" (X -> N). To make sure that all those vertices are connected to X (N -> X) and therefore validate strong connectivity you need to traverse the edges in reversed directions. The easiest way to do such is by transposing the graph.

If you look for proof of the algorithm, i am sure you will find some. It may not be the easiest to understand but check this source for example: Correctness of the algorithm for finding strongly connected components

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!