โ† DSA II

Graph traversal lab

Graph Explorer

See exactly why a queue, stack, or call stack produces a different order.

0/7 visited 1 component โšก 0 XP
Traversal
Graph source
Labels are case-sensitive. All components are traced.
Live graph state

Breadth-first search

Current Frontier Visited
Graph traversal visualization7 nodes and 6 edges. Current node is none.A: waiting in the frontierAC1B: unseenBC: unseenCD: unseenDE: unseenEF: unseenFG: unseenG
  • A: waiting in the frontier
  • B: unseen
  • C: unseen
  • D: unseen
  • E: unseen
  • F: unseen
  • G: unseen
Traversal-tree edge Edges can be followed both ways
1 / 41
Queuefront โ†’
  1. A
Stackโ† top
  1. empty
Call stackโ† active frame
  1. empty
Cross-language mapping

Same state change, different syntax

The highlighted line follows the current semantic operation across all four languages.

1queue = deque([start]); seen = {start}
2node = queue.popleft()
3order.append(node)
4for neighbor in sorted(graph[node]):
5 if neighbor not in seen: seen.add(neighbor); queue.append(neighbor)
6# repeat until this component is exhausted
7return order