Complete the code to declare a 2D adjacency matrix for 4 nodes.
int[,] adjacencyMatrix = new int[4, [1]];
The adjacency matrix for 4 nodes is a 4x4 matrix, so both dimensions must be 4.
Complete the code to set an edge from node 1 to node 3 in the adjacency matrix.
adjacencyMatrix[1, [1]] = 1;
Node indices start at 0, so node 3 corresponds to index 2.
Fix the error in the code to correctly check if there is an edge from node 2 to node 0.
if (adjacencyMatrix[[1], 0] == 1) { Console.WriteLine("Edge exists"); }
Node 2 corresponds to index 1 because indexing starts at 0.
Fill both blanks to correctly initialize a 3x3 adjacency matrix with no edges.
int[,] matrix = new int[[1], [2]];
For 3 nodes, the adjacency matrix must be 3x3, so both dimensions are 3.
Fill all three blanks to set an edge from node 0 to node 2 and print if it exists.
matrix[[1], [2]] = 1; if (matrix[[3], 2] == 1) { Console.WriteLine("Edge exists"); }
Set edge from node 0 (index 0) to node 2 (index 2). Then check if edge from node 0 to node 2 exists.
