We 开发者_运维知识库know there is "Union and find" for disjoint sets. http://en.wikipedia.org/wiki/Union_find
But how to do reverse operation ? Consider a set with N nodes connected with E edges( which is in fact a graph ). And at each step we want to delete some edge and check if this delete operation leads to have another disjoint set. Is it possible to do it fastly like in "Union and find"?
P.S this is not homework, we have holiday :)
This is known as the online edge deletion problem or online connectivity problem. Some links to algorithms are in this section of the Wikipedia article on graph connectivity.
So your question is how to efficiently detect a Bridge? This can be done in linear time (also see the link).
Union-find is used in Kruskal algorithm, which repeatedly adds edge of minimum weight which doesn't make a cycle. A reverse idea - removing edges of maximum weight as long as it doesn't disconnect the graph - is used in reverse-delete algorithm, which seemingly can make use of some complicated data structure (see Wikipedia).
精彩评论