Skip to content

Interactive B-Tree visualization with animated insertions, deletions, and node splitting. Built with C++ and Raylib.

Notifications You must be signed in to change notification settings

AakrishtSP/B-tree-visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

B-Tree Visualizer

This project implements a simple B-Tree and a Raylib-based visualizer with interactive controls.

Try it Online

Web Version (Desktop): https://aakrishtsp.github.io/B-tree-visualizer/btree-raylib.html

Note: This project was designed for desktop use and later ported to web. Mobile devices and keyboard-less interactions are not supported. For the best experience, use a desktop browser with a keyboard, or download the native application from the releases page.

Controls (keyboard & mouse)

  • A : Add a single random key (incrementing seed)
  • M : Add multiple random keys — press M, type a count, then Enter to insert that many
  • I : Insert a specific key — press I, type the number, then Enter
  • D : Delete the last-inserted key
  • H : Delete the hovered key (hover over a key then press H)
  • X : Clear all keys (reset tree)
  • Z : Fit view to show the whole tree
  • R : Reset the example scene (starts with 8 random keys)
  • ESC: Cancel typing input
  • Mouse drag (left button) : Pan the view
  • Mouse wheel or +/- : Zoom in/out

Typing behavior

  • When you press M or I the app enters typing mode; type digits (and an optional leading -), then press Enter to commit or Esc to cancel.

UI notes

  • Hover a key with the mouse to highlight it; the hover value is shown in the legend.
  • A legend is shown at the bottom-right with available controls and indicators.

Preview

Latest Version (Build 13)

B-Tree visualizer - Latest

Video Demo:

V13.mp4

📸 Old Version (Build 1) - Click to expand

B-Tree visualizer - Build 1

Build (Linux/macOS)

Run a single-line configure+build (recommended):

cmake -S . -B build && cmake --build build -- -j4

This will download Raylib via CMake's FetchContent and build the executable into build/bin.

Build (Windows - Visual Studio)

Open a "x64 Native Tools Command Prompt" (or use CMake GUI). Then:

cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Release

Build (Web - Emscripten)

Build for web browsers using WebAssembly:

./build-web.sh

Or manually with Emscripten:

emcmake cmake -S . -B build-web -DCMAKE_BUILD_TYPE=Release -DPLATFORM=Web
cmake --build build-web -j4

Then serve locally:

cd build-web/bin && python3 -m http.server 8000

See web/README.md for detailed instructions.

Prerequisites

  • CMake (>= 3.24) installed and available on PATH. Install from https://cmake.org if needed.
  • A C/C++ toolchain: GCC/Clang on Linux/macOS or Visual Studio on Windows.

Notes

  • The build uses FetchContent to download raylib automatically. If you are offline, pre-populate build/_deps or install raylib system-wide.