Graph Visualizer
Graph Traversal
Trace BFS, DFS, and Dijkstra across a weighted directed graph with frontier, visited, settled, and distance state.
O(V + E)
Step Note
Start BFS with the chosen node in the queue.
function bfs(graph: Graph, start: Node) {
const queue = [start]
while (queue.length > 0) {
const node = queue.shift()
visit(node)
for (const neighbor of graph.neighbors(node)) {
queue.push(neighbor)
}
}
}