Skip to content

Commit 7b9b63d

Browse files
committed
Initial commit: Algorithm Visualizer with pathfinding and sorting algorithms
0 parents  commit 7b9b63d

33 files changed

Lines changed: 11095 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
8+
jobs:
9+
validate:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
14+
with:
15+
node-version: 20
16+
cache: npm
17+
- run: npm ci
18+
- run: npm run lint
19+
- run: npm run typecheck
20+
- run: npm test
21+
- run: npm run build

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/node_modules
2+
/.next
3+
/out
4+
/coverage
5+
*.log
6+
.env*
7+
!.env.example
8+
.DS_Store
9+
*.tsbuildinfo

README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Traverse — Algorithm Visualizer
2+
3+
An interactive, static visualizer for graph traversal and sorting algorithms. Draw a board, add weighted terrain, generate a maze, and inspect each decision with full playback controls.
4+
5+
The live demo and demo GIF will be added after the repository is connected to Vercel.
6+
7+
## Features
8+
9+
- BFS, DFS, Dijkstra, and A* pathfinding on a 50 × 25 grid
10+
- Click-and-drag walls, Shift-drag weighted cells, and draggable endpoints
11+
- Keyboard grid controls with arrow navigation and wall, weight, start, and target shortcuts
12+
- Randomized depth-first maze generation
13+
- Bubble, insertion, selection, merge, and quick sort
14+
- Play, pause, single-step, scrub, reset, and steps-per-second controls
15+
- Pure algorithm engines with no React or DOM dependencies
16+
17+
## Architecture
18+
19+
Every algorithm accepts plain data and returns a flat list of animation steps. The UI is only a player for that list. This keeps the engines deterministic and unit-testable, and makes timeline controls simple.
20+
21+
The pathfinding grid renders once and stores cell elements in a ref map. During playback, only changed classes are updated inside a `requestAnimationFrame` loop. Sorting uses ordinary React state because its arrays are much smaller.
22+
23+
## Complexity
24+
25+
| Algorithm | Time | Notes |
26+
| --- | --- | --- |
27+
| BFS | O(V + E) | Shortest path on unweighted grids |
28+
| DFS | O(V + E) | Does not guarantee a shortest path |
29+
| Dijkstra | O((V + E) log V) | Optimal with non-negative weights |
30+
| A* | O((V + E) log V) worst case | Manhattan-distance heuristic |
31+
| Bubble sort | O(n²) | In-place, stable |
32+
| Insertion sort | O(n²) | Adaptive on nearly sorted input |
33+
| Selection sort | O(n²) | Minimizes swaps |
34+
| Merge sort | O(n log n) | Stable, O(n) auxiliary space |
35+
| Quick sort | O(n log n) average | O(n²) worst case |
36+
37+
## Run locally
38+
39+
```bash
40+
npm install
41+
npm run dev
42+
```
43+
44+
Open [http://localhost:3000](http://localhost:3000).
45+
46+
```bash
47+
npm run lint
48+
npm run typecheck
49+
npm test
50+
npm run build
51+
```
52+
53+
## Deploy
54+
55+
Import the repository into [Vercel](https://vercel.com/new). No environment variables, backend, or database are required.
56+
57+
After deployment:
58+
59+
1. Add the Vercel project URL near the top of this README.
60+
2. Record a short pathfinding-to-sorting demo as `docs/demo.gif`.
61+
3. Link the GIF to the live deployment.
62+
63+
## Stack
64+
65+
Next.js 15 App Router · React 19 · TypeScript · Tailwind CSS v4 · Vitest

eslint.config.mjs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { dirname } from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
import { FlatCompat } from "@eslint/eslintrc";
4+
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
7+
const compat = new FlatCompat({ baseDirectory: __dirname });
8+
const config = [
9+
{ ignores: [".next/**", "node_modules/**", "coverage/**", "next-env.d.ts"] },
10+
...compat.extends("next/core-web-vitals", "next/typescript"),
11+
];
12+
13+
export default config;

next-env.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
/// <reference path="./.next/types/routes.d.ts" />
4+
5+
// NOTE: This file should not be edited
6+
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

0 commit comments

Comments
 (0)