Skip to content

Conversation

mohiuddin-khan-shiam
Copy link
Contributor

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 3 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 <[email protected]>
    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.
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Aug 24, 2025
@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Aug 24, 2025
@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Aug 24, 2025
@algorithms-keeper algorithms-keeper bot removed the awaiting reviews This PR is ready to be reviewed label Aug 24, 2025
@MaximSmolskiy MaximSmolskiy merged commit 561cc38 into TheAlgorithms:master Aug 24, 2025
5 checks passed
cclauss pushed a commit to cclauss/Python that referenced this pull request Aug 25, 2025
…eAlgorithms#12814)

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

* 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 <[email protected]>

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

* Update check_bipatrite.py

---------

Co-authored-by: Odio Marcelino <[email protected]>
Co-authored-by: Maxim Smolskiy <[email protected]>
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.

3 participants