GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Create Bridges.java by rajattiwariind · Pull Request #7659 · TheAlgorithms/Java

Conversation

@rajattiwariind

@rajattiwariind rajattiwariind commented Oct 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
  • 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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rajattiwariind
Create Bridges.java
711b1fe
@rajattiwariind
rajattiwariind requested review from DenizAltunkapan, alxkm and yanglbme as code owners October 25, 2026 11:56
@rajattiwariind
Update Bridges.java
d3886e1
@codecov-commenter

codecov-commenter commented Oct 25, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.22%. Comparing base (96ed2d7) to head (a6f7c26).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #7659      +/-   ##
============================================
+ Coverage     82.20%   82.22%   +0.02%     
- Complexity     8397     8417      +20     
============================================
  Files           843      844       +1     
  Lines         26133    26177      +44     
  Branches       5097     5109      +12     
============================================
+ Hits          21482    21524      +42     
- Misses         3859     3860       +1     
- Partials        792      793       +1     

☔ View full report in Codecov by Harness.
📢 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.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rajattiwariind added 11 commits October 25, 2026 17:47
@rajattiwariind
Update Bridges.java
b5149b0
@rajattiwariind
Create BridgesTest.java
9f54bcc
@rajattiwariind
Create BridgesTest.java
7918aad
Move BridgesTest to test source directory
@rajattiwariind
Delete src/main/java/com/thealgorithms/graph/BridgesTest.java
91b3d76
@rajattiwariind
Update BridgesTest.java
6a21425
@rajattiwariind
Update Bridges.java
c5b315f
@rajattiwariind
Update Bridges.java
28877ae
@rajattiwariind
Update Bridges.java
06e717e
@rajattiwariind
Merge branch 'master' into patch-1
3fb9a74
@rajattiwariind
Update BridgesTest.java
423cc3a
@rajattiwariind
Update BridgesTest.java
a6f7c26
@rajattiwariind

rajattiwariind commented Oct 26, 2026

Copy link
Copy Markdown
Author

Hello maintainers,

All 7 CI checks are passing, and Codecov confirms that all modified, coverable lines are covered by tests.

Could you please review my pull request when you have a chance? I'm happy to make any changes needed.

Thank you for your time.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

DenizAltunkapan
DenizAltunkapan requested changes Oct 26, 2026
View reviewed changes

@DenizAltunkapan DenizAltunkapan left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thank you for the contribution. The bridge-finding logic looks sound, and using edge IDs correctly handles parallel edges. All 19 added tests passed locally; an additional 50,000 seeded random multigraph cases also matched an independent oracle that removes each edge and counts connected components. I ran these checks directly with javac/JUnit rather than a full Maven build.

Before merging, please integrate this work with the existing TarjanBridges implementation and correct the complexity documentation, as detailed in the inline comments. The parallel-edge handling is a useful improvement worth preserving, along with its regression tests.

Non-blocking: the recursive DFS produced a StackOverflowError locally on a 20,000-vertex chain. Recursive DFS is also used by the existing implementation, so I am not requesting an iterative rewrite for this PR, but documenting the recursion-depth limitation would be helpful.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/com/thealgorithms/graph/Bridges.java
*
* <p>Reference: https://en.wikipedia.org/wiki/Bridge_(graph_theory)
*/
public final class Bridges {

@DenizAltunkapan DenizAltunkapan Oct 26, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This package already contains TarjanBridges, which implements the same DFS/low-link bridge-finding algorithm: https://github.com/TheAlgorithms/Java/blob/96ed2d7970606b51014afd25212c6c86d2af6255/src/main/java/com/thealgorithms/graph/TarjanBridges.java

Please consolidate this contribution into that implementation rather than maintaining a second copy of the algorithm. In particular, preserve the edge-ID handling and add the parallel-edge regression test to TarjanBridgesTest: for two vertices joined by two parallel edges, the existing implementation incorrectly reports one bridge, while this implementation correctly reports none. If an edge-list entry point is useful, it can be added to TarjanBridges while preserving the existing API and sharing the traversal logic. Please update the PR title/description to explain the resulting improvement.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/main/java/com/thealgorithms/graph/Bridges.java
*
* <p>Vertices are numbered from 0 to {@code vertexCount - 1}.
*
* <p>Time complexity: O(V + E), where V is the number of vertices

@DenizAltunkapan DenizAltunkapan Oct 26, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The O(V + E) claim does not account for bridges.sort(...) at lines 79–82. With B returned bridges, the implemented method has an upper bound of O(V + E + B log B). Please update the complexity documentation if sorted output is retained, and document the endpoint normalization and lexicographic ordering in the return contract. Alternatively, remove the sorting if ordering is not part of the intended API.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@DenizAltunkapan DenizAltunkapan DenizAltunkapan requested changes
@yanglbme yanglbme Awaiting requested review from yanglbme yanglbme is a code owner
@alxkm alxkm Awaiting requested review from alxkm alxkm is a code owner

Requested changes must be addressed to merge this pull request.

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@rajattiwariind @codecov-commenter @DenizAltunkapan
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.