* 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>
* 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
* added Greedy min vertex algorithm
* pre-commit hook(s) made changes
* Delete complete_graph_generator.py
* Delete random_graph_generator.py
* fixed doctest
* updated commit following highligths
* fixed following pre-commit highlights
* modified variables names
* boruvka.py: A few simplifications and f-strings
Python f-strings simplify the code and [should speed up execution](https://www.scivision.dev/python-f-string-speed).
@srkchowdary2000 Your review, please.
* updating DIRECTORY.md
* fixup! Streamline the test
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Added Borůvka's algorithm.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Solved Test Cases Errors.Removed WhiteSpaces.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Code Changes.
* Added Borůvka's algorithm, a graph algorithm that finds the minimum spanning tree. Code Changes.
* Move files to cellular_automata
* Rename other/davis–putnam–logemann–loveland.py to backtracking/davis–putnam–logemann–loveland.py
* Rename other/markov_chain.py to graphs/markov_chain.py
* undid rename: need to fix mypy first
* new implementation for adjacency list graph
* add example code for undirected graph
* reduce length to 88 columns max to fix build errors7
* fix pre commit issues
* replace print_list method with __str__
* return object in add_edge method to enable fluent syntax
* improve class docstring and include doctests
* add end of file line
* fix pre-commit issues
* remove __str__ method
* trigger build
* Update graph_list.py
* Update graph_list.py
Co-authored-by: gnc <chidieberen1999@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Updated the code to track visited Nodes with Set data structure instead of Lists to bring down the lookup time in visited from O(N) to O(1)
as doing O(N) lookup each time in the visited List will become significantly slow when the graph grows
* graphs/kruskal: add doctest & type hints
this is a child of a previous PR #2443
its ancestor is #2128
* updating DIRECTORY.md
* graphs/kruskal: fix max-line-length violation
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* test/graphs/kruskal: adding a test case to verify the correctness of the algorithm
Fixes#2128
* grahps/kruskal: running psf/black
* graphs/kruskal: read edges in a friendlier fashion
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update minimum_spanning_tree_kruskal.py
* fixup! Format Python code with psf/black push
* Update test_min_spanning_tree_kruskal.py
* updating DIRECTORY.md
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* fix assignment of a variable to itself
* Fix unnecessary 'else' clause in loop
* formatting and redundant reasignment fix
* mark unreachable code with a TODO comment
* fix variable defined multiple times
* fix static method without static decorator
* revert unintended autoformatting
Co-authored-by: Christian Clauss <cclauss@me.com>
* revert autoformatting issue
* applied black autoformatting
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fix Non Recursive Depth First Search
* Unindent docstring
* Reindent docstring by 1 space
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
* Add implementation of Karger's Algorithm
* Remove print statement from karger's algorithm function
* Fix style issues in graphs/karger.py
* Change for loops to set comprehensions where appropriate in graphs/karger.py
* Gale Shapley Algorithm
Implementation of a Nobel prize-winning algorithm that determines a stable matching in a bipartite graph.
* Update graphs/gale_shapley_bigraph.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Fixed some flake8 issues.
* Updated it to donors and recipients
* description changes
Co-authored-by: Christian Clauss <cclauss@me.com>
* description changes
Co-authored-by: Christian Clauss <cclauss@me.com>
* description changes
Co-authored-by: Christian Clauss <cclauss@me.com>
* Edited the line lengths
* Update gale_shapley_bigraph.py
* Update gale_shapley_bigraph.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* black format
* updating DIRECTORY.md
* fixes
* fixup! Format Python code with psf/black push
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Add typing for bfs
* Add url for BFS
* rename the function
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update graphs/bfs.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Change the return value type of bfs
* change the function name.
change all instances of bfs() to breadth_first_search().
* change the function name in annotate
* Add one more blank line.
* Delete one blank line.
* Delete one blank line.
I've read the https://www.flake8rules.com/rules/W391.html, and still don't know how to do it. I've tried using 0 ,1,2 blank lines...
* Update graphs/bfs.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Update graphs/bfs.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Rename bfs.py to breadth_first_search_2.py
Co-authored-by: Christian Clauss <cclauss@me.com>
* Tighten up psf/black and flake8
* Fix some tests
* Fix some E741
* Fix some E741
* updating DIRECTORY.md
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
* Create breadth_first_search_shortest_path.py
* updating DIRECTORY.md
* Reduce side effect of `shortest_path`
For the sake of future testing and documentation -
* fixup! Format Python code with psf/black push
* Fix typo `separately`
* Change to get() from dictionary
Co-Authored-By: Christian Clauss <cclauss@me.com>
* Move graph to the top
* fixup! Format Python code with psf/black push
* Add doctest for shortest path
* Add doctest for BFS
* fixup! Format Python code with psf/black push
* Add typings for breadth_first_search_shortest_path
* fixup! Format Python code with psf/black push
* Remove assert from doctests
* Add blank line to doctest
Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: John Law <johnlaw@linux.com>
* spelling corrections
* review
* improved documentation, removed redundant variables, added testing
* added type hint
* camel case to snake case
* spelling fix
* review
* python --> Python # it is a brand name, not a snake
* explicit cast to int
* spaces in int list
* "!= None" to "is not None"
* Update comb_sort.py
* various spelling corrections in documentation & several variables naming conventions fix
* + char in file name
* import dependency - bug fix
Co-authored-by: John Law <johnlaw.po@gmail.com>
* Simplify sudoku.is_completed() using builtin all()
Simplify __sudoku.is_completed()__ using Python builtin function [__all()__](https://docs.python.org/3/library/functions.html#all).
* fixup! Format Python code with psf/black push
* Update sudoku.py
* fixup! Format Python code with psf/black push
* Old style exception -> new style for Python 3
* updating DIRECTORY.md
* Update convex_hull.py
* fixup! Format Python code with psf/black push
* e.args[0] = "msg"
* ValueError: could not convert string to float: 'pi'
* Update convex_hull.py
* fixup! Format Python code with psf/black push
* Fix out of range error in bellman_ford.py
* Update bellman_ford.py
* fixup! Format Python code with psf/black push
* Enhance the print function
* fixup! Format Python code with psf/black push