Graphs

Concept shape

Core
Definition

Graphs are commonly represented with adjacency lists, adjacency matrices, or edge lists.

Step 1 / 5
Concept shape
Current lesson

Graph Representation Lab

Graphs Core

Graph Representation

Welcome to the Graph Representation concept lab. Graphs are commonly represented with adjacency lists, adjacency matrices, or edge lists. The must know points are: Adjacency lists are efficient for sparse graphs. Matrices make edge lookup O(1). Edge lists are convenient for sorting edges. The common operations are: list neighbors, check edge, iterate edges. The complexity shape is Depends on representation. Watch out for these pitfalls: Using a matrix for a huge sparse graph. Forgetting both directions in undirected graphs. Related algorithms include BFS, DFS, Kruskal MST.

Concept details

Graphs are commonly represented with adjacency lists, adjacency matrices, or edge lists.

Must know

  • Adjacency lists are efficient for sparse graphs.
  • Matrices make edge lookup O(1).
  • Edge lists are convenient for sorting edges.

Complexity

Depends on representation

Open deeper visual structure lesson
1.0x