If you are unfamiliar with graphs, check out some of my earlier posts on them.
Resources:
- Video explanation of articulation points & bridges
- Video explanation and implementation for articulation points
- Video on bridges & blocks
- Articulation points implementation
- Bridges implementation
Takeaways:
- A component is a sub-graph that is not connected to the rest of the graph.
- An articulation point is a vertex that when removed (along with it's edges) creates more components in the graph.
- Another name for articulation point is cut vertex.
- A bridge is an edge that when removed creates more components in the graph.
- Another name for a bridge is cut-edge.
- We can use depth-first search (DFS) to find all the articulation points or bridges in a graph.
-
There are two rules for finding articulation points in undirected graphs:
- The root vertex in a graph is an articulation point if it has more than one child.
- Any other vertex
vin the graph is an articulation point if it has a childuthat cannot reach any ancestors ofv, without also visitingv.- This means that there is no back-edge between
uand any ancestor beforev.
- This means that there is no back-edge between
-
How do we apply DFS and follow the above two rules?
- We maintain a discovery time (or ID) for each vertex
vin the graph. We also keep track of the earliest vertexyit is connected to - we call this the low-link value (yis the low-link vertex). - So during DFS, for every vertex
vwe visit we assign it an ID & a low-link value. To start, we set both ID/low-link to be the same integer that we will increment by 1 each time we visit a new vertex. (For example: root vertex will get 0 assigned to it for ID/low-link, then we will increment both by 1 for the next vertex). - For every vertex
u, that is adjacent tov, we will recursively call our DFS routine. - When our DFS finds no more adjacent vertices to visit, the stack begins to unwind. As it unwinds, we will update our low-link value for each adjacent vertex (to represent the earliest ancestor it is connected to).
- If we find that the ID (visited time) of the current vertex
vis<=the low-link value of our adjacent vertexu, thenvis an articulation point.- This is because it means
ucannot reach one of it's ancestor vertices without also visiting/going viav.
- This is because it means
- We maintain a discovery time (or ID) for each vertex
-
Finding bridges is very similar to finding articulation points. The main changes to the algorithm are:
- We no longer need to keep track of how many children the root vertex has.
- Instead of checking if the ID of
vis<=the low-link ofu, we just check if it's<.- We only check if it's less than, because if the values are the same then there is a back-edge present - and this means a bridge cannot exist
- A back-edge means that a neighbour
wofucould have an edge connecting tov. Creating a cycle. Meaning ifedge(u,v)is removed, thenustill connects tovviaedge(w,v). - If there is no back-edge, or cycle, like described, then the ID of
vwill always be less than the low-link ofuif a bridge is present. And this means ifedge(u,v)is removed,uand all it's adjacent vertices will become disconnected from the graph - forming another component (and increasing the number of components in the graph).
Time complexity is
O(v + e)for an adjacency list. Space complexity isO(v). For an adjacency matrix, the time & space complexity would beO(v^2).Below is an example of an undirected graph with articulation points and bridges:
Below are implementations for finding articulation points & bridges in undirected adjacency list & adjacency matrix representations of graphs:
As always, if you found any errors in this post please let me know!

Top comments (0)