Graph Representations
Adjacency matrix ($O(V^2)$ space, $O(1)$ edge check) vs adjacency list ($O(V+E)$ space, fast neighbour iteration).
Easy
Use lists for sparse graphs (most real graphs); matrices for dense graphs or Floyd-Warshall.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.