Code tool

Graph Traversal Visualizer

Define nodes and edges, choose BFS or DFS and a start node, then inspect the exact visit order.

In-browser processingNo account requiredPrivacy details ↗

Define a graph and create a trace.

A QUICK WALKTHROUGH

How to use this tool

  1. Enter up to 24 unique node labels and 80 edges.
  2. Choose directed or undirected edges, BFS or iterative DFS, and a start node.
  3. Create the trace and use the controls to inspect visited nodes and the queue or stack.

Implemented BFS and DFS

BFS marks a node when it enters the queue. Iterative DFS marks a node when it enters the stack; stale duplicate stack entries are not created. Traversal stops after the start node’s reachable component.

Deterministic visit order

Neighbors follow node declaration order, then first appearance in the edge list. BFS uses a queue. Iterative DFS pushes neighbors in reverse so the first declared neighbor is visited first.

Bounded local graph

Labels use letters, digits, underscores, or hyphens and are limited to 20 characters. The graph and trace remain in this page.

GOOD TO KNOW

Common questions

Does this find a shortest path?

No. It shows traversal order from one start node; BFS parent links are not presented as a path result.

Are edges directed?

You can choose an undirected graph or a directed graph. Duplicate edges are collapsed.