CSE220 · Data Structures

Graph (ADT) Simulator

Place nodes and edges, and watch the adjacency list and adjacency matrix update together.

ABCDE

Adjacency list

A→B → C
B→A → D
C→A → D
D→B → C → E
E→D

O(V + E) space — good for sparse graphs.

Adjacency matrix

ABCDE
A01100
B10010
C10010
D01101
E00010

O(V²) space regardless of edge count — but O(1) edge lookup.

Build the graph

→

Edges

  • A — B
  • A — C
  • B — D
  • C — D
  • D — E
Vertices (V)
5
Edges (E)
5
Matrix cells
25
Degrees
A:2 B:2 C:2 D:3 E:1

Both views update together. Add edges and watch the matrix stay the same size while the list grows — that is the space trade-off in one picture.