Graph Algorithm Playground by Zach View on GitHub

Graph Explorer

Graph Generator

Customize and generate random graphs. Node colors show distance gradient (purple→pink→red) from universal first node.

Starting node for DFS, BFS, and Dijkstra trees.

0
Undirected Directed
3
Sparse Dense
5
Acyclic Cyclic

Graphs are generated randomly. For best performance, use under ~1000 nodes.

No graph loaded. Drag to pan, scroll to zoom.

DFS Tree

Run DFS from a starting node. Produces a tree of all reachable nodes with parent and descendant relationships.

Tiebreaker: When multiple unvisited neighbors exist, explores in reverse order of connections (last connection first).

BFS Tree

Run BFS from a starting node. Produces a tree showing distance from first node.

Tiebreaker: When multiple unvisited neighbors exist, explores in order of connections (first connection first).

Dijkstra Tree

Run Dijkstra from a starting node. Produces a shortest-path tree showing distances (cost) from source.

Tiebreaker: When multiple nodes have the same distance, processes in order of connections (first connection first).

Shortest Path

Select two nodes and run an algorithm to find the shortest path between them.

Topological Sort

Linear ordering of vertices such that for every directed edge (u, v), u comes before v. Non-unique, there may be many answers—this just displays one. Use the verifier to check your answers.

Graph must be acyclical and directional to generate a topological sort!