图的割点和桥

 

图的割点和桥_第1张图片

 


DFS(G) for each u in V[G] do color[u] <- WHITE pi[u] <- NIL time <- 0 for each u in V[G] do if color[u] = WHITE then root <- u DFS-VISIT(u) DFS-VISIT(u) color <- GRAY d[u] <- time <- time + 1 ancestor[u] <- d[u] child_nb <- 0 for each v in Adj[u] do if color[v] = GRAY and v != pi[u] then ancestor[u] <- min(ancestor[u], d[v]) if color[v] = WHITE then pi[v] <- u child_nb <- child_nb + 1 DFS-VISIT(v) ancestor[u] <- min(ancestor[u], ancestor[v]) if (ancestor[v] >= d[u] and u != root) or (u = root and child_nb > 1) then cut[u] <- true if ancestor[v] > d[u] then bridge[(u, v)] <- true color[u] <- BLACK f[u] <- time <- time + 1  

参考资料

刘汝佳, 黄亮. 算法艺术与信息学竞赛. 清华大学出版社, page 285-286, 2004.

你可能感兴趣的:(算法,each,出版)