Translation of the Java code in "Algorithms" by Sedgwick and Wayne to python3
https://algs4.cs.princeton.edu/home/
https://introcs.cs.princeton.edu/python/home/
https://algs4.cs.princeton.edu/code/
https://github.com/kevin-wayne/algs4
Riko Jacob rikj@itu.dk, Thore Husfeldt thore@itu.dk,
Morten Tychsen Clausen mocl@itu.dk, Frederik Haagensen haag@itu.dk, Anton Mølbjerg Eskildsen aesk@itu.dk, Andreas Holck Høeg-Petersen anhh@itu.dk, Martino Secchi msec@itu.dk, Otto Stadel Clausen otcl@itu.dk
https://www.python.org/dev/peps/pep-0008/#prescriptive-naming-conventions
Use somehting like
class DirectedDFS:
def __init__(self, G, *s):
like in graphs/directed_dfs.py
Otherwise we use static factory methods where the name indicates the expected type.
If appropriate we use isinstance()
and its variants, for example to distinguish undirected and directed graphs.
file names, variables, methods are file_name (and not CamelCase, adjustting from algs4), only classes are CamelCase (PascalCase)
there is one file per version of an algorithm / data structure (like in algs4), the name, and importantly the docstring, reflects which version it is
- lower case letter with underscore
- like in the book
- private variables become _variable_name
- should we include generators (additionally to iterators) everywhere?