Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG : bridge finding algorithm offline #959

Open
SubhramRanaRZP opened this issue Nov 15, 2022 · 1 comment
Open

BUG : bridge finding algorithm offline #959

SubhramRanaRZP opened this issue Nov 15, 2022 · 1 comment
Labels

Comments

@SubhramRanaRZP
Copy link

SubhramRanaRZP commented Nov 15, 2022

Article: Finding Bridges in O(N+M)

Problem:
If there is double edge between two nodes, due to if (to == p) continue;, the edge (v-to) will be considered as a bridge, which is not correct.
Here is the modified code.

  1. introduce a new variable called parentSkipped inside the dfs()
    bool parentSkipped = false;
  2. instead of just if (to == p) continue; do the following
    if (to == p && !parentSkipped) {
    parentSkipped = true;
    continue;
    }
@SubhramRanaRZP SubhramRanaRZP changed the title The following scenario will results in wrong answer BUG : bridge finding algorithm offline Nov 15, 2022
@adamant-pwn
Copy link
Member

Hi, thanks for bringing that up! Would you like to make a pull request with this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants