Commit Graph

140 Commits

Author SHA1 Message Date
Caeden Perelli-Harris
f15cc2f01c
Follow Flake8 pep3101 and remove modulo formatting (#7339)
* 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>
2022-10-16 22:50:11 +02:00
CenTdemeern1
04698538d8
Misc fixes across multiple algorithms (#6912)
Source: Snyk code quality
Add scikit-fuzzy to requirements

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-16 10:55:38 +05:30
Caeden
a652905b60
Add Flake8 comprehensions to pre-commit (#7235)
* ci(pre-commit): Add ``flake8-comprehensions`` to ``pre-commit`` (#7233)

* refactor: Fix ``flake8-comprehensions`` errors

* fix: Replace `map` with generator (#7233)

* fix: Cast `range` objects to `list`
2022-10-15 19:29:42 +02:00
Caeden
6e69181d1f
refactor: Replace list() and dict() calls with literals (#7198) 2022-10-15 06:37:03 +05:30
Caeden
4d0c830d2c
Add flake8 pluin flake8 bugbear to pre-commit (#7132)
* ci(pre-commit): Add ``flake8-builtins`` additional dependency to ``pre-commit`` (#7104)

* refactor: Fix ``flake8-builtins`` (#7104)

* fix(lru_cache): Fix naming conventions in docstrings (#7104)

* ci(pre-commit): Order additional dependencies alphabetically (#7104)

* fix(lfu_cache): Correct function name in docstring (#7104)

* Update strings/snake_case_to_camel_pascal_case.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update data_structures/stacks/next_greater_element.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update digital_image_processing/index_calculation.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update graphs/prim.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Update hashes/djb2.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* refactor: Rename `_builtin` to `builtin_` ( #7104)

* fix: Rename all instances (#7104)

* refactor: Update variable names (#7104)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* ci: Create ``tox.ini`` and ignore ``A003`` (#7123)

* revert: Remove function name changes (#7104)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename tox.ini to .flake8

* Update data_structures/heap/heap.py

Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>

* refactor: Rename `next_` to `next_item` (#7104)

* ci(pre-commit): Add `flake8` plugin `flake8-bugbear` (#7127)

* refactor: Follow `flake8-bugbear` plugin (#7127)

* fix: Correct `knapsack` code (#7127)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 18:03:06 +02:00
Caeden
d5a9f649b8
Add flake8-builtins to pre-commit and fix errors (#7105)
Ignore `A003`

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com>
2022-10-13 19:53:59 +05:30
Caeden
07e991d553
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038)

* refactor: Fix naming conventions (#7038)

* Update arithmetic_analysis/lu_decomposition.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038)

* chore: Fix naming conventions in doctests (#7038)

* fix: Temporarily disable project euler problem 104 (#7069)

* chore: Fix naming conventions in doctests (#7038)

Co-authored-by: Christian Clauss <cclauss@me.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-13 00:54:20 +02:00
Christian Clauss
b75a7c77f8
pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0 (#6245)
* pre-commit autoupdate: pyupgrade v2.34.0 -> v2.37.0

* pre-commit run --all-files
2022-07-11 10:19:52 +02:00
Raine Legary
b8fdd81f28
Add minmum path sum (#5882)
* commit on 'shortest_path_sum'

* minimum_path_sum updated

* commit to 'minimum_path_sum'

* added description to minimum_path_sum

* bot requirements fixed for

* Update minimum_path_sum.py

* Update minimum_path_sum.py

Co-authored-by: John Law <johnlaw.po@gmail.com>
2022-05-25 13:49:54 +08:00
Christian Clauss
24d3cf8244
The black formatter is no longer beta (#5960)
* 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>
2022-01-30 20:29:54 +01:00
Rohan R Bharadwaj
ed4c92d98a
[mypy] Type annotations for graphs directory (#5798)
* 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
2021-11-08 19:18:30 +01:00
Rohan R Bharadwaj
a8aeabdf18
[mypy] Type annotations for graphs/finding_bridges.py and graphs/random_graph_generator.py (#5795)
* [mypy] Annotate `graphs/finding_bridges.py`

* Remove from excluded in `mypy.ini`

* Add doctest.testmod()

* psf/black formatting

* Annotations for `graphs/random_graph_generator.py`

* Remove from excluded in `mypy.ini`

* Resolve merge conflict

* Resolve merge conflict

* Update mypy.ini

* Update mypy.ini

* Remove from excluded
2021-11-08 18:18:33 +01:00
Dylan Buchi
ac4bdfd66d
[mypy] Fix type annotations in graphs/boruvka.py (#5794)
* Fix type annotations in boruvka.py

* Remove graphs/boruvka.py|

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-11-08 21:47:09 +08:00
Boris Galochkin
dbddac74d3
Fix graphs/finding_bridges.py algorithm + doctests (#5765)
* Fix finding_bridges algorithms + tests

* update type hints

* Better, more obvious condition fix

* fix prev commit + more tests

* Short explanation + url

* Update finding_bridges.py

Co-authored-by: Christian Clauss <cclauss@me.com>
2021-11-04 17:51:31 +01:00
Casper Rysgaard
e6cf13cc03
Update queue implementation (#5388)
* 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>
2021-10-30 19:06:25 +08:00
Manuel Di Lullo
ba71005484
Add random graph generator (#5240)
* 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
2021-10-25 15:59:52 +08:00
Christian Clauss
bd9464e4ac
mandelbrot.py: Commenting out long running tests (#5558)
* mandelbrot.py: Commenting out long running tests

* updating DIRECTORY.md

* Comment out 9 sec doctests

* Update bidirectional_breadth_first_search.py

* Comment out slow tests

* Comment out slow (9.15 sec) pytests...

* # Comment out slow (4.20s call) doctests

* Comment out slow (3.45s) doctests

* Update miller_rabin.py

* Update miller_rabin.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-10-23 18:15:30 +02:00
Atishaye Jain
c50f0c56aa
add check_cycle.py (#5475)
* 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>
2021-10-23 12:29:42 +02:00
poloso
061614880d
[mypy] fix type annotations for graphs/a_star.py #4052 (#5224)
* [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>
2021-10-22 18:07:28 +08:00
Meysam
08d4d226d7
[mypy] Fix type annotations for graphs/boruvka (#4867)
* fix: type annotations for pypi 🏷️

Fixes #4052

* updating DIRECTORY.md

* apply suggestions from code review

Co-authored-by: Christian Clauss <cclauss@me.com>

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
2021-10-17 18:26:12 +02:00
Manuel Di Lullo
1d457be29d
Matching min vertex cover (#5326)
* 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>
2021-10-15 17:03:57 +02:00
Manuel Di Lullo
908cb4f1e7
Greedy min vertex cover hacktoberfest (#5241)
* 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
2021-10-15 15:04:38 +02:00
Christian Clauss
cecf43d648
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2021-09-07 13:37:03 +02:00
Christian Clauss
097f830238
Avoid mutable default arguments (#4691) 2021-08-31 06:56:15 +02:00
Christian Clauss
78a5d3a558
boruvka.py: A few simplifications and f-strings (#4660)
* 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>
2021-08-24 15:27:31 +02:00
Shiva Rama Krishna
4ed7c7f09c
Added Borůvka's algorithm. (#4645)
* 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.
2021-08-23 12:35:20 +02:00
imp
4545270ace
[mypy] Fix type annotations for graphs (#4622)
* Fix mypy error for frequent_pattern_graph_miner.py

* Fix mypy error for markov_chain.py
2021-08-18 12:44:26 +02:00
Hasanul Islam
cd987372e4
Fix multi heuristic astar algo (#4612) 2021-08-13 09:10:24 +02:00
Hasanul Islam
d668c172b0
Refactor graph_initialization at basic_graph.py (#4601) 2021-08-11 22:48:53 +02:00
Hasanul Islam
da71184b04
Fix mypy errors at mst_kruskal (#4581) 2021-08-02 14:40:48 +02:00
Hasanul Islam
a5bcf0f674
Fix mypy errors at even_tree algo (#4579) 2021-07-29 15:14:35 +02:00
Milton Chandro Bhowmick
40d85d5443
Modified the a_star [dot] py for making readable (#4576) 2021-07-28 12:50:21 +02:00
Hasanul Islam
a4b7d12262
Fix mypy errors at greedy best first algo (#4575) 2021-07-27 13:21:00 +02:00
Hasanul Islam
c5003a2c46
Fix mypy errors at bfs_shortest_path algo (#4572) 2021-07-27 10:09:17 +02:00
Hasanul Islam
7634cf0d60
Fix mypy errors at gale_shapely_bigraph (#4568) 2021-07-26 14:45:40 +02:00
Hasanul Islam
7342b33658
Fix mypy erros at strongly connected component (#4558) 2021-07-21 07:59:18 +02:00
Hasanul Islam
bc09ba9abf
Fix mypy errors at graph_list (#4557) 2021-07-20 13:24:27 +02:00
Hasanul Islam
4a2216b69a
Fix mypy errors at bidirectional_a_star (#4556) 2021-07-20 09:36:14 +02:00
Hasanul Islam
307ffd8c29
Fix mypy errors at bidirectional_bfs (#4531) 2021-07-12 08:10:07 +02:00
Hasanul Islam
256c319ce2
Fix mypy errors at kruskal_2 (#4528) 2021-07-08 08:46:43 +02:00
strambake
4412eafaac
[mypy] Fix mypy error (#4524) 2021-07-06 09:08:33 +02:00
Hasanul Islam
95862303a6
Fix mypy at prims_algo_2 (#4527) 2021-07-05 08:23:18 +02:00
Hasanul Islam
86baec0bc9
Fix mypy errors at bfs_zero_one_shortest_path (#4521) 2021-07-02 13:52:26 +02:00
Hasanul Islam
62d4418851
Fix mypy error and add more doctest on bfs_shortest_path (#4512) 2021-06-29 19:44:35 +08:00
Hasanul Islam
3ea5a13334
Add doctest and fix mypy type annotation in bellman ford (#4506) 2021-06-24 08:50:23 +02:00
Hasanul Islam
977511b3a3
Add/fix mypy type annotations at BFS, DFS in graphs (#4488) 2021-06-10 22:36:41 +05:30
algobytewise
ce99859ad5
Move files to various folders (#4286)
* 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
2021-03-22 10:54:04 +01:00
Nwachukwu Chidiebere Godwin
03d34350f6
Graph list patch (#4113)
* 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>
2021-01-12 14:41:48 +01:00
Lewis Tian
c39be1d8b8
update graphs/breadth_first_search.py (#3908)
* update graphs/breadth_first_search.py

- update naming style to snake_case
- add type hints

* add doctests
2020-12-09 17:21:46 +08:00
Akash G Krishnan
fa364dfd27
Changed how the Visited nodes are tracked (#3811)
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
2020-11-21 12:28:52 +05:30