A Python package to plot the graph for calls to a recursive function
Project description
Recursion Tree Plotter
A python decorator to generate a visual tree for recursive functions.
Installation
$ pip install recurstion-tree-plotter
Example
Let's say you have a recursive function for finding n-th element in Fibonacci sequence.
def fib(n):
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)
In order to plot a recursion tree for an execution of above function (say fib(5)
), we put @plot_recursion_tree
decorator over it.
from recursion_tree_plotter import plot_recursion_tree
@plot_recursion_tree
def fib(n):
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)
And boom!
In the tree, node label is constructed as <comma-separated args> [<counter>]
where counter
specifies the order
of execution.
Check out examples
folder for more examples!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for recursion-tree-plotter-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | abb890d4dcf23f4da0b082ed415e0c2bac3b770e543c0398d0e2225ede202069 |
|
MD5 | ecfa373bdd09de15efa971f87df4d8f5 |
|
BLAKE2b-256 | b3ad8fc8875e13df61095c810d8d3c86cef79a337c21ab605a0647b11bdd2569 |
Close
Hashes for recursion_tree_plotter-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7599eb6b8fbb8d8d27fe5f61c780bc1a4538701ce8f0f15973abec1c31de008 |
|
MD5 | 0686acba819814e6781482e4255c82b5 |
|
BLAKE2b-256 | 49a9e964a5aaff9c977c099f8420f0e4da5fc120e49f3d3ba5b280cb6c54f88c |