草庐IT

c++ - 递归算法的迭代版本较慢

我正在尝试实现Tarjan的强连接组件(SCC)的迭代版本,为方便起见,在此复制(来源:http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm)。Input:GraphG=(V,E)index=0//DFSnodenumbercounterS=empty//AnemptystackofnodesforallvinVdoif(v.indexisundefined)//StartaDFSateachnodetarjan(v)//wehaven'tvisitedyetprocedureta

c++ - 递归算法的迭代版本较慢

我正在尝试实现Tarjan的强连接组件(SCC)的迭代版本,为方便起见,在此复制(来源:http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm)。Input:GraphG=(V,E)index=0//DFSnodenumbercounterS=empty//AnemptystackofnodesforallvinVdoif(v.indexisundefined)//StartaDFSateachnodetarjan(v)//wehaven'tvisitedyetprocedureta