Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@0xsatoshi99
Copy link
Contributor

Summary

Adds Bridges (cut edges) algorithm to find critical edges in undirected graphs.

Algorithm

A bridge is an edge whose removal increases the number of connected components. Uses DFS-based approach similar to Tarjan's algorithm.

  • Time: O(V + E)
  • Space: O(V)

Features

  • Find() - Returns all bridges
  • IsBridge() - Checks specific edge
  • Count() - Counts total bridges
  • Generic type support

Tests (17 cases)

  • Simple chains, triangles, star graphs
  • Two components connected by bridge
  • Disconnected graphs
  • Complex graphs with cycles
  • Edge cases and validation

Use Cases

  • Network reliability
  • Critical infrastructure
  • Vulnerability assessment

Files

  • Algorithms/Graph/Bridges.cs (169 lines)
  • Algorithms.Tests/Graph/BridgesTests.cs (346 lines)

Contribution by Gittensor, learn more at https://gittensor.io/

Finds bridges (cut edges) in undirected graphs.
A bridge is an edge whose removal increases connected components.

Features:
- Find all bridges using DFS
- Check if specific edge is a bridge
- Count total bridges
- O(V + E) time complexity
- Works with any vertex type

Tests (17 test cases):
- Simple chains and triangles
- Two components connected by bridge
- Star graphs
- Disconnected graphs
- Complex graphs with cycles
- Edge cases and validation

Use Cases:
- Network reliability analysis
- Critical connection identification
- Infrastructure vulnerability assessment

Files:
- Algorithms/Graph/Bridges.cs (177 lines)
- Algorithms.Tests/Graph/BridgesTests.cs (326 lines)
@0xsatoshi99 0xsatoshi99 requested a review from siriak as a code owner November 13, 2025 01:42
@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.96%. Comparing base (1baa726) to head (8bb141f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #575      +/-   ##
==========================================
+ Coverage   96.95%   96.96%   +0.01%     
==========================================
  Files         299      300       +1     
  Lines       12527    12598      +71     
  Branches     1832     1842      +10     
==========================================
+ Hits        12145    12216      +71     
  Misses        242      242              
  Partials      140      140              

☔ 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.

@0xsatoshi99
Copy link
Contributor Author

@siriak Please check this PR when you have some time, Thanks.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@siriak siriak enabled auto-merge (squash) November 14, 2025 12:50
@siriak siriak merged commit 5aee965 into TheAlgorithms:master Nov 14, 2025
4 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.

2 participants