Graph Algorithm Visualizer

Drag nodes, draw edges, run BFS, DFS and Dijkstra on your custom graph.

Start:

Drag nodes to rearrange. Yellow = frontier, Teal = visited. Edge weights shown on lines. White-outlined node = start.

What the graph visualizer shows

Drag nodes onto the canvas, draw edges between them, then run BFS, DFS, or Dijkstra on the graph you built. The animation highlights nodes in visit order and traces the path the algorithm settles on, making abstract graph theory concrete.

How graph traversal works

A graph is just nodes connected by edges — directed or undirected, weighted or not. BFS visits neighbors level by level (great for shortest paths on unweighted graphs and for "closest first" problems). DFS follows a path as far as it can before backtracking (used for cycle detection, topological sort, and connectivity). Dijkstra finds the shortest path when edges have weights, always expanding the cheapest-so-far node next.

Why it matters

Graphs model the things software actually deals with: social networks, road maps, package dependencies, state machines, and recommendation systems. Traversal is the foundation every one of those builds on. See a grid-specific application in the pathfinding visualizer, or practice on the coding challenges.

Frequently asked questions

What's the difference between a directed and undirected graph?

In an undirected graph an edge works both ways; in a directed graph it points one way (like one-way streets or "follows" on social media).

When do I use BFS vs DFS?

BFS for shortest paths and nearest-neighbor problems; DFS for exploring all paths, detecting cycles, and ordering dependencies.

What is Dijkstra's algorithm for?

Finding the shortest path in a graph whose edges have (non-negative) weights — the basis of GPS routing and network path selection.