Complete the code to declare an adjacency matrix for a graph with 4 nodes.
int graph[4][4] = [1];
The adjacency matrix for 4 nodes is a 4x4 matrix initialized with zeros.
Complete the code to add an edge from node 1 to node 3 in an adjacency list.
adjList[1].[1](3);
In C++, adjacency lists use vectors and edges are added with push_back.
Fix the error in the code to check if an edge exists between node 2 and node 4 in an adjacency matrix.
if (graph[2][[1]] == 1) { // edge exists }
Node indices start at 0, so node 4 is index 3 in the matrix.
Fill both blanks to create an adjacency list for a graph with 3 nodes and add an edge from node 0 to node 2.
std::vector<int> adjList[[1]]; adjList[0].[2](2);
We declare an array of vectors for 3 nodes and add an edge using push_back.
Fill all three blanks to initialize an adjacency matrix for 2 nodes and add an edge from node 0 to node 1.
int graph[[1]][[2]] = [3]; graph[0][1] = 1;
The matrix size is 2x2 for 2 nodes, initialized with zeros before adding edges.
