Skip to content

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

Closed
Keykyrios wants to merge 4 commits intoTheAlgorithms:masterfrom
Keykyrios:feat/add-tarjan-bridges
Closed

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

Conversation

@Keykyrios
Copy link
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

Implement Kasai's algorithm to compute the Longest Common Prefix (LCP) array in O(N) time given a string and its suffix array. Add KasaiAlgorithm.java and KasaiAlgorithmTest.java.
Adds a classic graph algorithm to find bridge edges in an undirected graph in O(V + E) time.
@Keykyrios Keykyrios closed this Mar 22, 2026
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 95.16129% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.48%. Comparing base (7d57c57) to head (469b79c).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...in/java/com/thealgorithms/graph/TarjanBridges.java 94.44% 2 Missing ⚠️
...java/com/thealgorithms/strings/KasaiAlgorithm.java 96.15% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7337      +/-   ##
============================================
+ Coverage     79.43%   79.48%   +0.05%     
- Complexity     7062     7085      +23     
============================================
  Files           788      790       +2     
  Lines         23124    23186      +62     
  Branches       4545     4561      +16     
============================================
+ Hits          18368    18430      +62     
- Misses         4022     4023       +1     
+ Partials        734      733       -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.

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