10000 Fix RuntimeError in bipartite-check DFS/BFS and clean up doctests by mohiuddin-khan-shiam · Pull Request #12814 · TheAlgorithms/Python · GitHub
[go: up one dir, main page]

Skip to content

Fix RuntimeError in bipartite-check DFS/BFS and clean up doctests #12814

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mohiuddin-khan-shiam
Copy link

Fix RuntimeError in bipartite-check DFS/BFS and clean up doctests

Description

  • Iteration over graph mutated by defaultdict neighbours caused
    RuntimeError: dictionary changed size during iteration.
    – Iterate over list(graph) in both DFS and BFS helpers.
  • Corrected if __name__ == "__main__": typo.
  • Updated two doctests that now succeed after the fix.

All doctests now pass (30/30), eliminating a critical runtime failure and improving reliability of the graph algorithms.

odiomarcelino and others added 2 commits June 29, 2025 20:10
* Iteration over `graph` mutated by `defaultdict` neighbours caused
  `RuntimeError: dictionary changed size during iteration`.
  – Iterate over `list(graph)` in both DFS and BFS helpers.
* Corrected `if __name__ == "__main__":` typo.
* Updated two doctests that now succeed after the fix.

All doctests now pass (`30/30`), eliminating a critical runtime failure and improving reliability of the graph algorithms.

Co-Authored-By: S. M. Mohiuddin Khan Shiam <147746955+mohiuddin-khan-shiam@users.noreply.github.com>
    Iteration over graph mutated by defaultdict neighbours caused
    RuntimeError: dictionary changed size during iteration.
    – Iterate over list(graph) in both DFS and BFS helpers.
    Corrected if __name__ == "__main__": typo.
    Updated two doctests that now succeed after the fix.

All doctests now pass (30/30), eliminating a critical runtime failure and improving reliability of the graph algorithms.
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
0