Skip to main content

An algorithm visualization tool for jupyter notebook to show animation for vector, table, linked list, tree and graph data structures.

Project description

Algviz

PyPI - Python Version PyPI GitHub PyPI - Downloads

Links

Introduce

Algviz is an algorithm visualization tool for your Python code in Jupyter-notebook.

Algviz can generate visual animations for vector, table, linked list, tree, and graph data structures. You can bring alive animations in your notebook after inserting a few algviz interfaces into code. For example, this animation shows a bubble sort algorithm:

bubble_sort_animation

If you come up with a good algorithm that can solve a problem but don't know how to describe it to your friends. At this point, you can use algviz to create an intuitive animation demo to show the working process of your algorithm. The point is, that you don't need to know about the fundamentals of animation at all. Leave the dirty work to algviz and just focus on how to implement your algorithm.

It's useful when you try to express the working process of a complex algorithm. For example, it's hard to imagine in mind the whole detail of mirror binary tree algorithm. Because the algorithm includes some recursive operations on a binary tree, which subtree was moved first is a headache problem. But no matter how complex the binary tree is, algviz can tell you how the algorithm works by intuitive animations.

mirror_tree_animation

Furthermore, algviz provides some encapsulated data classes which support operations like Python built-in class. For example, you can iterate on the algviz.Vector class just like Python list:

import algviz                   # Import algviz library.
viz = algviz.Visualizer()       # Create a visualizer object.
data = [1, 2, 3]
vector = viz.createVector(data) # Create a vector data object.
for num in vector:              # Iterate over all the elements in vector.
    print(num)
    viz.display()               # Refresh the animation in Jupyter-notebook.

You can modify the data multi-times, and algviz will record all the operations since the last time you call the display interface. Then it will merge all the operations in one animation when you call display next time. So the only thing you need to be concerned about is: when to call the display interface?

Installation

Step1: Install Jupyter-notebook

You can choose any of the following methods to install:

Step2: Install Graphviz

Graphviz is used to generate the static layout of the topology graph. It's a popular open-source software, you can download the program on it's official site.

Note: please remember to add graphviz into your system's environment path so that other programs can call it directly.

Step3: Install algviz

Note: algviz runs on Python 3.7 or heigher versions.

python -m pip install --upgrade pip
pip install algviz

Tutorial

This tutorial helps you start up using algviz quickly. (中文版教程)

All the API references for algviz can be found on readthedocs.

Examples

The examples folder contains some tutorials on how to start with algviz. You can set up your local environment and try them in your notebook.

Try algviz online

You can try the online notebooks on MyBinder and if you are a Google Colab, Kaggle or Gitpod user, you can also try it on Colab, Kaggle or Gitpod.

Open algviz examples in Gitpod

Example MyBinder Kaggle Google Colab Description
vector vector.ipynb binder vector.ipynb kaggle vector.ipynb colab Basic operations on Vector class.
Example of bubble sort algorithm.
table table.ipynb binder table.ipynb kaggle table.ipynb colab Basic operations on Table class.
linked list linked_list.ipynb binder linked_list.ipynb kaggle linked_list.ipynb colab Create linked list and operate ForwardLinkedNode, DoublyLinkedNode classes.
tree tree.ipynb binder tree.ipynb kaggle tree.ipynb colab Create binary tree, normal tree
Operate TreeNode, BinaryTreeNode classes.
Example of mirror binary tree.
Example of construct trie tree.
graph graph.ipynb binder graph.ipynb kaggle graph.ipynb colab Create graph and operate GraphNode class.

Unit Test

Make sure you have successfully installed algviz from PyPi and download the test codes from GitHub.

Then call the command:

python tests/run.py

If you see the output like this:

Congratulations, everything is OK !!!

It means algviz works fine in your environment. But if you get any unexpected errors, please report the bug.

License

Algviz uses GNU general public LICENSE. You can use it freely for learning and communication.

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

algviz-0.1.8.tar.gz (52.8 kB view hashes)

Uploaded Source

Built Distribution

algviz-0.1.8-py3-none-any.whl (55.2 kB view hashes)

Uploaded Python 3

Supported by

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