Package: recursion-visualiser
Recursion VisualiserRecursion visualiser is a python tool that visualizes recursion tree with animation and draws recursion tree for recursive function.
It works with almost any type of recursive function.
Just add the recursion-visualiser decorator to your function and let it do the rest of the work.Installation1. Installing graphvizWindowsThe only dependency for recursion visualiser is GraphvizDownloadgraphviz binaryAdd graphviz bin to path manually or by adding the following line on your script. Change the installation directory according to your installation path# Set it to bin folder of graphviz  
os.environ["PATH"] += os.pathsep +  'C:/Program Files (x86)/Graphviz2.38/bin/'UbuntuInstall graphvizsudo apt install graphvizThe instructions to install graphviz for other operating system is availablehere2. Installing recursion-visualiserThe easiest way to  installrecursion-visualiserpackage is frompypipip install recursion-visualiserAn alternative way is to clone the repository and install all the requirements.pip install -r requirements.txtAlternative Installation using DockerIf you havedockeranddocker-composeinstalled then you can installrecursion-tree-visualiserusingDockeranddocker-compose.ymlfileDownloadDockerfile from repocurlhttps://raw.githubusercontent.com/Bishalsarang/Recursion-Tree-Visualizer/master/Dockerfile--outputDockerfileDownloaddocker-compose.ymlcurlhttps://raw.githubusercontent.com/Bishalsarang/Recursion-Tree-Visualizer/master/docker-compose.yml--outputdocker-compose.ymlStart docker containerCURRENT_UID=$(id-u):$(id-g)docker-composeupRun any python scripts and run usingdocker-compose exec vs python fibonacci.pyUsageThe preferred way to import the decorator class from the package is as:fromvisualiser.visualiserimportVisualiserasvs1.  FibonacciLet's draw the recursion tree for fibonacci number.Here is how the simple code looks likedeffib(n):ifn<=1:returnnreturnfib(n-1)+fib(n-2)print(fib(6))Now we want to draw the recursion tree for this function. It is as simple as adding a decorator# Author: Bishal Sarang# Import Visualiser class from module visualiserfromvisualiser.visualiserimportVisualiserasvs# Add decorator# Decorator accepts optional arguments: ignore_args , show_argument_name, show_return_value and node_properties_kwargs@vs(node_properties_kwargs={"shape":"record","color":"#f57542","style":"filled","fillcolor":"grey"})deffib(n):ifn<=1:returnnreturnfib(n=n-1)+fib(n=n-2)defmain():# Call functionprint(fib(n=6))# Save recursion tree to a filevs.make_animation("fibonacci.gif",delay=2)if__name__=="__main__":main()Here are the changes required:Add decorator Visualiser which accepts optional argumentsignore_args,show_argument_nameand 'show_return_value'Change every function calls to pass as keyword arguments.Make_animationThe output image are saved as "fibonacci.gif" and "fibonacci.png"Here is how the recursion tree looks like:Animation:Support:Find other exampleshereand read more aboutrecursion-visualiserhereTODO:Minimal working versionUpload package to pypiSupport animationAdd node stylesSupport aliasing for function nameShow repeated statesSupport node_color, backgroundcolor etcRefactorHandle base casesMake more beautiful trees