* sync
* fixes#8098
* deleted: graphs/check_bipartite_graph_all.py
new file: graphs/check_bipatrite,py
* renamed: graphs/check_bipatrite,py -> graphs/check_bipatrite.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add the new tests
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* [ADD] tests for check_bipartite_graph_bfs
* linter fix?
* linter fix
* [ADD] more test cases check_bipartite_graph_bfs
* doctest fixes. Forgot to add 'Traceback...'
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* missed a Traceback
* Update check_bipartite_graph_bfs.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Adds Doc test in depth_first_search_2.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Fixes depth_first_search_2.py formatting
* Cleanup
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
* test: adding more tests to a star algorithm
* Apply suggestions from code review
* Update a_star.py
---------
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
* Added algorithm to deeply clone a graph
* Fixed file name and removed a function call
* Removed nested function and fixed class parameter types
* Fixed doctests
* bug fix
* Added class decorator
* Updated doctests and fixed precommit errors
* Cleaned up code
* Simplified doctest
* Added doctests
* Code simplification
* Create dijkstra_algorithm.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update dijkstra_algorithm.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update dijkstra_algorithm.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update dijkstra_algorithm.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Delete greedy_methods/dijkstra_algorithm.py
* Update check_bipartite_graph_dfs.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update check_bipartite_graph_dfs.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update graphs/check_bipartite_graph_dfs.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update graphs/check_bipartite_graph_dfs.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update check_bipartite_graph_dfs.py
* Update check_bipartite_graph_dfs.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update check_bipartite_graph_dfs.py
* Update check_bipartite_graph_dfs.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update check_bipartite_graph_dfs.py
* Update check_bipartite_graph_dfs.py
* Update check_bipartite_graph_dfs.py
* Let's use self-documenting variable names
This is complex code so let's use self-documenting function and variable names to help readers to understand.
We should not shorten names to simplify the code formatting but use understandable name and leave to code formatting to psf/black.
I am not sure if `nbor` was supposed to be `neighbour`. ;-)
* Update check_bipartite_graph_dfs.py
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* fix: typo
#8770
* refactor: delete unnecessary continue
* add test grids
* fix: add \_\_eq\_\_ in Node class
#8770
* fix: delete unnecessary code
- node in self.open_nodes is always better node
#8770
* fix: docstring
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* fix: docstring max length
* refactor: get the successors using a list comprehension
* Apply suggestions from code review
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tianyi Zheng <tianyizheng02@gmail.com>
* Fix ruff errors
Renamed neural_network/input_data.py to neural_network/input_data.py_tf
because it should be left out of the directory for the following
reasons:
1. Its sole purpose is to be used by neural_network/gan.py_tf, which is
itself left out of the directory because of issues with TensorFlow.
2. It was taken directly from TensorFlow's codebase and is actually
already deprecated. If/when neural_network/gan.py_tf is eventually
re-added back to the directory, its implementation should be changed
to not use neural_network/input_data.py anyway.
* updating DIRECTORY.md
* Change input_data.py_tf file extension
Change input_data.py_tf file extension because algorithms-keeper bot is being picky about it
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Improved Graph Implementations
Provides new implementation for graph_list.py and graph_matrix.py along with pytest suites for each. Fixes#8709
* Graph implementation style fixes, corrections, and refactored tests
* Helpful docs about graph implementation
* Refactored code to separate files and applied enumerate()
* Renamed files and refactored code to fail fast
* Error handling style fix
* Fixed f-string code quality issue
* Last f-string fix
* Added return types to test functions and more style fixes
* Added more function return types
* Added more function return types pt2
* Fixed error messages
* Reduce the complexity of graphs/bi_directional_dijkstra.py
* Try to lower the --max-complexity threshold in the file .flake8
* Lower the --max-complexity threshold in the file .flake8
* updating DIRECTORY.md
* updating DIRECTORY.md
* Try to lower max-complexity
* Try to lower max-complexity
* Try to lower max-complexity
---------
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* pre-commit: Upgrade psf/black for stable style 2023
Updating https://github.com/psf/black ... updating 22.12.0 -> 23.1.0 for their `2023 stable style`.
* https://github.com/psf/black/blob/main/CHANGES.md#2310
> This is the first [psf/black] release of 2023, and following our stability policy, it comes with a number of improvements to our stable style…
Also, add https://github.com/tox-dev/pyproject-fmt and https://github.com/abravalheri/validate-pyproject to pre-commit.
I only modified `.pre-commit-config.yaml` and all other files were modified by pre-commit.ci and psf/black.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Added Bi-Directional Dijkstra
* Added Bi-Directional Dijkstra
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added doctest and type hints
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Rename Bi_directional_Dijkstra.py to bi_directional_dijkstra.py
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update bi_directional_dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Cleanup the BFS
* Add both functions and timeit
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Add performace results as comment
* Update breadth_first_search_2.py
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update dijkstra.py
* Update graphs/dijkstra.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update graphs/dijkstra.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update graphs/dijkstra.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update dijkstra.py
* Apply suggestions from code review
* Create dijkstra_alternate.py
* Update dijkstra.py
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* int(1e7)
* Update dijkstra_alternate.py
* Update graphs/dijkstra_alternate.py
* sptset --> visited
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* ci: Add ``flake8-pep3101`` plugin to ``pre-commit``
* refactor: Remove all modulo string formatting
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* refactor: Remove ``flake8-pep3101`` plugin from ``pre-commit``
* revert: Revert to modulo formatting
* refactor: Use f-string instead of `join`
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* The black formatter is no longer beta
* pre-commit autoupdate
* pre-commit autoupdate
* Remove project_euler/problem_145 which is killing our CI tests
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Type annotations for `breadth_first_search.py`
* Type annotations for `breadth_first_search_2.py`
* Remove from excluded in mypy.ini
* Add doctest.testmod()
* Type annotations for `graphs/check_cycle.py`
* Type annotations for `graphs/greedy_min_vertex_cover.py`
* Remove from excluded in mypy.ini
* Update queue implementation
Popping the first element of a list takes O(n) time.
Using a cyclic queue takes O(1) time.
* Add queue changes from extra files
* Update indentation
* Add empty line between imports
* Fix lines
* Apply suggestions from code review
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
* added complete graph generator function
* added doctest, type hints, wikipedia explanation
* added return type hint for function complete_graph
* added descriptive name for the parameter: n
* random graph generator with doctest and type hints
* validated using pre-commit
* Delete complete_graph_generator.py
* fixed doctest
* updated following reviews
* simplified the code following reviews
* fixed doctest and solved consistency issues
* consistency fixes
* add check_cycle.py
* Update graphs/check_cycle.py
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Update check_cycle.py
* Apply suggestions from code review
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* [mypy] fix type annotations for graphs/a_star.py #4052
* updating DIRECTORY.md
* Add from __future__ import anotations
* rename delta by DIRECTIONS
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Rename delta by DIRECTIONS in all code
* Enclose script in __main__ code block
* Refactor DIRECTIONS with comments for readibility
* Delete heuristic example comment
* Do not print, return all values
* Fix multilines
* fix black
* Update a_star.py
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
* matching algorithm for min vertex cover problem
* fixed hint on row 37
* changed variable names
* provided doctest for get_edges function
* Removed dict.keys() iteration
* Update matching_min_vertex_cover.py
Co-authored-by: Christian Clauss <cclauss@me.com>