vector<int> adj[5] creates separate vectors. Each adj[i] holds the neighbors of node .
adj[0] is a vector that stores neighbors of node .
adj[1] is a vector that stores neighbors of node .
And so on for adj[2], adj[3], adj[4]. If Node connects to nodes and , then adj[1] = {2, 3}. To add a neighbor, use adj[u].push_back(v). To iterate through all neighbors of node , loop through adj[u]. This two-line pattern is the foundation of every graph algorithm you will write. Learn it now because you will use it hundreds of times.