New Labs for BFS, DFS, and Dijkstra! π§ͺ
A few tiny graph playgrounds that let you watch each algorithm make its choices.
Hi everybody! Graph algorithms are one of those topics that can feel totally reasonable while you are reading about them, but their subtle complications often appear only when you start using them.
Letβs say that we have a graph that looks as follows and our goal is to find a path from A to F:
The type of graph algorithm you use can determine the path you find. DFS (Depth First Search) says, Letβs go as far as we can down this path. BFS (Breadth First Search) says, Letβs check everything nearby first. Dijkstra asks, Which route has the lowest total cost? We are dealing with the same graph, but their decision-making can look totally different.
Reading about these differences is useful. Watching them unfold one decision at a time is even better, so I added a pair of interactive labs:
The DFS/BFS lab starts with the same A-through-H graph from the tutorial and asks you to find a path from A to F:
You can switch between DFS and BFS, move through the search one step at a time, and watch the discovered list act like a stack in one case and a queue in the other.
The Dijkstra lab builds on the weighted-graph example from the tutorial:
You can generate a graph, customize its nodes and edges, and watch Dijkstra update its best-known distances until the cheapest path from A to F emerges.
The nice thing about these labs is that I tried my best to ensure that no detail is hidden. You can see the current node, the nodes waiting to be explored, the final path, and running notes that explain why the algorithm made each move. It is like giving the graph a tiny glass floor:
Image credit to Torsodog
Slightly unsafe (and possibly terrifying) architecturally, but very helpful educationally.
Give the labs a spin. Try the same graph with DFS and BFS, regenerate a few weighted graphs for Dijkstra, and see how quickly each algorithmβs behavior starts to feel less mysterious.
Cheers,
Kirupa π






