#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
⚡ FREE · STEP BY STEP

BFS & DFS Visualizer: Watch Graph Traversal One Node at a Time

Type the edges of a graph and step through BFS or DFS with the queue or stack shown.

  • 🌊 BFS with its queue
  • 🧗 DFS with its stack
  • ➡️ Directed or undirected

How to use the Graph BFS DFS Visualizer

  1. 1. Type the edgesOne per line, like A-B. Tick directed if A-B means A → B.
  2. 2. Pick BFS or DFSAnd the node to start from.
  3. 3. Step throughSee the current node, visited nodes and the queue or stack.

BFS vs DFS

  • Breadth-first search uses a queue. It visits the start node, then all its neighbours, then their neighbours, level by level. On an unweighted graph it finds the path with the fewest edges, so it's used for shortest paths, social network "degrees of separation" and web crawlers.
  • Depth-first search uses a stack (or recursion). It goes as deep as it can along one branch before backing up. It's used for cycle detection, topological sort, finding connected components and solving mazes.

Both run in O(V + E) time. Neighbours are taken in alphabetical or numeric order, the usual textbook convention, so your answer matches the one in the book. In the drawing, the current node is orange, discovered nodes are yellow and finished ones are green, each labelled with its visit number.

Worked example

The sample graph has edges A-B, A-C, B-D, B-E, C-F and E-F. From A:

  • BFS: A → B → C → D → E → F. A's neighbours B and C go in the queue; then B adds D and E; then C adds F. Distances in edges from A: B and C are 1, D, E and F are 2.
  • DFS: A → B → D → E → F → C. From B it dives to D, backs up, goes to E, then F, and only then reaches C through F.

Tick Directed graph and the same edges become one-way, so some nodes may become unreachable; the summary lists any the search couldn't reach. The adjacency list is shown too, which helps when you're turning a drawn graph into code.

Frequently asked questions

Which DFS order does it use?

The iterative stack version that visits neighbours in sorted order, which gives the same order as the usual recursive DFS.

Can I use numbers as node names?

Yes, like 1-2. They're sorted numerically.

How big can the graph be?

Up to 26 nodes, so the circle drawing stays readable.

Is the graph bfs dfs visualizer free to use?

Yes, the graph bfs dfs visualizer is free and costs nothing. Your first traversal shows a short form for your name and WhatsApp number one time; once that's done, this tool and every other Uncodemy tool open with no form.

More free tools

See all free tools