Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

recursion-tree-plotter-1.0.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

recursion_tree_plotter-1.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file recursion-tree-plotter-1.0.1.tar.gz.

File metadata

  • Download URL: recursion-tree-plotter-1.0.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for recursion-tree-plotter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 abb890d4dcf23f4da0b082ed415e0c2bac3b770e543c0398d0e2225ede202069
MD5 ecfa373bdd09de15efa971f87df4d8f5
BLAKE2b-256 b3ad8fc8875e13df61095c810d8d3c86cef79a337c21ab605a0647b11bdd2569

See more details on using hashes here.

File details

Details for the file recursion_tree_plotter-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: recursion_tree_plotter-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for recursion_tree_plotter-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7599eb6b8fbb8d8d27fe5f61c780bc1a4538701ce8f0f15973abec1c31de008
MD5 0686acba819814e6781482e4255c82b5
BLAKE2b-256 49a9e964a5aaff9c977c099f8420f0e4da5fc120e49f3d3ba5b280cb6c54f88c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page