Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Graph Representation Lab
Graphs
Concept shape
Core
Definition
Graphs are commonly represented with adjacency lists, adjacency matrices, or edge lists.
Step 1 / 5
Concept shape
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
1.0x