Commit Graph

113 Commits

Author SHA1 Message Date
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
Lewis Tian
83a24cb06d
Update graphs/graph_list.py (#3813)
- update naming style to snake_case
- add type hints
2020-11-08 20:34:01 +05:30
Lewis Tian
4fa8c9d4b4
Update graphs/depth_first_search_2.py (#3799)
- update naming style to snake_case
- add type hints
2020-10-29 08:35:31 +08:00
Phil Bazun
5be77f33f7
Add 0-1-bfs. (#3285)
* Add 0-1-bfs.

* fixup! Add 0-1-bfs.

* fixup! Add 0-1-bfs.

* Check edge weights.

* Check edge vertecies.
2020-10-24 23:07:04 +02:00
Christian Clauss
9b95e4f662
Pyupgrade to python3.8 (#3616)
* Upgrade to Python 3.8 syntax

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-21 12:46:14 +02:00
Christian Clauss
5b024f4dd5
BROKEN BUILD: Fix a failing precommit test (#3344)
* Fix a failing precommit test

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-16 00:33:25 +02:00
Meysam
cc050dbf5b
test/graphs/prim: writing a test case to verify the correctness of the algorithm (#2454) 2020-10-15 21:10:35 +02:00
Meysam
83b825027e
Graphs/kruskal: adding doctest & type hints (#3101)
* 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>
2020-10-15 21:08:52 +02:00
Tapajyoti Bose
02d3ab81bd
feat: added prim's algorithm v2 (#2742)
* feat: added prim's algorithm v2

* updating DIRECTORY.md

* chore: small tweaks

* fixup! Format Python code with psf/black push

* chore: added algorithm descriptor

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-10 12:18:52 +05:30
Meysam
c2a5033f9e
graphs/kruskal: add a test case to verify the correctness, fix styles (#2443)
* 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>
2020-10-08 20:21:48 +08:00
Dhruv
48357cea5b
Add __init__.py files in all the directories (#2503) 2020-09-28 19:42:36 +02:00
Christian Clauss
9200a2e543
from __future__ import annotations (#2464)
* from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-23 13:30:13 +02:00
Du Yuanchao
d6bff5c133
Renamed files and fixed Doctest (#2421)
* * Renamed files
* Fiexed doctest

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-13 13:27:20 +02:00
Hasenn
20e98fcded
Fix some warnings from LGTM (#2420)
* 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>
2020-09-13 10:11:27 +02:00
Marcos Cannabrava
a191f89fe2
Fix Non Recursive Depth First Search (#2207)
* 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>
2020-09-11 16:23:26 +02:00
Du Yuanchao
4d0a8f2355
Optimized recursive_bubble_sort (#2410)
* optimized recursive_bubble_sort

* Fixed doctest error due whitespace

* reduce loop times for optimization

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-10 10:31:26 +02:00
Tapajyoti Bose
aa46639cbc
Added Kruskal's Algorithm (more organized than the one present) (#2218)
* Added Kruskal's Algorithm

* Added Type Hints

* fixup! Format Python code with psf/black push

* Added Type Hints V2

* Implemented suggestions + uniform naming convention

* removed redundant variable (self.nodes)

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-12 12:16:17 +02:00
Christian Clauss
1fb1fdd130
requirements.txt: Unpin numpy (#2287)
* requirements.txt: Unpin numpy

* fixup! Format Python code with psf/black push

* Less clutter

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-06 17:50:23 +02:00
Arin Khare
c6c9f4707b
Karger's Algorithm (#2237)
* 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
2020-08-01 09:30:34 +05:30
KARTHIKEYAN ANBARASU
e292ddb5ec
Update basic_graphs.py (#1990)
* Update basic_graphs.py

missing return statement line no:223.

* Update basic_graphs.py

Co-authored-by: vinayak <itssvinayak@gmail.com>
2020-07-13 09:17:13 +05:30
Marcos Cannabrava
728c0df355
Fix typo: Adjancent -> Adjacent (#2184) 2020-07-06 22:00:07 -05:00
Christian Clauss
2c75a7b3dd
Numerous fixes to directed_and_undirected_(weighted)_graph.py (#2182)
* Numerous fixes to directed_and_undirected_(weighted)_graph.py

* dict.keys() is almost never need in modern Python
2020-07-06 19:31:04 +02:00
Christian Clauss
5f4da5d616
isort --profile black . (#2181)
* updating DIRECTORY.md

* isort --profile black .

* Black after

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-07-06 09:44:19 +02:00
Christian Clauss
cd3e8f95a0
isort --profile black --recursive . (#2170)
* isort --profile black --recursive .

* Update codespell.yml

* typo: vertices

* typo: Explanation

* typo: Explanation

* Fix typos
2020-07-06 08:48:18 +05:30
Akash Shroff
25d9d819a2
Gale Shapley Algorithm (#2100)
* 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>
2020-07-05 11:21:32 +02:00
vinayak
2d3d660155
black fixes and Travis CI fixes (#2160)
* 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>
2020-07-02 20:02:15 +05:30
wuyudi
d2fa91b18e
Add url and typing hint for BFS (#2156)
* 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>
2020-06-25 17:54:41 +02:00
Nika Losaberidze
fb3a228d26
Strongly connected components (#2114)
* Implement strongly connected components for graph algorithms

* fixup! Format Python code with psf/black push

* Delete trailing whitespace

* updating DIRECTORY.md

* Add doctests and typehints

* Remove unnecessary comments, change variable names

* fixup! Format Python code with psf/black push

* Change undefined variable's name

* 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>
2020-06-17 18:16:54 +02:00