Skip to content

feat(graph): implement Tarjan's Bridge-Finding Algorithm#7346

Open
Keykyrios wants to merge 2 commits intoTheAlgorithms:masterfrom
Keykyrios:feat/add-tarjan-bridges
Open

feat(graph): implement Tarjan's Bridge-Finding Algorithm#7346
Keykyrios wants to merge 2 commits intoTheAlgorithms:masterfrom
Keykyrios:feat/add-tarjan-bridges

Conversation

@Keykyrios
Copy link
Copy Markdown
Contributor

Description

This PR adds an implementation of Tarjan's Bridge-Finding Algorithm to the graph directory. The algorithm efficiently finds all bridge edges (edges whose removal increases the number of connected components) in an undirected graph in O(V + E) time complexity using a Depth-First Search (DFS) approach.

A comprehensive JUnit 5 test suite (TarjanBridgesTest.java) has also been included to validate various standard and edge cases, including disconnected graphs, cyclic graphs, and trees. I have also verified that clang-format is completely satisfied.

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new algorithms include a corresponding test class that validates their functionality.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

Adds a classic graph algorithm to find bridge edges in an undirected graph in O(V + E) time.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.48%. Comparing base (cc75b5e) to head (72c718a).

Files with missing lines Patch % Lines
...in/java/com/thealgorithms/graph/TarjanBridges.java 94.44% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7346      +/-   ##
============================================
+ Coverage     79.45%   79.48%   +0.03%     
- Complexity     7083     7091       +8     
============================================
  Files           790      791       +1     
  Lines         23164    23200      +36     
  Branches       4556     4564       +8     
============================================
+ Hits          18405    18441      +36     
- Misses         4022     4023       +1     
+ Partials        737      736       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Keykyrios Keykyrios marked this pull request as ready for review March 27, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants