Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Graph Tarjan';s算法_Graph - Fatal编程技术网

Graph Tarjan';s算法

Graph Tarjan';s算法,graph,Graph,我正在阅读的描述是为了在一个滴状图中找到强连通的成分。 但我发现很难理解这些代码片段: if (w.index is undefined) then // Successor w has not yet been visited; recurse on it strongconnect(w) v.lowlink := min(v.lowlink, w.lowlink) else if (w is in S) then

我正在阅读的描述是为了在一个滴状图中找到强连通的成分。 但我发现很难理解这些代码片段:

 if (w.index is undefined) then
        // Successor w has not yet been visited; recurse on it
        strongconnect(w)
        v.lowlink  := min(v.lowlink, w.lowlink)
      else if (w is in S) then
        // Successor w is in stack S and hence in the current SCC
        v.lowlink  := min(v.lowlink, w.index)
      end if
第四行和第七行不一样,这让我很困惑。 在我看来,第七行可以和第四行写得一样
v.lowkink:=min(v.lowlink,w.index)


我在我的程序中对此进行了测试,效果很好,对我来说,最好理解bcz verdex v cloud reach hight up root,但我无法证明这一点。

我编写了一个程序,枚举了大小为4的所有图形,然后运行每个版本(如果w在s中,则使用
min(v.lowlink,w.index)
min(v.lowlink,w.lowlink)
)并对结果进行了比较。尽管w.lowlink和w.index通常不同,但在所有情况下两者都完全相同

<> P.>为什么我们可以使用W.索引是这样的:考虑堆栈S相对于当前节点V在另一个节点W上的位置。

如果它在堆栈上较早,那么它的索引比当前节点小(因为它访问较早,duh),因此当前节点不是其连接组件的“头”,这将反映在v.lowlink中