3

I have an undirected unweighted graph with a single component. I want to know if removing a given node will disconnect the graph. I know that I can remove the edges to the node and then use DFS to get the number of components, however this seems rather inefficient as I need to check all vertices in the graph for this. Is there a faster way to do this?

D.W.
  • 167,959
  • 22
  • 232
  • 500
k-a-v
  • 133
  • 1
  • 4

1 Answers1

4

Yes, if we know something about the given graph. For example, if we know that graph is a tree or a cycle or a star graph. Or we might be able to terminate the algorithm early, for example, if we can determine the neighborhood of that node is still connected after that node is removed.

However, an algorithm to determine whether an arbitrary node is an articulation point or not in a general graph has to visit every node in the worse case.

Suppose a clever algorithm claims a given node is an articulation point without visiting all nodes. Suppose node $\mathcal U$ is not visited. Well, it could happen that $\mathcal U$ is connected to every node. Or there might be an edge that connects $\mathcal U$ to a point in the other connected component. That is a contradiction.

To be slightly more precise, any such algorithm should visit every remaining edge in the worst case.

Any way, a DFS that goes through all edges runs in $O(|E|)$ time is pretty fast for graph without too many edges. It should not be a big performance concern usually. If a series of node will be removed one by one and you want to determine the first one that disconnects the graph, it might help to do some precomputation to decompose the graph in certain way or other kinds of tricks to reduce the amortized cost. That is another story, though.

John L.
  • 39,205
  • 4
  • 34
  • 93