Skip to content

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

Merged
DenizAltunkapan merged 3 commits intoTheAlgorithms:masterfrom
Keykyrios:feat/add-tarjan-bridges
Mar 28, 2026
Merged

feat(graph): implement Tarjan's Bridge-Finding Algorithm#7346
DenizAltunkapan merged 3 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-commenter commented Mar 27, 2026

Codecov Report

❌ Patch coverage is 94.44444% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.47%. Comparing base (92d4702) to head (5fae07f).

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.46%   79.47%   +0.01%     
- Complexity     7085     7091       +6     
============================================
  Files           790      791       +1     
  Lines         23166    23202      +36     
  Branches       4557     4565       +8     
============================================
+ Hits          18408    18440      +32     
- Misses         4022     4024       +2     
- Partials        736      738       +2     

☔ 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
Copy link
Copy Markdown
Member

@DenizAltunkapan DenizAltunkapan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Keykyrios Thank you for your contribution

@DenizAltunkapan DenizAltunkapan enabled auto-merge (squash) March 28, 2026 09:54
@DenizAltunkapan DenizAltunkapan merged commit 227355e into TheAlgorithms:master Mar 28, 2026
7 checks passed
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.

3 participants