Graph Representation
3 popular ways to implement:
- Adjacency list representation (most popular)
- Adjacency matrix representation
- Edge list representation
Adjacency List Representation
Use an array of vectors.
vector<int> adj[N];
The indices of the array represent the node number, while the actual value of the array are vectors of the other nodes that the current node is connected to.