Graph (ADT) Simulator
Place nodes and edges, and watch the adjacency list and adjacency matrix update together.
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
| A | B | C | D | E | |
|---|---|---|---|---|---|
| A | 0 | 1 | 1 | 0 | 0 |
| B | 1 | 0 | 0 | 1 | 0 |
| C | 1 | 0 | 0 | 1 | 0 |
| D | 0 | 1 | 1 | 0 | 1 |
| E | 0 | 0 | 0 | 1 | 0 |
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.