feat: add Articulation Points and Bridges algorithm #6684
+641
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📝 Add Articulation Points and Bridges Algorithm
Description
This PR implements an algorithm to find Articulation Points (Cut Vertices) and Bridges (Cut Edges) in undirected graphs using a DFS-based approach with discovery times and low-link values.
Articulation Point: A vertex whose removal increases the number of connected components.
Bridge: An edge whose removal increases the number of connected components.
Features
Algorithm Details
Time Complexity: O(V + E)
Space Complexity: O(V)
Detection Rules:
u
is an articulation point if it has a childv
wherelow[v] >= discovery[u]
(u,v)
is a bridge iflow[v] > discovery[u]
Test Coverage
The test suite covers:
Real-World Applications
Files Changed
src/main/java/com/thealgorithms/datastructures/graphs/ArticulationPointsAndBridges.java
- Main implementation (270 lines)src/test/java/com/thealgorithms/datastructures/graphs/ArticulationPointsAndBridgesTest.java
- Test suite (371 lines)Checklist
References
Hacktoberfest 2025 🎃
Example Usage