Skip to main content

The ultimate Python toolkit for animating Data Structures and Algorithms.

Project description

๐ŸŽจ vizods

Visualize Data Structures & Algorithms with Python

PyPI Version Python Version License: MIT Downloads GitHub Stars GitHub Issues Last Commit Repo Size Code Style

Transform abstract algorithms into stunning animated visualizations with a single line of code.

Installation โ€ข Quick Start โ€ข Documentation โ€ข Examples โ€ข Contributing


๐ŸŒŸ Overview

vizods is a powerful, intuitive Python library designed to bridge the gap between abstract code and visual understanding. Whether you're a student learning algorithms, an educator preparing materials, or a developer explaining concepts, vizods turns your data structures and algorithms into beautiful MP4 animations and PNG snapshots automatically.

๐Ÿ’ก "A picture is worth a thousand lines of code."


โœจ Key Features

Feature Description
๐ŸŽฌ Auto Animation Generate .mp4 videos of algorithm execution step-by-step
๐Ÿ“ธ Snapshot Export Save final or intermediate states as .png images
๐ŸŒณ Tree Visualization Hierarchical layouts for Binary Search Trees
๐Ÿ“Š Sorting Animations Bar chart visualizations with color-coded states
๐Ÿ—บ๏ธ Graph Pathfinding Step-by-step Dijkstra's algorithm tracing with weights
๐Ÿ”— Linked Lists Pointer-based node visualization
๐ŸŽจ Color-Coded States Universal color scheme for clarity
โšก Zero Configuration Works out of the box โ€” just pip install and run

๐Ÿ“ฆ Installation

Install vizods directly from PyPI:

pip install vizods

Prerequisites

  • Python: 3.8 or higher
  • FFmpeg: Required for .mp4 rendering

Installing FFmpeg

๐ŸชŸ Windows
# Using Chocolatey
choco install ffmpeg

# Or download from https://ffmpeg.org/download.html
๐ŸŽ macOS
brew install ffmpeg
๐Ÿง Linux (Ubuntu/Debian)
sudo apt update && sudo apt install ffmpeg

Dependencies

vizods automatically installs:

  • matplotlib >= 3.5.0
  • imageio >= 2.20.0
  • imageio-ffmpeg >= 0.4.7
  • networkx >= 2.8.0
  • numpy >= 1.21.0

๐Ÿš€ Quick Start

from vizods.bubble_sort import BubbleSort

# Create and visualize a sorting animation in 3 lines
sorter = BubbleSort([64, 25, 12, 22, 11])
sorter.sort()
sorter.save_video("my_first_animation.mp4")

That's it! ๐ŸŽ‰ You now have a fully animated MP4 visualization.


๐Ÿ“š Supported Modules

Category Module Class Visual Style
Sorting bubble_sort BubbleSort ๐Ÿ“Š Bar Chart
insertion_sort InsertionSort ๐Ÿ“Š Bar Chart
selection_sort SelectionSort ๐Ÿ“Š Bar Chart
merge_sort MergeSort ๐Ÿ“Š Bar Chart
quick_sort QuickSort ๐Ÿ“Š Bar Chart
Data Structures linked_list LinkedList ๐Ÿ”— Nodes & Pointers
bst BST ๐ŸŒณ Hierarchical Tree
stack Stack ๐Ÿ“š Vertical Bar Stack
queue Queue โžก๏ธ Horizontal Bar Queue
Graph Algorithms dijkstra Dijkstra ๐Ÿ—บ๏ธ Weighted Graph

๐ŸŽฏ Examples

1๏ธโƒฃ Sorting Algorithms

Bubble Sort

from vizods.bubble_sort import BubbleSort

data = [64, 34, 25, 12, 22, 11, 90]
sorter = BubbleSort(data)
sorter.sort(visualize=True)
sorter.save_video("bubble_sort.mp4", fps=5)
sorter.save_snapshot("bubble_final.png")

Quick Sort

from vizods.quick_sort import QuickSort

sorter = QuickSort([10, 80, 30, 90, 40, 50, 70])
sorter.sort()
sorter.save_video("quick_sort.mp4", fps=5)

Merge Sort

from vizods.merge_sort import MergeSort

sorter = MergeSort([38, 27, 43, 3, 9, 82, 10])
sorter.sort()
sorter.save_video("merge_sort.mp4", fps=3)

Insertion Sort

from vizods.insertion_sort import InsertionSort

sorter = InsertionSort([5, 2, 4, 6, 1, 3])
sorter.sort()
sorter.save_video("insertion_sort.mp4", fps=4)

Selection Sort

from vizods.selection_sort import SelectionSort

sorter = SelectionSort([29, 10, 14, 37, 13])
sorter.sort()
sorter.save_video("selection_sort.mp4", fps=3)

2๏ธโƒฃ Binary Search Tree (BST)

from vizods.bst import BST

tree = BST()

# Insert nodes
for value in [50, 30, 70, 20, 40, 60, 80]:
    tree.insert(value)

# Search a value
tree.search(40)

# Delete a leaf node
tree.delete(20)

# Save outputs
tree.save_video("tree_operations.mp4", fps=1)
tree.save_snapshot("final_tree.png")

3๏ธโƒฃ Linked List

from vizods.linked_list import LinkedList

ll = LinkedList()

# Add nodes
for value in [10, 20, 30, 40, 50]:
    ll.add_node(value)

# Delete a node
ll.delete_node(30)

# Save animation
ll.save_video("linked_list.mp4", fps=2)

4๏ธโƒฃ Dijkstra's Shortest Path

from vizods.dijkstra import Dijkstra

graph = Dijkstra()

# Build a weighted graph
edges = [
    ('A', 'B', 4), ('A', 'C', 2),
    ('B', 'C', 1), ('B', 'D', 5),
    ('C', 'D', 8), ('C', 'E', 10),
    ('D', 'E', 2)
]
for u, v, w in edges:
    graph.add_edge(u, v, w)

# Visualize shortest path
graph.visualize_search(start_node='A', target_node='E')
graph.save_video("dijkstra_path.mp4", fps=1)

5๏ธโƒฃ Stack (LIFO)

from vizods.stack import Stack

stack = Stack()

# Push elements
for value in [10, 20, 30, 40, 50]:
    stack.push(value)

# Peek and pop
stack.peek()
stack.pop()
stack.pop()

# Save outputs
stack.save_video("stack_demo.mp4", fps=2)
stack.save_snapshot("stack_final.png")

6๏ธโƒฃ Queue (FIFO)

from vizods.queue import Queue

queue = Queue()

# Enqueue elements
for value in [10, 20, 30, 40, 50]:
    queue.enqueue(value)

# Inspect front and rear
queue.front()
queue.rear()

# Dequeue elements
queue.dequeue()
queue.dequeue()

# Save outputs
queue.save_video("queue_demo.mp4", fps=2)
queue.save_snapshot("queue_final.png")

๐ŸŽจ Visualization Color Standards

vizods uses a consistent color language across all visualizations:

Color Meaning
๐ŸŸข Green Sorted / Visited / Completed
๐ŸŸ  Orange Active / Currently Processing
๐Ÿ”ด Red Critical / Deleting / Shortest Path
๐Ÿ”ต Skyblue Standard / Unprocessed
๐ŸŸฃ Purple Pivot (Quick Sort)
โšช Lightgray Inactive / Waiting

๐Ÿ“– API Documentation

๐Ÿ”น Sorting Classes (BubbleSort, QuickSort, MergeSort, InsertionSort, SelectionSort)

Method Parameters Description
__init__(data) data: list Initialize with a list of numbers
sort(visualize=True) visualize: bool Run sort & capture frames
save_video(output_name, fps) output_name: str, fps: int Export animation as MP4
save_snapshot(filename) filename: str Save final state as PNG

๐Ÿ”น BST (Binary Search Tree)

Method Description
insert(value) Insert a new node into the tree
search(value) Search for a value, animating the traversal
delete(value) Delete a leaf node (leaf-only support)
save_video(output_name, fps) Export full operations as MP4
save_snapshot(filename) Save current tree state as PNG

๐Ÿ”น LinkedList

Method Description
add_node(value) Append a node to the list
delete_node(value) Remove a specific node
save_video(output_name, fps) Export operations animation as MP4

๐Ÿ”น Dijkstra

Method Description
add_edge(u, v, weight) Add a weighted edge
visualize_search(start_node, target_node) Run & animate Dijkstra's algorithm
save_video(output_name, fps) Export pathfinding animation as MP4

๐ŸŽ“ Use Cases

  • ๐Ÿซ Education: Teach algorithms in classrooms with engaging visuals
  • ๐Ÿ“น Content Creation: Produce YouTube tutorials and online courses
  • ๐Ÿ“ Documentation: Embed animations in blogs, articles, and books
  • ๐ŸŽค Presentations: Make technical talks more interactive
  • ๐Ÿงช Debugging: Visually inspect algorithm behavior

๐Ÿ› ๏ธ Project Structure

vizods/
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ .workflows/
โ”‚       โ””โ”€โ”€ pypi.yml
โ”œโ”€โ”€ output/ # Samples
โ”‚   โ”œโ”€โ”€ bst_animation.mp4
โ”‚   โ”œโ”€โ”€ bst_snapshot.png
โ”‚   โ”œโ”€โ”€ bubble_sort_snapshot.png
โ”‚   โ”œโ”€โ”€ bubble_sort.mp4
โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ”œโ”€โ”€ ...
โ”‚   โ””โ”€โ”€ stack.mp4
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_all_algorithms.py
โ”œโ”€โ”€ vizods/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ bst.py
โ”‚   โ”œโ”€โ”€ bubble_sort.py
โ”‚   โ”œโ”€โ”€ dijkstra.py
โ”‚   โ”œโ”€โ”€ insertion_sort.py
โ”‚   โ”œโ”€โ”€ linked_list.py
โ”‚   โ”œโ”€โ”€ merge_sort.py
โ”‚   โ”œโ”€โ”€ queue.py
โ”‚   โ”œโ”€โ”€ quick_sort.py q
โ”‚   โ”œโ”€โ”€ selection_sort.py
โ”‚   โ””โ”€โ”€ stack.py
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ setup.py

๐Ÿค Contributing

Contributions make the open-source community such an amazing place to learn and grow. Any contributions are greatly appreciated!

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please make sure to update tests as appropriate and follow the PEP 8 style guide.


๐Ÿ› Reporting Bugs

Found a bug? Please open an issue with:

  • A clear description
  • Steps to reproduce
  • Expected vs actual behavior
  • Your environment (OS, Python version)

๐Ÿ“œ License

Distributed under the MIT License. See LICENSE for more information.


๐Ÿ‘จโ€๐Ÿ’ป Author

Abdelrahman Ali (@Mordekai66)

๐Ÿ“ง abdelrahman.ali.dev@gmail.com


๐ŸŒŸ Show Your Support

If you find vizods helpful:

  • โญ Star this repository
  • ๐Ÿด Fork it for your projects
  • ๐Ÿ“ข Share it with fellow developers
  • ๐Ÿ’ฌ Tweet about it

๐Ÿ™ Acknowledgements

  • Matplotlib โ€” for plotting
  • NetworkX โ€” for graph structures
  • ImageIO โ€” for video encoding
  • All contributors and users of this library โค๏ธ

Developed with โค๏ธ by Mordekai66

If this project helped you, consider giving it a โญ on GitHub!

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

vizods-2.2.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

vizods-2.2.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file vizods-2.2.0.tar.gz.

File metadata

  • Download URL: vizods-2.2.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vizods-2.2.0.tar.gz
Algorithm Hash digest
SHA256 8fdfc94644a9b31a80f618f8377a0497d07672523039b0710a6659cdfb8bc6bb
MD5 d8ca7583e0669d4bc1d2ff6d6e0ab51e
BLAKE2b-256 fac77682168cd89d91e30b17aca0c53e986759cdeaaf94192d487b83ecb6b27e

See more details on using hashes here.

File details

Details for the file vizods-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: vizods-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vizods-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3cbeb4f45b317696d194167ac8fc772480232da81e7b07ba804fa498b141a60d
MD5 422bfa44402e618f214b731ea5e9fa2a
BLAKE2b-256 e9a06c05e2d932d5d52e05cfafcf7f8ae89f2d763c77bd15770f39a32a20cd54

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