Graph Representation
A graph is vertices plus edges. An adjacency list spends memory on the edges that exist. An adjacency matrix spends a cell on every possible pair.
Costs
| Category | Data Structure |
| Difficulty | Medium |
| Adjacency list memory | O(V + E) |
| Adjacency matrix memory | O(V²) |
| Choose a list when | the graph is sparse |
Questions
What is Graph Representation?
A graph is vertices plus edges. An adjacency list spends memory on the edges that exist. An adjacency matrix spends a cell on every possible pair.
Where do I practice it?
DSA Master keeps challenges and progress on the phone. This page is the idea and the costs.