{"id":13738352,"url":"https://github.com/Bishalsarang/Recursion-Tree-Visualizer","last_synced_at":"2025-05-08T16:33:33.572Z","repository":{"id":49950066,"uuid":"243515149","full_name":"Bishalsarang/Recursion-Tree-Visualizer","owner":"Bishalsarang","description":"A simple python package that helps to visualise any recursive function by adding a single line of code.","archived":false,"fork":false,"pushed_at":"2024-03-02T03:39:01.000Z","size":6548,"stargazers_count":111,"open_issues_count":7,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-14T18:55:13.536Z","etag":null,"topics":["hacktoberfest","hacktoberfest2020","recursion","recursion-tree","recursion-tree-visualiser","recursion-tree-visualizer","visualiser","visualization"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/recursion-visualiser/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bishalsarang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-02-27T12:34:14.000Z","updated_at":"2024-11-01T16:10:44.000Z","dependencies_parsed_at":"2023-12-24T07:13:51.881Z","dependency_job_id":"bf52f9f0-b920-49d9-af78-e23f9b241163","html_url":"https://github.com/Bishalsarang/Recursion-Tree-Visualizer","commit_stats":{"total_commits":39,"total_committers":3,"mean_commits":13.0,"dds":"0.23076923076923073","last_synced_commit":"c9f794ec6b6b741246e8347ffd54efea06b1cb09"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bishalsarang%2FRecursion-Tree-Visualizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bishalsarang%2FRecursion-Tree-Visualizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bishalsarang%2FRecursion-Tree-Visualizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bishalsarang%2FRecursion-Tree-Visualizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bishalsarang","download_url":"https://codeload.github.com/Bishalsarang/Recursion-Tree-Visualizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224746624,"owners_count":17363081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","hacktoberfest2020","recursion","recursion-tree","recursion-tree-visualiser","recursion-tree-visualizer","visualiser","visualization"],"created_at":"2024-08-03T03:02:19.692Z","updated_at":"2024-11-15T07:30:52.042Z","avatar_url":"https://github.com/Bishalsarang.png","language":"Python","readme":"# Recursion Visualiser  \n\n![](https://forthebadge.com/images/badges/made-with-python.svg)\n\n![PyPI downloads](https://img.shields.io/pypi/dm/recursion-visualiser)\n![Stars](https://img.shields.io/github/stars/Bishalsarang/Recursion-Tree-Visualizer)\n![Forks](https://img.shields.io/github/forks/Bishalsarang/Recursion-Tree-Visualizer)\n\n![](https://img.shields.io/pypi/v/recursion-visualiser)\n![](https://img.shields.io/pypi/pyversions/recursion-visualiser)\n![](https://img.shields.io/github/license/Bishalsarang/Recursion-Tree-Visualizer?logo=MIT)\n\nRecursion visualiser is a python tool that visualizes recursion tree with animation and draws recursion tree for recursive function.\nIt works with almost any type of recursive function.\nJust add the recursion-visualiser decorator to your function and let it do the rest of the work.\n\n  \n  ## Installation  \n  ### 1. Installing graphviz\n  #### Windows\nThe only dependency for recursion visualiser is Graphviz\n- Download  [graphviz binary](https://www2.graphviz.org/Packages/stable/windows/10/msbuild/Release/Win32/)  \n- Add graphviz bin to path manually or by adding the following line on your script. Change the installation directory according to your installation path  \n```  \n# Set it to bin folder of graphviz  \nos.environ[\"PATH\"] += os.pathsep +  'C:/Program Files (x86)/Graphviz2.38/bin/'  \n```  \n  \n  #### Ubuntu \n  - Install graphviz\n  ```\n   sudo apt install graphviz\n  ```\n\n\u003e  The instructions to install graphviz for other operating system is available  [here](https://www.graphviz.org/download/#linux)\n\n### 2. Installing recursion-visualiser\n\nThe easiest way to  install ```recursion-visualiser``` package is from [pypi](https://pypi.org/project/recursion-visualiser/)\n```\npip install recursion-visualiser\n```\n\n\nAn alternative way is to clone the repository and install all the requirements.\n```\npip install -r requirements.txt\n```\n\n## Alternative Installation using Docker\nIf you have `docker` and `docker-compose` installed then you can install `recursion-tree-visualiser`  using `Docker` and `docker-compose.yml` file\n1.  Download `Docker` file from repo\n```bash\ncurl https://raw.githubusercontent.com/Bishalsarang/Recursion-Tree-Visualizer/master/Dockerfile --output Dockerfile\n```\n\n3. Download `docker-compose.yml`\n```bash\ncurl https://raw.githubusercontent.com/Bishalsarang/Recursion-Tree-Visualizer/master/docker-compose.yml --output docker-compose.yml\n```\n5. Start docker container\n```bash\nCURRENT_UID=$(id -u):$(id -g) docker-compose up\n```\n\n7. Run any python scripts and run using\n```\ndocker-compose exec vs python fibonacci.py\n```\n## Usage \nThe preferred way to import the decorator class from the package is as:\n```python\nfrom visualiser.visualiser import Visualiser as vs\n```\n### 1.  Fibonacci  \nLet's draw the recursion tree for fibonacci number.  \nHere is how the simple code looks like  \n```python  \ndef fib(n):  \n    if n \u003c= 1: \n        return n \n    return fib(n - 1) + fib(n - 2)  \n\nprint(fib(6))  \n```  \n  \nNow we want to draw the recursion tree for this function. It is as simple as adding a decorator  \n```python  \n# Author: Bishal Sarang\n\n# Import Visualiser class from module visualiser\nfrom visualiser.visualiser import Visualiser as vs\n\n# Add decorator\n# Decorator accepts optional arguments: ignore_args , show_argument_name, show_return_value and node_properties_kwargs\n@vs(node_properties_kwargs={\"shape\":\"record\", \"color\":\"#f57542\", \"style\":\"filled\", \"fillcolor\":\"grey\"})\ndef fib(n):\n    if n \u003c= 1:\n        return n\n    return fib(n=n - 1) + fib(n=n - 2)\n\n\ndef main():\n    # Call function\n    print(fib(n=6))\n    # Save recursion tree to a file\n    vs.make_animation(\"fibonacci.gif\", delay=2)\n\n\nif __name__ == \"__main__\":\n    main()\n```  \nHere are the changes required:  \n \n - Add decorator Visualiser which accepts optional arguments `ignore_args`, `show_argument_name`  and 'show_return_value'   \n - Change every function calls to pass as keyword arguments.  \n - Make_animation\n  \n The output image are saved as \"fibonacci.gif\" and \"fibonacci.png\"\n \nHere is how the recursion tree looks like:  \nAnimation:\n![enter image description here](https://raw.githubusercontent.com/Bishalsarang/Recursion-Tree-Visualizer/master/examples/fibonacci.gif)  \n  \n![enter image description here](https://raw.githubusercontent.com/Bishalsarang/Recursion-Tree-Visualizer/master/examples/fibonacci.png)  \n\n\n## Support\nIf you like this project and want to support it, consider buying me a coffee!\n\n[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/bishalsarang)\n\nThank you for your support!\n\n\n## TODO:  \n - [x] Minimal working version  \n - [x] Upload package to pypi  \n - [x] Support animation\n - [x] Add node styles\n - [ ] Support aliasing for function name\n - [ ] Show repeated states\n - [x] Support node_color, backgroundcolor etc\n - [ ] Refactor  \n - [ ] Handle base cases  \n - [ ] Make more beautiful trees\n","funding_links":["https://www.buymeacoffee.com/bishalsarang"],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBishalsarang%2FRecursion-Tree-Visualizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBishalsarang%2FRecursion-Tree-Visualizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBishalsarang%2FRecursion-Tree-Visualizer/lists"}