#98

Graph Algorithms Visualizer

Click canvas to add nodes · Click nodes to draw edges · Right-click to delete
VISUALIZE
ALGORITHMS
CHALLENGES
INTERVIEW
Mode: Add Node

Load Example

Algorithm

Algorithm State

Queue
Visited

Current Step

Select an algorithm and press Play — or Step through one move at a time.

Legend

Unvisited
In Queue / Stack
Currently Processing
Visited / Finalized
Path / Cycle
MST Edge

Adjacency List vs Adjacency Matrix

Adjacency List

graph = {
  0: [1, 2],
  1: [0, 3],
  2: [0, 3],
  3: [1, 2, 4],
  4: [3]
}

Space: O(V + E)
Add edge: O(1)
Check edge: O(degree)
Iterate neighbors: O(degree)

✅ Best for sparse graphs
✅ BFS, DFS, Dijkstra

Adjacency Matrix

mat = [
  [0,1,1,0,0],
  [1,0,0,1,0],
  [1,0,0,1,0],
  [0,1,1,0,1],
  [0,0,0,1,0]
]

Space: O(V²)
Add edge: O(1)
Check edge: O(1) ⚡
Iterate neighbors: O(V)

✅ Best for dense graphs
✅ Floyd-Warshall

Algorithm Selection Challenges

Score
0 / 15

FAANG Graph Interview Q&As

Click a card to reveal answer