Complete the code to declare an adjacency matrix for a graph with 5 vertices.
int graph[5][5] = [1];
The adjacency matrix is initialized with zeros to indicate no edges initially.
Complete the code to add an edge from vertex 2 to vertex 4 in an adjacency matrix.
graph[2][[1]] = 1;
Vertices are zero-indexed, so vertex 4 corresponds to index 4.
Fix the error in the adjacency list insertion code to add vertex 3 to vertex 1's list.
adjList[1].push_back([1]);
To add an edge from vertex 1 to vertex 3, push 3 into vertex 1's adjacency list.
Fill both blanks to create an adjacency list for a graph with 4 vertices.
std::vector<int> adjList[[1]]; adjList[0].push_back([2]);
The graph has 4 vertices, so the array size is 4. Adding an edge from vertex 0 to vertex 1 means pushing 1 into adjList[0].
Fill all three blanks to check if an edge exists from vertex 2 to vertex 3 in an adjacency matrix.
if (graph[[1]][[2]] [3] 1) { printf("Edge exists\n"); }
Check the matrix at row 2, column 3. If the value equals 1, the edge exists.