Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find Connected Component dynamically

Using disjoint-set data structure can easily get connected component of Graph. And, it just supports Incremental Connected Components.

However, in my case, removing edge is very common so that I am looking for an algorithm or new structure can maintain Connected Components fully dynamically(including adding and removing edge)

Thanks

like image 440
Chang Avatar asked Aug 30 '11 09:08

Chang


People also ask

Can DFS find number of connected components?

As mentioned by others, running a BFS or DFS will allow you to efficiently count the number of connected components.

How do you find strongly connected components?

Perform depth-first search on the reversed graph. Start from the top vertex of the stack. Traverse through all of its child vertices. Once the already visited vertex is reached, one strongly connected component is formed.

How do you determine the number of connected components?

First, mark all vertices as unvisited. Iterate over all vertices. If a vertex is not visited, perform DFS on that vertex and increment the count by 1. After iterating over all vertices, the value of count will be the number of connected components in the graph.


1 Answers

Poly-logarithmic deterministic fully-dynamic algorithms for connectivity, minimum spanning tree, 2-edge, and biconnectivity (Holm, de Lichtenberg and Thorup 2001) gives an algorithm that allows an arbitrary sequence of edge insertions, deletions and connectivity queries, with updates (insertions and deletions) taking O(log(n)^2) amortised time, and queries taking O(log(n)/log(log(n))) time, with n being the number of vertices in the graph. These time bounds assume that the graph starts with no edges.

I only skimmed the first 2 of its 38 pages, but don't be (too) scared -- the paper describes a bunch of new algorithms on dynamic graphs (that is, graphs that can be efficiently modified over time) of which connectivity is the simplest.

like image 130
j_random_hacker Avatar answered Sep 30 '22 10:09

j_random_hacker