The ultimate Python toolkit for animating Data Structures and Algorithms.
Project description
๐จ vizods
Visualize Data Structures & Algorithms with Python
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 |
| ๐ Search Animations | Dynamic highlighting of search ranges and target matching |
| ๐บ๏ธ 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
.mp4rendering
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.0imageio >= 2.20.0imageio-ffmpeg >= 0.4.7networkx >= 2.8.0numpy >= 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 |
|---|---|---|---|
| Searching | linear_search |
LinearSearch |
๐ Highlighted Bars |
binary_search |
BinarySearch |
๐ Range Reduction | |
| 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๏ธโฃ Searching Algorithms
Linear Search
from vizods.linear_search import LinearSearch
data = [10, 50, 30, 70, 80, 60, 20, 90, 40]
ls = LinearSearch(data)
ls.search(70)
ls.save_video("linear_search.mp4", fps=2)
Binary Search
from vizods.binary_search import BinarySearch
# Binary search requires a sorted array
data = [10, 20, 30, 40, 50, 60, 70, 80, 90]
bs = BinarySearch(data)
bs.search(70)
bs.save_video("binary_search.mp4", fps=2)
2๏ธโฃ 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)
Insertion Sort
from vizods.insertion_sort import InsertionSort
sorter = InsertionSort([12, 11, 13, 5, 6])
sorter.sort()
sorter.save_video("insertion_sort.mp4", fps=4)
Selection Sort
from vizods.selection_sort import SelectionSort
sorter = SelectionSort([64, 25, 12, 22, 11])
sorter.sort()
sorter.save_video("selection_sort.mp4", fps=3)
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)
Quick Sort
from vizods.quick_sort import QuickSort
sorter = QuickSort([10, 7, 8, 9, 1, 5])
sorter.sort()
sorter.save_video("quick_sort.mp4", fps=5)
3๏ธโฃ Data Structures
Linked List
from vizods.linked_list import LinkedList
ll = LinkedList()
for value in [10, 20, 30, 40, 50]:
ll.add_node(value)
ll.delete_node(30)
ll.save_video("linked_list.mp4", fps=2)
Binary Search Tree (BST)
from vizods.bst import BST
tree = BST()
for value in [50, 30, 70, 20, 40, 60, 80]:
tree.insert(value)
tree.search(40)
tree.delete(20)
tree.save_video("bst_animation.mp4", fps=1)
Stack (LIFO)
from vizods.stack import Stack
stack = Stack()
for value in [10, 20, 30]:
stack.push(value)
stack.pop()
stack.save_video("stack.mp4", fps=2)
Queue (FIFO)
from vizods.queue import Queue
queue = Queue()
for value in [10, 20, 30]:
queue.enqueue(value)
queue.dequeue()
queue.save_video("queue.mp4", fps=2)
4๏ธโฃ Graph Algorithms
Dijkstra's Shortest Path
from vizods.dijkstra import Dijkstra
graph = Dijkstra()
edges = [
('A', 'B', 4), ('A', 'C', 2),
('B', 'C', 1), ('B', 'D', 5),
('C', 'D', 8), ('D', 'E', 2)
]
for u, v, w in edges:
graph.add_edge(u, v, w)
graph.visualize_search(start_node='A', target_node='E')
graph.save_video("dijkstra_path.mp4", fps=1)
๐จ 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
๐น Searching Classes (LinearSearch, BinarySearch)
| Method | Parameters | Description |
|---|---|---|
__init__(data) |
data: list |
Initialize with a list of numbers |
search(target) |
target: int/float |
Start the search process and capture frames |
save_video(output_name, fps) |
output_name: str, fps: int |
Export search animation as MP4 |
๐น 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 the sorting algorithm & capture frames |
save_video(output_name, fps) |
output_name: str, fps: int |
Export sorting animation as MP4 |
save_snapshot(filename) |
filename: str |
Save the final sorted state as PNG |
๐น Stack (LIFO - Last In First Out)
| Method | Parameters | Description |
|---|---|---|
push(value) |
value |
Add an element to the top of the stack |
pop() |
- | Remove and return the top element |
peek() |
- | View the top element without removing it |
is_empty() |
- | Check if the stack is empty |
save_video(output_name, fps) |
output_name: str, fps: int |
Export stack operations as MP4 |
save_snapshot(filename) |
filename: str |
Save a snapshot of the current stack state |
๐น Queue (FIFO - First In First Out)
| Method | Parameters | Description |
|---|---|---|
enqueue(value) |
value |
Add an element to the end of the queue |
dequeue() |
- | Remove and return the front element |
front() |
- | View the first element in the queue |
rear() |
- | View the last element in the queue |
save_video(output_name, fps) |
output_name: str, fps: int |
Export queue operations as MP4 |
save_snapshot(filename) |
filename: str |
Save a snapshot of the current queue state |
๐น BST (Binary Search Tree)
| Method | Description |
|---|---|
insert(value) |
Insert a new node into the tree |
search(value) |
Search for a value, animating the traversal path |
delete(value) |
Delete a node (currently supports leaf nodes) |
save_video(output_name, fps) |
Export full tree operations as MP4 |
save_snapshot(filename) |
Save the current tree structure as PNG |
๐น LinkedList
| Method | Description |
|---|---|
add_node(value) |
Append a new node to the end of the list |
delete_node(value) |
Remove a specific node from the list |
save_video(output_name, fps) |
Export pointer/node operations as MP4 |
๐น Dijkstra
| Method | Parameters | Description |
|---|---|---|
add_edge(u, v, weight) |
u, v: nodes, weight: int |
Add a weighted edge between two nodes |
visualize_search(start, target) |
start, target: nodes |
Run and animate the shortest pathfinding process |
save_video(output_name, fps) |
output_name: str, fps: int |
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
โ โโโ binary_search.py
โ โโโ bst.py
โ โโโ bubble_sort.py
โ โโโ dijkstra.py
โ โโโ insertion_sort.py
โ โโโ linear_search.py
โ โโโ linked_list.py
โ โโโ merge_sort.py
โ โโโ queue.py
โ โโโ quick_sort.py
โ โโโ 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!
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vizods-2.3.0.tar.gz.
File metadata
- Download URL: vizods-2.3.0.tar.gz
- Upload date:
- Size: 23.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f446bdc5fab5a935c77885ae00a2fc8d43692fcc30798cffa868a15dc630840e
|
|
| MD5 |
6421faf8dc7f523f24f6a8b21e51e4cd
|
|
| BLAKE2b-256 |
7749ffca905caf9b43492ebf1dedf30b9f0619c092ceee378df7d6d7ab0250a4
|
File details
Details for the file vizods-2.3.0-py3-none-any.whl.
File metadata
- Download URL: vizods-2.3.0-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08c972c29ae8ce14e2e2aedcafaafcd18fdea75187839ea2d81e235424e21953
|
|
| MD5 |
74349c1461f8655eb4b567fd0662efdc
|
|
| BLAKE2b-256 |
913c5bdc32d41c30a1e3b21c59afee4c87404071eb9ee957067931efd77847be
|