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 Conda-forge License PyPI - Downloads

What is algviz?

Algviz is an algorithm animation engine for your Python code in Jupyter, which supports multiple data structures such as vector, table, linked_list, tree and graph.

Vector Table Tree Graph
vector.svg table.svg tree.svg graph.svg

You can get live algorithm animation after bringing some algviz interfaces to your algorithm. For example, this code shows the bubble sort algorithm:

import algviz

def bubble_sort(data):
    viz = algviz.Visualizer(0.5)
    vector = viz.createVector(data, cell_size=(40, 160), histogram=True)
    for i in range(len(vector)):
        for j in range(len(vector)-i-1):
            if vector[j] > vector[j+1]:
                vector.mark(algviz.cRed, j)
                vector.mark(algviz.cGreen, j+1)
                viz.display()
                vector.swap(j, j+1)
            else:
                vector.mark(algviz.cRed, j+1)
                vector.mark(algviz.cGreen, j)
            viz.display()
        vector.mark(algviz.cGray, len(vector)-i-1, hold=True)
    vector.removeMark(algviz.cGray)
    viz.display()

bubble_sort([5, 4, -2, 1, -1, 3])

The rendered animation looks like this:

bubble_sort_animation

Examples

Ready to see the magic? Click this button to try more algorithms on Gitpod!

Open algviz examples in Gitpod

Installation

Please follow this installation guide to setup algviz.

Tutorial

This tutorial gives you a quick start on using algviz.

All the API references can be found at readthedocs.

License

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

Contribution

Any form of contribution is welcomed! Please feel free to report a bug or create a pull request.

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.2.2.tar.gz (51.3 kB view hashes)

Uploaded Source

Built Distribution

algviz-0.2.2-py3-none-any.whl (56.4 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