Graph Representation - Adjacency List
Learn Graph Representation - Adjacency List (Graphs, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Representing a Graph as a List of Neighbors Per Vertex Each vertex maps to a LIST of its neighbors - space is O(V + E), proportional to what's actually in the graph, not V². This is the default choice for most graph algorithms (BFS, DFS, Dijkstra) since it directly hands you "iterate over this vertex's neighbors" in optimal time.
More lessons in Graphs
- Graph Representation - Adjacency Matrix
- Directed Graph
- Undirected Graph
- Weighted Graph
- BFS
- DFS
- Connected Components
- Cycle Detection
- Bipartite Graph
- Topological Sort
- Kahn's Algorithm
- DFS Topological Sort
- Shortest Path - BFS
- Shortest Path - Dijkstra
- Shortest Path - Bellman-Ford
- Shortest Path - Floyd-Warshall
- Minimum Spanning Tree - Prim's
- Minimum Spanning Tree - Kruskal's
- Disjoint Set Union - DSU
- Union-Find
- Strongly Connected Components - Kosaraju
- Strongly Connected Components - Tarjan
- Bridges
- Articulation Points
- Euler Path / Circuit
- Hamiltonian Path / Cycle
- Graph Coloring
- Network Flow
- Maximum Flow
- Bipartite Matching