Skip to content

Commit 609930b

Browse files
author
sarangbishal
committed
Add LICENSE.md and CONTRIBUTING.md
1 parent a8e91db commit 609930b

File tree

12 files changed

+74
-9
lines changed

12 files changed

+74
-9
lines changed

CONTRIBUTING.md

Whitespace-only changes.

Examples.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Recursion Visualiser Examples:
2+
In this example series, I'm going to start with making minimal recursion tree to making some complex recursion tree.
3+
4+
Let's start with first example:

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Bishal Sarangkoti
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Recursion Visualiser
2+
3+
![](https://forthebadge.com/images/badges/made-with-python.svg)
4+
25
Recursion visualiser is a python tool that visualizes recursion tree with animation and draws recursion tree for recursive function.
36
It works with almost any type of recursive function.
47
Just add the recursion-visualiser decorator to your function and let it do the rest of the work.
@@ -45,8 +48,8 @@ Now we want to draw the recursion tree for this function. It is as simple as add
4548
from visualiser.visualiser import Visualiser as vs
4649

4750
# Add decorator
48-
# Decorator accepts arguments: ignore_args and show_argument_name
49-
@vs()
51+
# Decorator accepts optional arguments: ignore_args , show_argument_name, show_return_value and node_properties_kwargs
52+
@vs(node_properties_kwargs={"shape":"record", "color":"#f57542", "style":"filled", "fillcolor":"grey"})
5053
def fib(n):
5154
if n <= 1:
5255
return n
@@ -73,9 +76,9 @@ Here are the changes required:
7376

7477
Here is how the recursion tree looks like:
7578
Animation:
76-
![enter image description here](https://github.com/sarangbishal/Recursion-Visualizer/blob/master/examples/fibonacci.gif)
79+
![enter image description here](https://raw.githubusercontent.com/sarangbishal/Recursion-Tree-Visualizer/master/examples/fibonacci.gif)
7780

78-
![enter image description here](https://github.com/sarangbishal/Recursion-Visualizer/blob/master/examples/fibonacci.png)
81+
![enter image description here](https://raw.githubusercontent.com/sarangbishal/Recursion-Tree-Visualizer/master/examples/fibonacci.png)
7982

8083
Find other examples : [here](https://github.com/sarangbishal/Recursion-Tree-Visualizer/tree/master/examples)
8184
and read more about **recursion-visualiser** [here](https://github.com/sarangbishal/Recursion-Tree-Visualizer/blob/master/Examples.md)
@@ -87,7 +90,7 @@ and read more about **recursion-visualiser** [here](https://github.com/sarangbis
8790
- [x] Add node styles
8891
- [ ] Support aliasing for function name
8992
- [ ] Show repeated states
90-
- [ ] Support node_color, backgroundcolor etc
93+
- [x] Support node_color, backgroundcolor etc
9194
- [ ] Refactor
9295
- [ ] Handle base cases
9396
- [ ] Make more beautiful trees

examples/binary_string.gif

1.03 MB
Loading

examples/binary_string.png

40.9 KB
Loading

examples/binary_string.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from visualiser.visualiser import Visualiser as vs
2+
3+
"""
4+
Problem Link: https://stackoverflow.com/questions/33808653/recursion-tree-with-fibonacci-python/60126306#60126306
5+
"""
6+
7+
@vs(node_properties_kwargs={"shape":"record", "color":"#f57542", "style":"filled", "fillcolor":"grey"})
8+
def binary(length, outstr=""):
9+
if len(outstr) == length:
10+
print(outstr)
11+
else:
12+
for i in ["0", "1"]:
13+
binary(length=length, outstr=outstr + i)
14+
15+
binary(length=3,outstr="")
16+
vs.make_animation("binary_string.gif", delay=2)

examples/factorial.gif

90.2 KB
Loading

examples/factorial.png

31.8 KB
Loading

examples/factorial.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Author: Bishal Sarang
2+
3+
# Import Visualiser class from module visualiser
4+
from visualiser.visualiser import Visualiser as vs
5+
6+
# Add decorator
7+
# Decorator accepts optional arguments: ignore_args , show_argument_name, show_return_value and node_properties_kwargs
8+
@vs()
9+
def fact(n):
10+
if n <= 1:
11+
return n
12+
return n * fact(n=n-1)
13+
14+
15+
def main():
16+
# Call function
17+
print(fact(n=6))
18+
# Save recursion tree to a file
19+
vs.make_animation("factorial.gif", delay=2)
20+
21+
22+
if __name__ == "__main__":
23+
main()

0 commit comments

Comments
 (0)