Skip to content

Commit a8e91db

Browse files
author
sarangbishal
committed
Version 1.0.1: Add node styles
1 parent de1f54a commit a8e91db

File tree

16 files changed

+57
-18
lines changed

16 files changed

+57
-18
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ test*
44
img
55
out*
66
*frames*
7+
8+
packaging.txt
9+
710
# Byte-compiled / optimized / DLL files
811
__pycache__/
912
*.py[cod]
@@ -630,3 +633,5 @@ MigrationBackup/
630633
# Ionide (cross platform F# VS Code tools) working folder
631634
.ionide/
632635

636+
!/packaging.txt
637+
!/packaging.txt

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,14 @@ Animation:
7777

7878
![enter image description here](https://github.com/sarangbishal/Recursion-Visualizer/blob/master/examples/fibonacci.png)
7979

80-
## 2. Make sum
81-
This is taken from one of my answers on quora where I had to manually draw recursion tree. Using Visualiser with very less changes I was able to draw the following tree. You can compare the tree [here](https://qr.ae/TltTCV)
82-
![enter image description here](https://github.com/sarangbishal/Recursion-Visualizer/blob/master/examples/make_sum.png)
83-
84-
80+
Find other examples : [here](https://github.com/sarangbishal/Recursion-Tree-Visualizer/tree/master/examples)
81+
and read more about **recursion-visualiser** [here](https://github.com/sarangbishal/Recursion-Tree-Visualizer/blob/master/Examples.md)
8582

8683
## TODO:
8784
- [x] Minimal working version
8885
- [x] Upload package to pypi
8986
- [x] Support animation
87+
- [x] Add node styles
9088
- [ ] Support aliasing for function name
9189
- [ ] Show repeated states
9290
- [ ] Support node_color, backgroundcolor etc

examples/coin_change.png

-17.6 KB
Loading

examples/combinations.gif

725 KB
Loading

examples/combinations.png

29.7 KB
Loading

examples/combinations.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from visualiser.visualiser import Visualiser as vs
2+
3+
st= []
4+
@vs(show_argument_name=False, node_properties_kwargs={"shape":"record", "color":"#f57542", "style":"filled", "fillcolor":"grey"})
5+
def combi(prefix, s):
6+
if len(s) == 0:
7+
return " "
8+
else:
9+
st.append(prefix + s[0])
10+
combi(prefix=prefix + s[0], s=s[1:])
11+
combi(prefix=prefix, s=s[1:])
12+
return st
13+
14+
print(combi(prefix="",s='abc'))
15+
vs.make_animation("combinations.gif", delay=3)

examples/fibonacci.gif

-279 KB
Loading

examples/fibonacci.png

-44.9 KB
Loading

examples/fibonacci.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Author: Bishal Sarang
22

33
# Import Visualiser class from module visualiser
4-
from visualiser.visualiser import Visualiser as vs
4+
5+
from test import Visualiser as vs
56

67
# Add decorator
7-
# Decorator accepts arguments: ignore_args and show_argument_name
8-
@vs()
8+
# Decorator accepts optional arguments: ignore_args , show_argument_name, show_return_value and node_properties_kwargs
9+
@vs(node_properties_kwargs={"shape":"record", "color":"#f57542", "style":"filled", "fillcolor":"grey"})
910
def fib(n):
1011
if n <= 1:
1112
return n

examples/make_sum.png

4.38 KB
Loading

0 commit comments

Comments
 (0)