Skip to main content
Fibonacci recursion tree animation

Overview

Recursion Tree Visualiser is a Python decorator library that automatically generates visual representations of recursive function calls. Simply add the @Visualiser decorator to your recursive function and watch your recursion tree come to life with animations. The library works with almost any type of recursive function, from simple examples like Fibonacci and factorial to complex algorithms like dynamic programming solutions.

Key features

Zero-code visualization

Add a single decorator to your function - no code changes required

Animated recursion trees

Generate GIF animations showing how recursion unfolds step-by-step

Highly customizable

Control node colors, shapes, labels, and return value display

Works everywhere

Compatible with any recursive function - Fibonacci, factorial, dynamic programming, and more

Quick example

Here’s how easy it is to visualize a Fibonacci function:
from visualiser.visualiser import Visualiser as vs

@vs()
def fib(n):
    if n <= 1:
        return n
    return fib(n=n - 1) + fib(n=n - 2)

print(fib(n=6))
vs.make_animation("fibonacci.gif", delay=2)
This generates both a static PNG image and an animated GIF showing the complete recursion tree.

Get started

Installation

Install graphviz and the recursion-visualiser package

Quickstart

Create your first recursion tree in under 5 minutes

Examples

Explore visualization examples for different recursive algorithms

API reference

Complete reference for all decorator options and methods

What you’ll learn

This documentation will guide you through:
  • Installing graphviz and the Python package on different platforms
  • Adding the visualizer decorator to your recursive functions
  • Customizing node appearance with colors, shapes, and styles
  • Generating static images and animated GIFs
  • Controlling what information appears in the tree (arguments, return values)
  • Troubleshooting common issues

Python version support

Recursion Tree Visualiser requires Python 3.6 or higher.

Build docs developers (and LLMs) love