Skip to main content

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!

Metadata

Release files for recursion-tree-plotter 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recursion-tree-plotter 1.0.1
File Size Uploaded
recursion-tree-plotter-1.0.1.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for recursion-tree-plotter 1.0.1
File Interpreter ABI Platform
recursion_tree_plotter-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 kB

Release files / recursion-tree-plotter-1.0.1.tar.gz

Download URL recursion-tree-plotter-1.0.1.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
abb890d4dcf23f4da0b082ed415e0c2bac3b770e543c0398d0e2225ede202069
BLAKE2b-256 checksum
How to use checksums
b3ad8fc8875e13df61095c810d8d3c86cef79a337c21ab605a0647b11bdd2569
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.23.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.6.9

Release files / recursion_tree_plotter-1.0.1-py3-none-any.whl

Download URL recursion_tree_plotter-1.0.1-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f7599eb6b8fbb8d8d27fe5f61c780bc1a4538701ce8f0f15973abec1c31de008
BLAKE2b-256 checksum
How to use checksums
49a9e964a5aaff9c977c099f8420f0e4da5fc120e49f3d3ba5b280cb6c54f88c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.23.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.46.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page