QiLing Tools

🪢Graph Algorithm Visualizer - Shortest Path, MST, Max Flow

Click the canvas to add vertices, drag from one vertex to another to add an edge, click an edge to change its weight, and switch between directed and undirected graphs — or paste an edge list (“from to weight” per line) and let the tool lay it out. Pick an algorithm and press Run to watch it step by step: the current vertex, finished vertices, vertices waiting in the queue, chosen edges and rejected edges each get their own colour, every step is explained in words, and you can play, change speed or step back and forth. It covers breadth-first and depth-first search (with discovery/finish times), Dijkstra’s shortest paths, Bellman-Ford with negative weights and negative-cycle detection, Floyd–Warshall with the distance matrix after each intermediate vertex, Prim’s and Kruskal’s minimum spanning trees, Kahn’s topological sort (showing the actual cycle when there is one), connected components and Tarjan’s strongly connected components, a bipartite check that shows an odd cycle when it fails, Euler paths and circuits with Hierholzer’s algorithm, and Edmonds–Karp maximum flow with the minimum cut highlighted. The adjacency matrix updates as you edit, and the drawing exports as PNG or SVG.

Free · No sign-up · Runs in your browserLast updated:

Loading tool...

How to use Graph Theory Algorithm Visualizer

  1. 1Click to add vertices and drag to connect them, paste an edge list, or load an example graph
  2. 2Choose an algorithm and a start vertex (plus a sink for max flow), then press Run
  3. 3Play or step through the animation, read the result table and export PNG/SVG if needed

FAQ

Should I use Dijkstra or Bellman-Ford?
With non-negative weights use Dijkstra: it repeatedly settles the closest unsettled vertex and is fast. With negative edges Dijkstra can give wrong answers, so use Bellman-Ford, which relaxes every edge n − 1 times; if an n-th pass still shortens a path, there is a negative cycle. Note that in an undirected graph a single negative edge is already a negative cycle.
Do Prim’s and Kruskal’s algorithms give the same tree?
They always give the same total weight, but when several edges share a weight they may pick different edges, because a minimum spanning tree need not be unique. Kruskal sorts the edges and adds each one that doesn’t close a cycle; Prim grows a tree from one vertex by always adding the cheapest edge leaving it. On a disconnected graph you get a minimum spanning forest.
How can I tell if a graph has an Euler path?
An undirected graph has an Euler path when all vertices with edges are connected and the number of odd-degree vertices is 0 or 2. With 0 there is an Euler circuit that returns to the start; with 2 the path must start at one odd vertex and end at the other. A directed graph needs in-degree equal to out-degree everywhere, or exactly one vertex with one extra outgoing edge and one with one extra incoming edge. The tool checks these conditions and then builds the route with Hierholzer’s algorithm.
How are maximum flow and minimum cut related?
By the max-flow min-cut theorem, the largest flow from source to sink equals the smallest capacity of any cut separating them. Edmonds–Karp repeatedly finds the shortest augmenting path with BFS and pushes its bottleneck until no path remains. The vertices still reachable from the source in the residual network form the set S, and the edges leaving S form the minimum cut — all of them saturated.