Commit Graph

197 Commits

Author SHA1 Message Date
onlinejudge95
7b7c1a0135
Fixes unused variable errors in LGTM (#1746)
* Fixes unsed variable errors in LGTM

* Fixes integer check

* Fixes failing tests
2020-02-11 13:59:09 +05:30
Kyle
724b7d2198 Add Prim's algorithm with min heap (#1704) 2020-01-22 02:46:03 +08:00
Christian Clauss
bfcb95b297
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
2020-01-18 13:24:33 +01:00
Christian Clauss
28419cf839 pyupgrade --py37-plus **/*.py (#1654)
* pyupgrade --py37-plus **/*.py

* fixup! Format Python code with psf/black push
2020-01-03 22:25:36 +08:00
Kyle
5f57ac975f Add docstr and algorithm to BFS shortest path module (#1637)
* Add docs and type alias to bfs_shortest_path.py

* Add bfs_shortest_path_distance algorithm

* Make requested changes
2019-12-19 10:40:16 +01:00
Christian Clauss
26b0803319
Simplify sudoku.is_completed() using builtin all() (#1608)
* 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
2019-12-08 22:42:17 +01:00
GeorgeChambi
9eb50cc223 Improved readability (#1615)
* improved readability

* further readability improvements

* removed csv file and added f
2019-12-07 06:39:59 +01:00
Bruno Santos
415c9f5e65 Improve prim.py (#1226)
* suiting PEP8

* create auxiliary function

* running example

* updating DIRECTORY.md
2019-12-01 06:13:28 +01:00
John Law
28c02a1f21
Improve bellman_ford.py (#1575)
* 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
2019-11-19 13:52:55 -08:00
JakobZhao
82a11d7f31 Fix bug in bellman_ford.py (#1544) 2019-11-10 17:01:38 +08:00
Ankur Chattopadhyay
7592cba417 psf/black code formatting (#1421)
* added sol3.py for problem_20

* added sol4.py for problem_06

* ran `black .` on `\Python`
2019-10-22 19:13:48 +02:00
Daniel Melo
906c985de3 Create dinic.py (#1396)
* Create dinic.py

Dinic's algorithm for maximum flow

* Update dinic.py

Changes made.
2019-10-22 11:37:43 +02:00
Phyllipe Bezerra
455509acee Add Topological Sort (#1302)
* add topological sort

* fix topological sort?

* running black

* renaming file
2019-10-18 08:13:58 +02:00
William Zhang
9eac17a408 psf/black code formatting (#1277) 2019-10-05 10:14:13 +05:00
Hector S
2304e31994 Fixing lgtm issue in basic graphs (#1141)
* Added print function into matrix_multiplication_addition.py and removed blank space in data_structures/binary tree directory

* Removed .vs/ folder per #893

* Rename matrix_multiplication_addition.py to matrix_operation.py

* Fixing lgtm issue in basic_graphs per ##1024

* Fixed lgtm issue per @cclauss recommendation in #1024
2019-08-20 07:02:43 +02:00
Christian Clauss
47a9ea2b0b
Simplify code by dropping support for legacy Python (#1143)
* Simplify code by dropping support for legacy Python

* sort() --> sorted()
2019-08-19 15:37:49 +02:00
Christian Clauss
3c8e9314b6 Travis CI: Add a flake8 test for unused imports (#1038) 2019-07-25 13:19:00 +05:30
Christian Clauss
0f09530707 dijkstra.py: Use r"strings" to fix two pylint warnings (#1052)
```
=============================== warnings summary ===============================
graphs/dijkstra.py:81
  /home/travis/build/TheAlgorithms/Python/graphs/dijkstra.py:81: DeprecationWarning: invalid escape sequence \ 
    """
graphs/dijkstra.py:97
  /home/travis/build/TheAlgorithms/Python/graphs/dijkstra.py:97: DeprecationWarning: invalid escape sequence \ 
    """
-- Docs: https://docs.pytest.org/en/latest/warnings.html
=================== 126 passed, 7 warnings in 19.35 seconds ====================
```
2019-07-21 00:31:08 +08:00
cclauss
7cdda931fd
Travis CI: Add pytest --doctest-modules graphs (#1018) 2019-07-17 06:07:25 +02:00
Bruno Simas Hadlich
267b5eff40 Added doctest and more explanation about Dijkstra execution. (#1014)
* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'
2019-07-17 01:09:53 +02:00
Alfonso Rodríguez Pereira
5f991f7740 #315 Renamed all files to snake_case (#993) 2019-07-11 11:16:42 +02:00
PatOnTheBack
2ad5be9919 Modified Docstrings to Fix Errors (#975)
I modified the Docstrings at the beginning of the file to fix D400, W0105, and E402.
2019-07-10 22:00:30 +02:00
zachzhu2016
a212efee5b Corrected wrong Dijkstra priority queue implementation (#909)
* Corrected wrong DFS implementation

* changed list into hash set for dijkstra priority queue implementation.
2019-06-23 23:32:12 +08:00
StephenGemin
a99acae32d Add docstring and comments per Issue #727 (#895)
I've added comments to make understanding this method a little easier for those that are not familiar.  This should close out #727 .

Other changes:
1. added if __name__ == '__main__' rather than the "# MAIN" comment
2. put in return for distances and vertices.  Previously everything was just printed out, but someone may find it useful to have the algorithm return something.
3. Other PEP8 changes
4.  Added example input and expected output as a check to make sure any future changes will give the same output.
2019-06-18 18:28:01 +08:00
zachzhu2016
55e0b0f00a Corrected wrong DFS implementation (#903) 2019-06-17 18:13:36 +08:00
Daniel Xu
ebe227c386 Removed Graphs and move prim.py to graphs (#872)
* Move prim.py from Graphs to graphs

* Removed prim.py from Graphs

* Update prim.py
2019-06-05 09:37:05 +08:00
Guo
f9b8dbf9db Correct the wrong iterative DFS implementation (#867)
* Update DFS.py

* Update DFS.py
2019-06-04 16:34:28 +08:00
Anup Kumar Panwar
71be23999c refactor 2019-05-26 21:56:10 +05:30
Anirudh Ajith
b5667e5ee9 Removed the (incorrectly named) redundant file graph_list.py and renamed graph.py to graph_list.py (#820) 2019-05-21 14:06:05 +08:00
Sarvesh Dubey
f3608acfd5 Created shortest path using bfs (#794)
* Created shortest path using bfs
2019-05-17 11:12:06 +08:00
Erfan Alimohammadi
a65efd42c4 Implement check_bipartite_graph using DFS. (#808) 2019-05-16 19:24:56 +08:00
ImNandha
13c0c166d8 Update graph.py (#809) 2019-05-16 19:23:23 +08:00
Anup Kumar Panwar
e22ea7e380
Update Directed and Undirected (Weighted) Graph.py 2019-05-04 21:53:06 +05:30
Vysor
df04d94543 Some directories had a capital in their name [fixed]. Added a recursive factorial algorithm. (#763)
* Renaming directories
* Adding a recursive factorial algorithm
2019-04-22 22:53:56 +08:00
Reshad Hasan
9a44eb4479 Organize graph algorithms (#719)
* organized graph algorithms

* all graph algorithms in Graphs/ folder

* all graph algorithms are in one folder

* Rename number theory/factorial_python.py to maths/factorial_python.py
2019-02-25 17:35:24 +08:00
Reshad Hasan
af08a67b20 added the dijkstra algorithm (#704) 2019-02-18 23:35:46 +08:00
Rizwan Hasan
c6be53e1c4 Rename Directed and Undirected (Weighted) Graph to Directed and Undirected (Weighted) Graph.py (#686) 2019-01-26 21:09:18 +08:00
Safari
069d2b9cb6
All Python Version 3
Added functions to get all nodes for some algorithms and time calculation for dfs and bfs.
2018-12-16 22:19:40 +03:30
A Safari
b3a15175bd
Added more functionality
Added topological sort, cycle detection and a function to report the nodes participating in cycles in graph(for a use case I myself needed ).
2018-12-14 23:14:35 +03:30
A Safari
889f8fba3d
Added getting node degree functionality to both directed and undirected graph
Easy to use directed and undirected graph in python 3
2018-12-14 15:28:45 +03:30
A Safari
e97565d21f
Added (Weighted) Undirected graph
Python version 3
2018-12-14 15:08:37 +03:30
A Safari
687af17d47
Added some examples.
Added examples and comments for more readable code.
2018-12-14 10:31:45 +03:30
A Safari
fa2eecdc30
Directed graph with optional weight assignment .
Containing graph auto-fill, dfs and bfs.
2018-12-14 10:22:18 +03:30
Shivam Arora
1a5df6bc46 Added the method to find the isolated nodes in the graph 2018-10-31 16:14:30 +05:30
Alex Brown
ea2ddaaf6a all valid python 3 2018-10-20 14:45:08 -05:00
Alex Brown
91fccecb56 snake_case all the things 2018-10-19 17:14:25 -05:00
Alex Brown
564179a0ec increment 1 2018-10-19 07:48:28 -05:00