How to use the visualizer
Draw a graph
- The controls have two tabs — Build and Run. Build is where you draw; the graph you make is kept when you switch to Run and back, so one graph can be tried with several algorithms.
- In Add/Move Vertices mode, click empty canvas to add a node (labelled A–Z), drag a node to reposition it, and click a node or edge to select it — the panel then lets you edit an edge's weight or remove what you selected (Delete works too).
- In Connect Vertices mode, click one node then another to join them. Every edge starts at weight 1.
- To change a weight, click the number on the line and type the new one — it is already selected, so a digit replaces it. Enter or a click elsewhere keeps it; Escape leaves it as it was. This works in either mode, so a new edge can be given its real weight straight after you draw it. The panel's Weight box does the same thing for a selected edge.
- Undirected / Directed switches how edges are read, and Load a course example drops in the graphs from the Dijkstra and MST pages.
- The adjacency matrix and adjacency list below the canvas always show the graph you have drawn.
Run an algorithm
- On the Run tab, pick BFS, DFS, Dijkstra, Prim, or Kruskal and a start node, then press Run. (Kruskal's walks the whole sorted edge list, so it needs no start node.) The canvas becomes read-only and colours each vertex — current, in the frontier/queue, and finished — while the playback controls step, scrub, and replay at your own speed.
- BFS shows its queue, DFS shows its call stack, and Dijkstra shows the course's distance / previous / known table plus the priority queue. The matrix and list highlight the edge being examined at each step.
- When Dijkstra finishes, pick a destination under the table and it walks the Previous Vertex column back to the start node to show that shortest path.
- Prim's shows its MinHeap of (vertex, parent, weight to parent): every vertex starts in it, the root at 0 and the rest at ∞, and an entry is rewritten whenever the tree finds a cheaper way in. Kruskal's shows every edge in weight order and the disjoint sets that decide which ones would close a cycle, and stops as soon as T holds one edge fewer than the number of vertices. Both end on the same tree.
- Dijkstra assumes non-negative weights, and a minimum spanning tree needs an undirected graph; in either case the app explains why it will not run rather than leaving you with a dead button.
- A negative weight is allowed on purpose — an MST is well defined for any weights, and BFS and DFS ignore weight altogether, so Prim's, Kruskal's, BFS and DFS all run on one. Only Dijkstra refuses, and a note under the canvas says so as soon as you type it. Zero is fine everywhere: the assumption is non-negative, not positive.
- Stop and edit returns to build mode with your graph intact.
- Your graphs never leave the browser — see About & privacy.
The course notes behind this
The Graphs chapter, in the order the course teaches it. BFS and DFS are run here but have no page of their own in this chapter — for those, work from the queue and call-stack panels.
- Introduction to graphs — a graph as a set of vertices and the edges connecting them, directed or not, and what they get used for.
- Definitions — adjacency, weights, paths, cycles, and connectivity — the vocabulary the readouts here use without redefining it.
- Representation — adjacency matrix versus adjacency list, and which suits a dense or a sparse graph. Both are on screen beside the canvas.
- Dijkstra's algorithm — the distance / previous / known table, filled in one vertex at a time. The app reproduces that table column for column.
- Minimum spanning tree — Prim's and Kruskal's, and why each stops where it does — loadable here as the chapter's worked graphs.